// http://eslint.org/docs/user-guide/configuring module.exports = { root: true, parser: 'babel-eslint', parserOptions: { sourceType: 'module' }, env: { browser: 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': { // don't require .vue extension when importing 'import/extensions': ['warn', 'always', { 'js': 'never', 'vue': 'never' }], // allow optionalDependencies 'import/no-extraneous-dependencies': ['warn', { 'optionalDependencies': ['test/unit/index.js'] }], // allow debugger during development 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, //'linebreak-style': ['error', 'unix'], // 强制一致的换行风格 //'semi': ["warn", "always"], // 强制句尾使用分号 'object-shorthand': ['warn', 'always'], // 要求对象字面量使用简写 'quotes': ['warn', 'single', { avoidEscape: true }], //要求使用单引号 'func-names': ['warn', 'never'], // 要求函数表达式有一个名字 'global-require': 'warn', // 此规则要求所有调用 require() 必须在模块顶部 'no-underscore-dangle': ['error', { allowAfterThis: false }], // this后面的属性不能用下划线,除非引入了underscore //'eqeqeq': 'error', // 强制使用 === 或 !== //'no-shadow': 'warn', // 禁止变量声明覆盖外层作用域的变量 'no-multi-spaces': 'warn', // 不要有多个 'vars-on-top': 'warn', // 要求将变量声明放在它们作用域的顶部 'space-infix-ops': 'warn', // 中缀运算符周围有空格 'guard-for-in': 'warn', // for in 循环体里要求必须用if判断是否为继承的属性 'no-restricted-syntax': 1, // 禁止使用特定的语法 //'no-unused-expressions': 1, // 禁止未使用过的表达式 'object-curly-spacing': 1, // 要求花括号中使用一致的 'no-trailing-spaces': 1, //禁用行尾空格 'prefer-template': 1, // 建议使用模板而非字符串连接 'no-var': 'warn', // 要求不用var 'comma-dangle': 'off', //强制拖尾逗号 'no-unused-vars': ['error', { 'vars': 'all' }], // 没用到的变量 'no-undef': ['warn'], //禁用未声明的变量,忽略全局变量 //空格 'space-before-function-paren': 'warn', // function 命名函数和匿名函数括号前的空格 'space-before-blocks': 'off', // 程序块之前的空格 'keyword-spacing': 'off', // 强制关键字周围使用空格 'key-spacing': ['warn', { beforeColon: false, afterColon: true }], // 强制在对象字面量的键和值之间使用一致的空格 'spaced-comment': 'off', // 强制注释 // 或 /* 后的空格 'padded-blocks': ['warn', 'never'], //禁止语句块内填充多余空行 'comma-spacing': ['warn', { before: false, after: true }], // 强制在逗号前无空格,分号后有空格 'semi-spacing': ['warn', { before: false, after: true }], // 强制分号前无空格,分号后有空格 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }], //要求对象字面量属性名称使用引号 'linebreak-style': ['warn', 'unix'], 'indent':0, 'no-plusplus':['error',{ "allowForLoopAfterthoughts": true }], 'no-extra-boolean-cast':1, // import rules{ "allowForLoopAfterthoughts": true } // Style guide: // disallow non-import statements appearing before import statements // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md 'import/first': [1, 'absolute-first'], // Require a newline after the last import/require in a group // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md 'import/newline-after-import': 1, // Require modules with a single export to use a default export // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md 'import/prefer-default-export': 1, 'import/no-mutable-exports': 1, } } // module.exports = { // root: true, // parser: 'babel-eslint',//解析器,这里我们使用babel-eslint // parserOptions: { // sourceType: 'module'//类型为module,因为代码使用了使用了ECMAScript模块 // }, // env: { // browser: true,//预定义的全局变量,这里是浏览器环境 // }, // // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style // //extends: 'standard', //扩展,可以通过字符串或者一个数组来扩展规则 // // required to lint *.vue files // plugins: [ // 'html' //插件,此插件用于识别文件中的js代码,没有MIME类型标识没有script标签也可以识别到,因此拿来识别.vue文件中的js代码 // ], // // add your custom rules here // 'rules': { // //这里写自定义规则 // } // }