Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support ESLint 9 Flat Config #573

Merged
merged 6 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -270,35 +270,6 @@ Repository: git://github.com/mde/ejs.git
> limitations under the License.
>

## javascript-stringify

License: MIT
By: Blake Embrey
Repository: git+https://github.com/blakeembrey/javascript-stringify.git

> The MIT License (MIT)
>
> Copyright (c) 2013 Blake Embrey (hello@blakeembrey.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
>

## kleur

License: MIT
Expand Down
76 changes: 0 additions & 76 deletions __test__/renderEslint.spec.ts

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@types/eslint": "^9.6.1",
"@types/node": "^20.16.10",
"@types/prompts": "^2.4.9",
"@vue/create-eslint-config": "^0.3.3",
"@vue/create-eslint-config": "0.4.1",
"@vue/tsconfig": "^0.5.1",
"ejs": "^3.1.10",
"esbuild": "^0.18.20",
Expand Down
40 changes: 21 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import fs from 'node:fs'
import path from 'node:path'
import * as esbuild from 'esbuild'
import esbuildPluginLicense from 'esbuild-plugin-license'

Expand Down Expand Up @@ -48,6 +50,48 @@ await esbuild.build({
})
}
},

{
name: '@vue/create-eslint-config fix',
setup(build) {
// Update esbuild to support the import attributes syntax in this PR is too risky.
// TODO: update esbuild and remove the hack.
build.onLoad({ filter: /@vue.create-eslint-config.index.js$/ }, (args) => {
const text = fs.readFileSync(args.path, 'utf8')
return {
contents: text.replace(`with { type: 'json' }`, ''),
loader: 'js'
}
})

// The renderEjsFile.js module uses file system APIs therefore after bundling it will not work.
// So we need to preprocess it to remove the file system APIs.
build.onLoad({ filter: /@vue.create-eslint-config.renderEjsFile\.js$/ }, (args) => {
const pkgDir = path.dirname(args.path)
const templatesDir = path.resolve(pkgDir, './templates')

const allTemplateFileNames = fs.readdirSync(templatesDir)
const templateFiles = Object.fromEntries(
allTemplateFileNames.map((fileName) => {
const content = fs.readFileSync(path.resolve(templatesDir, fileName), 'utf8')
return [`./templates/${fileName}`, content]
})
)

return {
contents: `
import ejs from 'ejs'
const templates = ${JSON.stringify(templateFiles)}
export default function renderEjsFile(filePath, data) {
return ejs.render(templates[filePath], data, {})
}
`,
loader: 'js'
}
})
}
},

esbuildPluginLicense({
thirdParty: {
includePrivate: false,
Expand Down
2 changes: 1 addition & 1 deletion template/config/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"devDependencies": {
"@types/node": "^20.16.10",
"npm-run-all2": "^6.2.3",
"typescript": "~5.6.0",
"typescript": "~5.5.4",
"vue-tsc": "^2.1.6"
}
}
Loading