# eslint-config-egg Node Style Guide for Egg. ## Install ```bash npm i eslint eslint-config-egg --save-dev ``` ## Usage - `package.json` ```json { "devDependencies": { "eslint-config-egg": "7", "eslint": "4" } } ``` - `.eslintrc.js` ```js module.exports = { extends: 'eslint-config-egg', }; ``` ### Use with TypeScript project - `package.json` ```json { "devDependencies": { "eslint-config-egg": "7", "typescript": "^3.5.3" } } ``` - `.eslintrc.js` ```js module.exports = { extends: 'eslint-config-egg/typescript', parserOptions: { // recommend to use another config file like tsconfig.eslint.json and extends tsconfig.json in it. // because you may be need to lint test/**/*.test.ts but no need to emit to js. // @see https://github.com/typescript-eslint/typescript-eslint/issues/890 project: './tsconfig.json' } }; ``` - `scripts` ```json { "lint": "eslint . --ext .ts" } ``` - `settings.json` in vscode ```json { "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: - `package.json` ```json { "devDependencies": { "eslint-config-egg": "7", "eslint": "4", "babel-eslint": "8" } } ``` - `.eslintrc.js` ```js module.exports = { extends: 'eslint-config-egg', // for experimental features support parser: 'babel-eslint', rules: { // see https://github.com/eslint/eslint/issues/6274 '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: - `package.json` ```json { "devDependencies": { "eslint-config-egg": "7", "eslint": "4", "babel-eslint": "8", "eslint-plugin-react": "7" } } ``` - `.eslintrc.js` ```js module.exports = { extends: 'eslint-config-egg', // for experimental features support parser: 'babel-eslint', 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', }, }; ``` ## License [MIT](LICENSE) ## Contributors |[
popomore](https://github.com/popomore)
|[
fengmk2](https://github.com/fengmk2)
|[
atian25](https://github.com/atian25)
|[
benjycui](https://github.com/benjycui)
|[
geekdada](https://github.com/geekdada)
|[
dead-horse](https://github.com/dead-horse)
| | :---: | :---: | :---: | :---: | :---: | :---: | [
bowei-jbw](https://github.com/bowei-jbw)
|[
aladdin-add](https://github.com/aladdin-add)
|[
hotoo](https://github.com/hotoo)
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Mar 11 2019 15:51:28 GMT+0800`.