$ npm install eslint-config-egg
Node.js Style Guide for Eggjs and Node.js
npm i eslint eslint-config-egg --save-dev
package.json
{
"devDependencies": {
"eslint-config-egg": "13",
"eslint": "8"
}
}
.eslintrc
{
"extends": [
"eslint-config-egg",
"eslint-config-egg/lib/rules/enforce-node-prefix"
]
}
package.json
{
"devDependencies": {
"eslint-config-egg": "13",
"typescript": "^4.5.2"
}
}
.eslintrc
{
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
]
}
scripts
{
"lint": "eslint . --ext .ts"
}
settings.json
in vscode{
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "typescript",
"autoFix": true
},
]
}
If you want to use eslint-config-egg with experimental features such as async function
, you should use @babel/eslint-parser
parser:
package.json
{
"devDependencies": {
"eslint-config-egg": "13",
"eslint": "8",
"@babel/core": "7",
"@babel/eslint-parser": "7"
}
}
.eslintrc.js
module.exports = {
extends: 'eslint-config-egg',
// for experimental features support
parser: '@babel/eslint-parser',
rules: {
// see https://github.com/eslint/eslint/issues/6274
'generator-star-spacing': 'off',
'babel/generator-star-spacing': 'off',
}
};
If you want to use eslint-config-egg with react, jsx and es6 modules:
package.json
{
"devDependencies": {
"eslint-config-egg": "13",
"eslint": "8",
"@babel/core": "7",
"@babel/eslint-parser": "7",
"eslint-plugin-react": "7"
}
}
.eslintrc.js
module.exports = {
extends: 'eslint-config-egg',
// for experimental features support
parser: '@babel/eslint-parser',
parserOptions: {
// for es6 module
sourceType: 'module',
},
plugins: [
'react',
],
rules: {
// for variables in jsx
'react/jsx-uses-vars': 'error',
// see https://github.com/eslint/eslint/issues/6274
'generator-star-spacing': 'off',
'babel/generator-star-spacing': 'off',
},
};
popomore |
fengmk2 |
whxaxes |
atian25 |
benjycui |
geekdada |
---|---|---|---|---|---|
dead-horse |
sang4lv |
nightink |
missjing |
ShadyZOZ |
zhaoxingyue |
bowei-jbw |
aladdin-add |
hotoo |
This project follows the git-contributor spec, auto updated at Thu Jun 02 2022 15:10:46 GMT+0800
.
© 2010 - cnpmjs.org x YWFE | Home | YWFE