1. eslint-config-egg
Node.js Style Guide for Egg.
eslint-config-egg
Package: eslint-config-egg
Created by: eggjs
Last modified: Thu, 25 Apr 2024 12:05:41 GMT
Version: 13.1.0
Downloads: 86,891
Repository: https://github.com/eggjs/eslint-config-egg

Install

npm install eslint-config-egg
yarn add eslint-config-egg

eslint-config-egg

NPM version
build status
Test coverage
Known Vulnerabilities
npm download

Node.js Style Guide for Eggjs and Node.js

Install

 npm i eslint eslint-config-egg --save-dev

Usage

Use with JavaScript project

  • package.json
 {
  "devDependencies": {
    "eslint-config-egg": "13",
    "eslint": "8"
  }
}
  • .eslintrc
 {
  "extends": [
    "eslint-config-egg",
    "eslint-config-egg/lib/rules/enforce-node-prefix"
  ]
}

Use with TypeScript project

  • 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
    },
  ]
}

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:

  • 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',
  }
};

Use with React in Front-End

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',
  },
};

License

MIT

Contributors


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.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin