|
// https://eslint.org/docs/user-guide/configuring |
|
|
|
module.exports = { |
|
root: true, |
|
parser: 'babel-eslint', |
|
parserOptions: { |
|
sourceType: 'module', |
|
}, |
|
env: { |
|
browser: true, |
|
}, |
|
// ignore global vars |
|
globals: { |
|
vm: true, |
|
DDLogin: true, |
|
window: true, |
|
}, |
|
extends: 'airbnb-base', |
|
// required to lint *.vue files |
|
plugins: ['html'], |
|
// check if imports actually resolve |
|
settings: { |
|
'import/resolver': { |
|
webpack: { |
|
config: './build/webpack.base.conf.js', |
|
}, |
|
}, |
|
}, |
|
// add your custom rules here |
|
rules: { |
|
'object-curly-newline': 'off', |
|
'consistent-return': 'off', |
|
'no-nested-ternary': 'off', |
|
'import/first': 'off', |
|
'no-unused-vars': [ |
|
'warn', |
|
{ |
|
vars: 'all', |
|
args: 'after-used', |
|
ignoreRestSiblings: false, |
|
}, |
|
], |
|
// don't require .vue extension when importing |
|
'import/extensions': [ |
|
'error', |
|
'always', |
|
{ |
|
js: 'never', |
|
vue: 'never', |
|
}, |
|
], |
|
// disallow reassignment of function parameters |
|
// disallow parameter object manipulation except for specific exclusions |
|
'no-param-reassign': [ |
|
'error', |
|
{ |
|
props: true, |
|
ignorePropertyModificationsFor: [ |
|
'state', // for vuex state |
|
'acc', // for reduce accumulators |
|
'e', // for e.returnvalue |
|
], |
|
}, |
|
], |
|
// allow optionalDependencies |
|
'import/no-extraneous-dependencies': [ |
|
'error', |
|
{ |
|
optionalDependencies: ['test/unit/index.js'], |
|
}, |
|
], |
|
// allow debugger during development |
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', |
|
// Severity should be one of the following: 0 = off, 1 = warn, 2 = error |
|
// allow console in debug mode, but will be auto removed in production by webpack |
|
'no-console': [ |
|
'error', |
|
{ |
|
allow: ['warn', 'error', 'log'], |
|
}, |
|
], |
|
// 箭头函数体只有一个参数时,可以省略圆括号。其它任何情况,参数都应被圆括号括起来。该规则强制箭头函数中圆括号的使用的一致性。 |
|
'arrow-parens': [ |
|
0, |
|
'as-needed', |
|
{ |
|
requireForBlockBody: true, |
|
}, |
|
], |
|
'implicit-arrow-linebreak': ['error', 'beside'], |
|
// TODO |
|
'no-param-reassign': 0, |
|
// 去除注释的最大长度限制 |
|
'max-len': [ |
|
'error', |
|
{ |
|
ignoreComments: true, |
|
ignoreStrings: true, |
|
code: 200, |
|
}, |
|
], |
|
'import/prefer-default-export': 0, |
|
'import/extensions': 0, |
|
// 转义相关:https://eslint.org/docs/rules/no-useless-escape#disallow-unnecessary-escape-usage-no-useless-escape |
|
'no-useless-escape': 0, |
|
'func-names': 0, |
|
// 处理 i++ 规则, qu https://eslint.org/docs/rules/no-plusplus |
|
'no-plusplus': [ |
|
'error', |
|
{ |
|
allowForLoopAfterthoughts: true, |
|
}, |
|
], |
|
'no-underscore-dangle': [0], |
|
'operator-linebreak': 0, |
|
'implicit-arrow-linebreak': 0, |
|
'function-paren-newline': 0, |
|
'no-restricted-globals': 0, |
|
'space-before-function-paren': 0, |
|
'prefer-destructuring': 0, |
|
}, |
|
}; |