json ESLint配置为es6-babel

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json ESLint配置为es6-babel相关的知识,希望对你有一定的参考价值。

{
  "parser": "babel-eslint",

  "env": {
    "browser": true
  },

  "globals": {
    "define": true,
    "require": true,
    "template": true,
    "styles": true
  },

  "rules": {
    "comma-dangle": [ "warn", "always-multiline" ],
    "no-cond-assign": [ "error", "except-parens" ],
    "no-console": "warn",
    "no-constant-condition": "error",
    "no-control-regex": "error",
    "no-debugger": "error",
    "no-dupe-args": "error",
    "no-dupe-keys": "error",
    "no-duplicate-case": "error",
    "no-empty": "error",
    "no-empty-character-class": "error",
    "no-ex-assign": "error",
    "no-extra-boolean-cast": "error",
    "no-extra-parens": "warn",
    "no-extra-semi": "error",
    "no-func-assign": "error",
    "no-inner-declarations": "warn",
    "no-invalid-regexp": "error",
    "no-irregular-whitespace": "error",
    "no-negated-in-lhs": "error",
    "no-obj-calls": "error",
    "no-regex-spaces": "error",
    "no-sparse-arrays": "error",
    "no-unexpected-multiline": "error",
    "no-unreachable": "error",
    "use-isnan": "error",
    "valid-jsdoc": "warn",
    "valid-typeof": "error",

    // Best Practices
    "accessor-pairs": "error",
    "array-callback-return": "error",
    "block-scoped-var": "error",
    "complexity": [ "error", 7 ],
    "consistent-return": "off",
    "curly": "off",
    "default-case": "error",
    "dot-location": [ "error", "property" ],
    "dot-notation": "error",
    "eqeqeq": [ "error", "allow-null" ],
    "guard-for-in": "error",
    "no-alert": "error",
    "no-caller": "error",
    "no-case-declarations": "error",
    "no-div-regex": "error",
    "no-else-return": "warn",
    "no-empty-function": "warn",
    "no-empty-pattern": "error",
    "no-eq-null": "off",
    "no-eval": "error",
    "no-extend-native": [ "error", { "exceptions": [ "Promise" ]}],
    "no-extra-bind": "error",
    "no-extra-label": "error",
    "no-fallthrough": "error",
    "no-floating-decimal": "error",
    "no-implicit-coercion": "error",
    "no-implicit-globals": "error",
    "no-implied-eval": "error",
    "no-invalid-this": "error",
    "no-iterator": "error",
    "no-labels": "error",
    "no-lone-blocks": "error",
    "no-loop-func": "error",
    "no-magic-numbers": [ "warn", { "ignore": [ -1, 0, 1, 2 ]}],
    "no-multi-spaces": "error",
    "no-multi-str": "error",
    "no-native-reassign": "error",
    "no-new": "error",
    "no-new-func": "error",
    "no-new-wrappers": "error",
    "no-octal": "error",
    "no-octal-escape": "error",
    "no-param-reassign": "error",
    "no-proto": "error",
    "no-redeclare": "error",
    "no-return-assign": "off",
    "no-script-url": "error",
    "no-self-assign": "error",
    "no-self-compare": "error",
    "no-sequences": "error",
    "no-throw-literal": "error",
    "no-unmodified-loop-condition": "error",
    "no-unused-expressions": "error",
    "no-useless-call": "error",
    "no-useless-concat": "error",
    "no-useless-escape": "error",
    "no-void": "error",
    "no-with": "error",
    "vars-on-top": "off",
    "wrap-iife": [ "error", "inside" ],
    "yoda": [ "error", "never", { "exceptRange": true }],
    "strict": [ "error", "function" ],

    // Variables
    "init-declarations": [ "warn", "always" ],
    "no-catch-shadow": "error",
    "no-delete-var": "error",
    "no-shadow": "off",
    "no-shadow-restricted-names": "error",
    "no-undef": "error",
    "no-undef-init": "error",
    "no-undefined": "error",
    "no-unused-vars": [ "error", { "vars": "all", "args": "after-used", "varsIgnorePattern": "[Inject|styles]" }],
    "no-use-before-define": [ "error", { "functions": false }],

    // Node.js and CommonJS
    "callback-return": "error",
    "no-new-require": "error",
    "no-path-concat": "error",
    "no-process-env": "error",
    "no-process-exit": "error",

    // Stylistic Issues
    "array-bracket-spacing": [ "warn", "always", { "objectsInArrays": false, "arraysInArrays": false }],
    "block-spacing": [ "warn", "always" ],
    "brace-style": [ "error", "stroustrup", { "allowSingleLine": false }],
    "camelcase": "error",
    "comma-spacing": "error",
    "comma-style": [ "error", "last" ],
    "computed-property-spacing": [ "warn", "never" ],
    "consistent-this": [ "error", "self" ],
    "eol-last": "error",
    "func-names": "off",
    "func-style": [ "error", "declaration" ],
    // "id-blacklist": "error",
    "id-length": [ "error", { "min": 2, "exceptions": [ "_", "i" ]}],
    "indent": [ "error", 2, { "SwitchCase": 1 }],
    "key-spacing": "warn",
    "keyword-spacing": "warn",
    "linebreak-style": [ "error", "unix" ],
    "max-depth": [ "error", 5 ],
    "max-len": [ "error", { "code": 120, "tabWidth": 2 }],
    "max-nested-callbacks": "off", // deprecated in favor of max-depth
    "max-params": [ "error", 6 ],
    "max-statements": "off",
    "max-statements-per-line": "error",
    "new-cap": "off",
    "new-parens": "error",
    "newline-after-var": "off", // [ "warn", "always" ],
    "newline-before-return": "off",
    "newline-per-chained-call": [ "warn" ],
    "no-array-constructor": "error",
    "no-bitwise": "error",
    "no-continue": "error",
    "no-inline-comments": "warn",
    "no-lonely-if": "warn",
    "no-mixed-spaces-and-tabs": "error",
    "no-multiple-empty-lines": [ "error", { "max": 2 }],
    "no-negated-condition": "warn",
    "no-nested-ternary": "error",
    "no-new-object": "error",
    "no-plusplus": "off",
    "no-restricted-syntax": "off",
    "no-spaced-func": "warn",
    "no-ternary": "off",
    "no-trailing-spaces": "error",
    "no-underscore-dangle": [ "error", { "allowAfterThis": true }],
    "no-unneeded-ternary": "warn",
    "no-whitespace-before-property": "error",
    "object-curly-spacing": [ "warn", "always", { "objectsInObjects": false, "arraysInObjects": false }],
    "one-var": [ "error", "never" ],
    "one-var-declaration-per-line": [ "warn", "initializations" ],
    "operator-assignment": "off",
    "operator-linebreak": [ "warn", "after" ],
    "padded-blocks": "off", // [ "warn", "never" ],
    "quote-props": [ "error", "as-needed"],
    "quotes": [ "error", "single", "avoid-escape"],
    "require-jsdoc": "off",
    "semi": [ "error", "always"],
    "semi-spacing": "warn",
    "space-before-blocks": [ "error", "always" ],
    "space-before-function-paren": [ "error", "never" ],
    "space-in-parens": [ "error", "never" ],
    "space-infix-ops": [ "error", { "int32Hint": false }],
    "space-unary-ops": [ "error", { "words": true, "nonwords": false }],
    "spaced-comment": [ "error", "always", { "exceptions": [ "*" ]}],
    "wrap-regex": "off"
  }
}

以上是关于json ESLint配置为es6-babel的主要内容,如果未能解决你的问题,请参考以下文章

各种关闭eslint方法总结

eslint的setting.json配置

如何配置 package.json 来运行 eslint 脚本

json ESLint配置

json ESLint配置

json React项目的ESLint配置