Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement a migrator to auto add eslint to deps (#4549)
- Loading branch information
Showing
2 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = (api) => { | ||
// if project is scaffolded by Vue CLI 3.0.x or earlier, | ||
// the ESLint dependency (ESLint v4) is inside @vue/cli-plugin-eslint; | ||
// in Vue CLI v4 it should be extracted to the project dependency list. | ||
if (api.fromVersion('^3')) { | ||
const pkg = require(api.resolve('package.json')) | ||
const hasESLint = [ | ||
'dependencies', | ||
'devDependencies', | ||
'peerDependencies', | ||
'optionalDependencies' | ||
].some(depType => | ||
Object.keys(pkg[depType] || {}).includes('eslint') | ||
) | ||
|
||
if (!hasESLint) { | ||
api.extendPackage({ | ||
devDependencies: { | ||
eslint: '^4.19.1' | ||
} | ||
}) | ||
} | ||
|
||
// TODO: add a prompt for users to optionally upgrade their eslint configs to a new major version | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters