Skip to content

Instantly share code, notes, and snippets.

@xhsdnn
Created January 6, 2021 08:42
Show Gist options
  • Save xhsdnn/2a7561dab6bcdaf16c5f1e5d43065fed to your computer and use it in GitHub Desktop.
Save xhsdnn/2a7561dab6bcdaf16c5f1e5d43065fed to your computer and use it in GitHub Desktop.
// https://eslint.org/docs/user-guide/configuring
/*
* 0 - off
* 1 - warn
* 2 - error
*/
module.exports = {
extends: "eslint:recommended",
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2018,
sourceType: "module"
},
globals: {
"console": "readonly",
"module": "readonly"
},
// https://eslint.org/docs/rules/
rules: {
"no-debugger": 2, // prod-2/dev-0
"no-console": [1, { "allow": ["warn", "error"] }],
"complexity": [2, { max: 5 }],
"consistent-return": 2,
"default-case": 1,
"eqeqeq": 2,
"no-alert": 2,
"no-caller": 2,
"no-else-return": 2,
"no-eval": 2,
"no-extra-bind": 1,
"no-extra-label": 1,
"no-implied-eval": 2,
"no-iterator": 2,
"no-lone-blocks": 1,
"no-loop-func": 2,
"no-magic-numbers": 0,
"no-multi-spaces": 2,
"no-new-func": 1,
"no-new-wrappers": 1,
"no-param-reassign": 2,
"no-proto": 1,
// "no-restricted-properties": [2, {
// "user": "name"
// }]
"no-return-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-throw-literal": 2,
"no-unmodified-loop-condition": 2,
"no-useless-call": 2,
"no-useless-concat": 2,
"no-useless-return": 2,
"prefer-promise-reject-errors": 2, // 便于抓取错误信息
"require-await": 2,
"vars-on-top": 2, // todo: 如何使用let
"wrap-iife": [2, "inside", { functionPrototypeMethods: true }],
"yoda": [2, "never", { onlyEquality: true }],
"no-label-var": 2,
"no-restricted-globals": [2, { name: "event" }, { name: "error" }],
// Stylistic
"array-bracket-spacing": [2, "never"],
"block-spacing": 2,
"brace-style": [2, "1tbs", { allowSingleLine: true }],
// "camelcase": [2, { ignoreDestructuring: true }] ,
"comma-dangle": 2,
"comma-spacing": 2,
"comma-style": 2,
"computed-property-spacing": 2,
"func-call-spacing": 2,
"function-paren-newline": 2,
"id-blacklist": [2, ""], // 禁止声明的列表
// "id-match": , // 声明标识符的规则
"implicit-arrow-linebreak": 2,
"indent": [1, 4],
"key-spacing": 2,
"keyword-spacing": [2, { before: true, after: true, overrides: { if: { after: false }, for: { after: false }, super: { after: false }, while: { after: false } } }],
"max-depth": 1,
"max-nested-callbacks": 1,
"max-params": [1, 3],
"new-cap": 2,
"new-parens": 2,
"no-lonely-if": 2,
"no-multiple-empty-lines": 2,
"no-whitespace-before-property": 2,
"object-curly-spacing": [2, "always"],
"one-var": [2, "consecutive"],
"semi": 2,
"semi-spacing": 2,
"semi-style": 2,
"space-before-blocks": 2,
"space-before-function-paren": [2, "never"],
"space-in-parens": 2,
"space-infix-ops": 2,
"space-unary-ops": [2, { words: true, nonwords: false }],
"spaced-comment": [2, "always"],
"switch-colon-spacing": [2, { after: true, before: false }],
// es6
"arrow-body-style": [2, "as-needed"],
"arrow-parens": [2, "as-needed"],
"arrow-spacing": [2, { after: true, before: true }],
"generator-star-spacing": [2, "before"],
"no-duplicate-imports": [2, { includeExports: true }],
"no-useless-computed-key": 2,
"no-useless-rename": 2,
"no-var": 2,
"prefer-rest-params": 2,
// "prefer-template": 1,
"rest-spread-spacing": [2, "never"],
"symbol-description": 1,
"template-curly-spacing": 2
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment