Eslint and Egg.js lint error

Using Eslint with egg.js will have errors when linting files using:

eslint --fix --ext .js,.vue --ignore-path .gitignore .
Full Error Message ``` D:\server>eslint --fix --ext .js,.vue --ignore-path .gitignore . Error: Cannot find module 'eslint-config-egg' Referenced from: D:\server\.eslintrc at ModuleResolver.resolve (C:\Users\Johnson\AppData\Roaming\npm\node_modules\eslint\lib\util\module-resolver.js:72:19) at resolve (C:\Users\Johnson\AppData\Roaming\npm\node_modules\eslint\lib\config\config-file.js:484:28) at load (C:\Users\Johnson\AppData\Roaming\npm\node_modules\eslint\lib\config\config-file.js:556:26) at configExtends.reduceRight (C:\Users\Johnson\AppData\Roaming\npm\node_modules\eslint\lib\config\config-file.js:430:36) at Array.reduceRight () at applyExtends (C:\Users\Johnson\AppData\Roaming\npm\node_modules\eslint\lib\config\config-file.js:408:26) at loadFromDisk (C:\Users\Johnson\AppData\Roaming\npm\node_modules\eslint\lib\config\config-file.js:528:22) at Object.load (C:\Users\Johnson\AppData\Roaming\npm\node_modules\eslint\lib\config\config-file.js:564:20) at Config.getLocalConfigHierarchy (C:\Users\Johnson\AppData\Roaming\npm\node_modules\eslint\lib\config.js:240:44) at Config.getConfigHierarchy (C:\Users\Johnson\AppData\Roaming\npm\node_modules\eslint\lib\config.js:192:43) (node:7612) [ESLINT_LEGACY_ECMAFEATURES] DeprecationWarning: The 'ecmaFeatures' config file property is deprecated, and has no effect. (found in ".eslintrc") ``` </details>
The reason is because `eslint-config-egg` is not in eslint global file. So we should use the local eslint instead: ``` node_modules/.bin/eslint --fix --ext .js,.vue --ignore-path .gitignore . ``` For Windows users: ``` node_modules\.bin\eslint --fix --ext .js,.vue --ignore-path .gitignore . ``` ## Further Reading 1. [Error: Cannot find module 'eslint-config-standard' \| GitHub Issues](https://github.com/standard/eslint-config-standard/issues/84#issuecomment-315129706)

Posted:

Comments