Skip to content

Commit cf88c6d

Browse files
committed
feat: add eslint support
1 parent dc4b430 commit cf88c6d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

generator/index.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,42 @@ module.exports = (api) => {
1313
prune: true
1414
})
1515

16+
if (api.hasPlugin('eslint')) {
17+
api.extendPackage({
18+
devDependencies: {
19+
'eslint-plugin-vue': '^7.0.0-alpha.0'
20+
}
21+
})
22+
23+
// `plugin:vue/essential` -> `plugin:vue/vue3-essential`, etc.
24+
const updateConfig = cfg =>
25+
cfg.replace(
26+
/plugin:vue\/(essential|recommended|strongly-recommended)/gi,
27+
'plugin:vue/vue3-$1'
28+
)
29+
30+
// if the config is placed in `package.json`
31+
const eslintConfigInPkg = api.generator.pkg.eslintConfig
32+
if (eslintConfigInPkg && eslintConfigInPkg.extends) {
33+
eslintConfigInPkg.extends = eslintConfigInPkg.extends.map(cfg => updateConfig(cfg))
34+
}
35+
// if the config has been extracted to a standalone file
36+
api.render((files) => {
37+
for (const filename of [
38+
'.eslintrc.js',
39+
'.eslintrc.cjs',
40+
'.eslintrc.yaml',
41+
'.eslintrc.yml',
42+
'.eslinrc.json',
43+
'.eslintrc'
44+
]) {
45+
if (files[filename]) {
46+
files[filename] = updateConfig(files[filename])
47+
}
48+
}
49+
})
50+
}
51+
1652
if (api.hasPlugin('vuex') || api.generator.pkg.dependencies['vuex']) {
1753
api.extendPackage({
1854
dependencies: {

0 commit comments

Comments
 (0)