Skip to content

Commit 053c8ab

Browse files
authored
feat: support ESLint 9 Flat Config (#573)
1 parent cd20177 commit 053c8ab

File tree

7 files changed

+135
-174
lines changed

7 files changed

+135
-174
lines changed

LICENSE

-29
Original file line numberDiff line numberDiff line change
@@ -270,35 +270,6 @@ Repository: git://github.com/mde/ejs.git
270270
> limitations under the License.
271271
>
272272

273-
## javascript-stringify
274-
275-
License: MIT
276-
By: Blake Embrey
277-
Repository: git+https://github.com/blakeembrey/javascript-stringify.git
278-
279-
> The MIT License (MIT)
280-
>
281-
> Copyright (c) 2013 Blake Embrey ([email protected])
282-
>
283-
> Permission is hereby granted, free of charge, to any person obtaining a copy
284-
> of this software and associated documentation files (the "Software"), to deal
285-
> in the Software without restriction, including without limitation the rights
286-
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
287-
> copies of the Software, and to permit persons to whom the Software is
288-
> furnished to do so, subject to the following conditions:
289-
>
290-
> The above copyright notice and this permission notice shall be included in
291-
> all copies or substantial portions of the Software.
292-
>
293-
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
294-
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
295-
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
296-
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
297-
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
298-
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
299-
> THE SOFTWARE.
300-
>
301-
302273
## kleur
303274

304275
License: MIT

__test__/renderEslint.spec.ts

-76
This file was deleted.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@types/eslint": "^9.6.1",
4242
"@types/node": "^20.16.10",
4343
"@types/prompts": "^2.4.9",
44-
"@vue/create-eslint-config": "^0.3.3",
44+
"@vue/create-eslint-config": "0.4.1",
4545
"@vue/tsconfig": "^0.5.1",
4646
"ejs": "^3.1.10",
4747
"esbuild": "^0.18.20",

pnpm-lock.yaml

+21-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build.mjs

+44
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import fs from 'node:fs'
2+
import path from 'node:path'
13
import * as esbuild from 'esbuild'
24
import esbuildPluginLicense from 'esbuild-plugin-license'
35

@@ -48,6 +50,48 @@ await esbuild.build({
4850
})
4951
}
5052
},
53+
54+
{
55+
name: '@vue/create-eslint-config fix',
56+
setup(build) {
57+
// Update esbuild to support the import attributes syntax in this PR is too risky.
58+
// TODO: update esbuild and remove the hack.
59+
build.onLoad({ filter: /@vue.create-eslint-config.index.js$/ }, (args) => {
60+
const text = fs.readFileSync(args.path, 'utf8')
61+
return {
62+
contents: text.replace(`with { type: 'json' }`, ''),
63+
loader: 'js'
64+
}
65+
})
66+
67+
// The renderEjsFile.js module uses file system APIs therefore after bundling it will not work.
68+
// So we need to preprocess it to remove the file system APIs.
69+
build.onLoad({ filter: /@vue.create-eslint-config.renderEjsFile\.js$/ }, (args) => {
70+
const pkgDir = path.dirname(args.path)
71+
const templatesDir = path.resolve(pkgDir, './templates')
72+
73+
const allTemplateFileNames = fs.readdirSync(templatesDir)
74+
const templateFiles = Object.fromEntries(
75+
allTemplateFileNames.map((fileName) => {
76+
const content = fs.readFileSync(path.resolve(templatesDir, fileName), 'utf8')
77+
return [`./templates/${fileName}`, content]
78+
})
79+
)
80+
81+
return {
82+
contents: `
83+
import ejs from 'ejs'
84+
const templates = ${JSON.stringify(templateFiles)}
85+
export default function renderEjsFile(filePath, data) {
86+
return ejs.render(templates[filePath], data, {})
87+
}
88+
`,
89+
loader: 'js'
90+
}
91+
})
92+
}
93+
},
94+
5195
esbuildPluginLicense({
5296
thirdParty: {
5397
includePrivate: false,

template/config/typescript/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"devDependencies": {
88
"@types/node": "^20.16.10",
99
"npm-run-all2": "^6.2.3",
10-
"typescript": "~5.6.0",
10+
"typescript": "~5.5.4",
1111
"vue-tsc": "^2.1.6"
1212
}
1313
}

0 commit comments

Comments
 (0)