ESLint最初是由Nicholas C. Zakas 于2013年6月创建的开源项目。它的目标是提供一个插件化的javascript代码检测工具。用于检测JS代码中常见的一些语法错误。

常用ESLint配置

/
“off”或者0,不启用这个规则
“warn”或者1,出现问题会有警告
“error”或者2,出现问题会报错
*/
module.exports = {
root: true,
env: {
node: true
},
‘extends’: [
‘plugin:vue/strongly-recommended’,
‘@vue/standard’
],
rules: {
‘no-console’: process.env.NODE_ENV === ‘production’ ? ‘error’ : ‘off’,
‘no-debugger’: process.env.NODE_ENV === ‘production’ ? ‘error’ : ‘off’,
‘generator-star-spacing’: ‘off’,
‘no-mixed-operators’: 0,
‘vue/max-attributes-per-line’: [
2,
{
‘singleline’: 5,
‘multiline’: {
‘max’: 1,
‘allowFirstLine’: false
}
}
],
‘vue/attribute-hyphenation’: 0,
‘vue/html-self-closing’: 0,
‘vue/component-name-in-template-casing’: 0,
‘vue/html-closing-bracket-spacing’: 0,
‘vue/singleline-html-element-content-newline’: 0,
‘vue/no-unused-components’: 0,
‘vue/multiline-html-element-content-newline’: 0,
‘vue/no-use-v-if-with-v-for’: 0,
‘vue/html-closing-bracket-newline’: 0,
‘vue/no-parsing-error’: 0,
‘no-tabs’: 0,
‘quotes’: [
0,
‘single’,
{
‘avoidEscape’: true,
‘allowTemplateLiterals’: true
}
],
‘semi’: [
0,
‘never’,
{
‘beforeStatementContinuationChars’: ‘never’
}
],
‘no-delete-var’: 2,
‘prefer-const’: [
0,
{
‘ignoreReadBeforeAssign’: false
}
],
‘template-curly-spacing’: ‘off’,
‘indent’: ‘off’,
‘keyword-spacing’: 0,
‘no-extra-semi’: 0,
‘no-alert’: 2,
‘no-eval’: 2,
‘eqeqeq’: 0,
‘eol-last’: 0,
‘comma-dangle’: 0,
‘no-unused-vars’: 0
},
parserOptions: {
parser: ‘babel-eslint’
}
}