Code Monkey home page Code Monkey logo

eslint-config-egg's Introduction

eslint-config-egg

Node Style Guide for Egg.

Install

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

Usage

  • package.json
{
  "devDependencies": {
    "eslint-config-egg": "10",
    "eslint": "8"
  }
}
  • .eslintrc.js
module.exports = {
  extends: 'eslint-config-egg',
};

Use with TypeScript project

  • package.json
{
  "devDependencies": {
    "eslint-config-egg": "8",
    "typescript": "^4.5.2"
  }
}
  • .eslintrc.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
{
  "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": "10",
    "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": "10",
    "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


whxaxes


fengmk2


atian25


benjycui


geekdada


dead-horse


sang4lv


missjing


ShadyZOZ


zhaoxingyue


bowei-jbw


aladdin-add


hotoo

This project follows the git-contributor spec, auto updated at Wed Nov 24 2021 15:28:00 GMT+0800.

eslint-config-egg's People

Contributors

aladdin-add avatar atian25 avatar benjycui avatar bowei-jbw avatar dead-horse avatar fengmk2 avatar geekdada avatar hotoo avatar missjing avatar popomore avatar sang4lv avatar shadyzoz avatar whxaxes avatar zhaoxingyue avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.