eslint

32 阅读1分钟

module.exports = { root: true, env: { browser: true, node: true, commonjs: true, es6: true, }, globals: { webpackConfig: 'readonly', // 配置多级目录访问地址 }, plugins: ['eslint-plugin-babel', 'eslint-plugin-vue', 'eslint-plugin-html'], // Prettier will be automatically injected by plugin:prettier/recommended settings: { 'import/resolver': 'webpack', }, rules: { 'no-new': 'off', 'no-debugger': 'warn', 'no-var': 'error', // 圈复杂度 complexity: ['error', 10], // 块嵌套最大深度 'max-depth': ['error', 5], // 最大行长 'max-len': ['error', { code: 150, tabWidth: 4 }], // 一个文件最大行数 'max-lines': [ 'error', { max: 500, skipBlankLines: true, skipComments: true }, ], // 回调嵌套最大深度 'max-nested-callbacks': ['error', { max: 5 }], // 一个方法最大行数 'max-lines-per-function': ['error', 100], }, parser: 'vue-eslint-parser', // extends eslint config extends: [ 'eslint-config-standard', 'plugin:eslint-plugin-prettier/recommended', // integrate eslint-plugin-prettier with eslint-config-prettier 'eslint-config-prettier/babel', 'eslint-config-prettier/vue', 'eslint-config-prettier/standard', ], };