eslint-config-egg
Node.js Style Guide for Egg.
Install
npm i eslint eslint-config-egg --save-dev
Usage
{
"devDependencies": {
"eslint-config-egg": "12",
"eslint": "8"
}
}
module.exports = {
extends: 'eslint-config-egg',
};
Use with TypeScript project
{
"devDependencies": {
"eslint-config-egg": "12",
"typescript": "^4.5.2"
}
}
module.exports = {
extends: 'eslint-config-egg/typescript',
parserOptions: {
project: './tsconfig.json'
}
};
{
"lint": "eslint . --ext .ts"
}
{
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "typescript",
"autoFix": true
},
]
}
Use with Experimental Features
If you want to use eslint-config-egg with experimental features such as async function
, you should use @babel/eslint-parser
parser:
{
"devDependencies": {
"eslint-config-egg": "12",
"eslint": "8",
"@babel/core": "7",
"@babel/eslint-parser": "7"
}
}
module.exports = {
extends: 'eslint-config-egg',
parser: '@babel/eslint-parser',
rules: {
'generator-star-spacing': 'off',
'babel/generator-star-spacing': 'off',
}
};
Use with React in Front-End
If you want to use eslint-config-egg with react, jsx and es6 modules:
{
"devDependencies": {
"eslint-config-egg": "12",
"eslint": "8",
"@babel/core": "7",
"@babel/eslint-parser": "7",
"eslint-plugin-react": "7"
}
}
module.exports = {
extends: 'eslint-config-egg',
parser: '@babel/eslint-parser',
parserOptions: {
sourceType: 'module',
},
plugins: [
'react',
],
rules: {
'react/jsx-uses-vars': 'error',
'generator-star-spacing': 'off',
'babel/generator-star-spacing': 'off',
},
};
License
MIT
Contributors
This project follows the git-contributor spec, auto updated at Thu Jun 02 2022 15:10:46 GMT+0800
.