规则值
- " off " 或者 0,关闭
- " warn " 或者 1,警告
- " error " 或者 2,报错
.eslintrc.js配置
module.exports = {
root: true,
env: {
amd: true,
es6: true,
commonjs: true,
node: true,
jquery: true,
browser: true
},
extends: [
'plugin:vue/essential',
'@vue/standard'
],
parserOptions: {
sourceType: 'module',
parser: 'babel-eslint'
},
rules: {
'array-bracket-spacing': ['error', 'never'],
'arrow-parens': 'off',
'block-spacing': ['error', 'always'],
'accessor-pairs': 'off',
'block-scoped-var': 'off',
'brace-style': ['warn', '1tabs'],
'callback-return': 'warn',
'camelcase': 'error',
'comma-dangle': ['error', 'never'],
'comma-spacing': 'off',
'comma-style': ['error', 'last'],
'complexity': ['off', 11],
'computed-property-spacing': ['off', 'never'],
'consistent-return': 'off',
'consistent-this': ['error', 'that'],
'constructor-super': 'off',
'curly': ['error', 'all'],
'default-case': 'error',
'dot-location': 'off',
'dot-notation': ['off', { 'allowKeywords': true }],
'eol-last': 'off',
'eqeqeq': 'error',
'func-names': 'off',
'func-style': ['off', 'declaration'],
'generator-star-spacing': 'off',
'guard-for-in': 'off',
'handle-callback-err': 'off',
'id-length': 'off',
'indent': ['error', 4],
'init-declarations': 'off',
'key-spacing': ['off', { 'beforeColon': false, 'afterColon': true }],
'lines-around-comment': 'off',
'max-depth': ['off', 4],
'max-len': ['off', 80, 4],
'max-nested-callbacks': ['off', 'error'],
'max-params': ['off', 3],
'max-statements': ['off', 10],
'new-cap': 'error',
'new-parens': 'error',
'newline-after-var': 'error',
'no-alert': 'off',
'no-array-constructor': 'error',
'no-bitwise': 'off',
'no-caller': 'warn',
'no-catch-shadow': 'error',
'no-class-assign': 'error',
'no-cond-assign': 'error',
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-const-assign': 'error',
'no-constant-condition': 'error',
'no-continue': 'off',
'no-control-regex': 'error',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-delete-var': 'error',
'no-div-regex': 'warn',
'no-dupe-keys': 'error',
'no-dupe-args': 'error',
'no-duplicate-case': 'error',
'no-else-return': 'error',
'no-empty': 'error',
'no-empty-character-class': 'error',
'no-empty-label': 'error',
'no-eq-null': 'error',
'no-eval': 'warn',
'no-ex-assign': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-boolean-cast': 'error',
'no-extra-parens': 'error',
'no-extra-semi': 'error',
'no-fallthrough': 'warn',
'no-floating-decimal': 'error',
'no-func-assign': 'error',
'no-implicit-coercion': 'warn',
'no-implied-eval': 'error',
'no-inline-comments': 'off',
'no-inner-declarations': ['error', 'functions'],
'no-invalid-regexp': 'error',
'no-invalid-this': 'error',
'no-irregular-whitespace': 'error',
'no-iterator': 'error',
'no-label-var': 'error',
'no-labels': 'error',
'no-lone-blocks': 'error',
'no-lonely-if': 'error',
'no-loop-func': 'warn',
'no-mixed-requires': ['off', false],
'no-mixed-spaces-and-tabs': ['error', false],
'linebreak-style': ['off', 'windows'],
'no-multi-spaces': 'warn',
'no-multi-str': 'error',
'no-multiple-empty-lines': ['warn', {'max': 'error'}],
'no-native-reassign': 'error',
'no-negated-in-lhs': 'error',
'no-nested-ternary': 'off',
'no-new': 'warn',
'no-new-func': 'warn',
'no-new-object': 'error',
'no-new-require': 'error',
'no-new-wrappers': 'error',
'no-obj-calls': 'error',
'no-octal': 'error',
'no-octal-escape': 'error',
'no-param-reassign': 'error',
'no-path-concat': 'off',
'no-plusplus': 'off',
'no-process-env': 'off',
'no-process-exit': 'off',
'no-proto': 'error',
'no-redeclare': 'error',
'no-regex-spaces': 'error',
'no-restricted-modules': 'off',
'no-return-assign': 'warn',
'no-script-url': 'off',
'no-self-compare': 'error',
'no-sequences': 'off',
'no-shadow': 'error',
'no-shadow-restricted-names': 'error',
'no-spaced-func': 'error',
'no-sparse-arrays': 'error',
'no-sync': 'off',
'no-ternary': 'off',
'no-trailing-spaces': 'warn',
'no-this-before-super': 'off',
'no-throw-literal': 'error',
'no-undef': 'warn',
'no-undef-init': 'error',
'no-undefined': 'error',
'no-unexpected-multiline': 'error',
'no-underscore-dangle': 'warn',
'no-unneeded-ternary': 'error',
'no-unreachable': 'error',
'no-unused-expressions': 'error',
'no-unused-vars': ['error', {'vars': 'all', 'args': 'after-used'}],
'no-use-before-define': 'error',
'no-useless-call': 'error',
'no-void': 'error',
'no-var': 'off',
'no-warning-comments': ['warn', { 'terms': ['todo', 'fixme', 'xxx'], 'location': 'start' }],
'no-with': 'error',
'object-curly-spacing': ['off', 'never'],
'object-shorthand': 'off',
'one-var': 'warn',
'operator-assignment': ['off', 'always'],
'operator-linebreak': ['error', 'after'],
'padded-blocks': 'off',
'prefer-const': 'off',
'prefer-spread': 'off',
'prefer-reflect': 'off',
'quotes': ['warn', 'single'],
'quote-props':['error', 'always'],
'radix': 'error',
'id-match': 'off',
'require-yield': 'off',
'semi': ['error', 'always'],
'semi-spacing': ['off', {'before': false, 'after': true}],
'sort-vars': 'off',
'space-after-keywords': ['off', 'always'],
'space-before-blocks': ['off', 'always'],
'space-before-function-paren': ['off', 'always'],
'space-in-parens': ['off', 'never'],
'space-infix-ops': 'off',
'space-return-throw-case': 'error',
'space-unary-ops': ['off', { 'words': true, 'nonwords': false }],
'spaced-comment': 'off',
'strict': 'error',
'use-isnan': 'error',
'valid-jsdoc': 'off',
'valid-typeof': 'error',
'vars-on-top': 'error',
'vue/require-v-for-key': 'off',
'wrap-iife': ['error', 'inside'],
'wrap-regex': 'off',
'yoda': ['error', 'never']
}
}