module.exports = {
root: true,
env: {
node: true
extends: [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/prettier',
'@vue/prettier/@typescript-eslint',
'@vue/typescript/recommended'
parser: 'vue-eslint-parser', //解析.vue文件
parserOptions: {
parser: '@typescript-eslint/parser', // 解析 .ts 文件
ecmaVersion: 2020
rules: {
'new-cap': ['error', { capIsNew: false }], //大写字母开头的函数必须要按照构建函数的方式调用
'prettier/prettier': 'error',
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-unused-vars': 2, //定义了变量却没有在代码中使用
'@typescript-eslint/no-unused-vars': ['off'],
'no-untyped-public-signature': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-explicit-any': ['off'],
'@typescript-eslint/no-non-null-assertion': ['off'],
semi: 0, //缺少分号,行尾必须使用分号
curly: 2, //if 后必须包含 { ,单行 if 除外
'default-case': 2, //switch 语句必须包含 default
'max-depth': [2, 5], //最大块嵌套不能超过5层
'max-params': [2, 8], //函数的形参不能多于8个
'no-array-constructor': 2, //禁止使用Array构造函数,定义数组直接用最快捷的方式[1, 2, 3]
// "no-await-in-loop":2,//禁止将await写在循环里,循环属于同步操作,不该将await异步操作写在内部
'no-caller': 2, //禁止使用arguments.caller和arguments.callee,ES6中废弃了
'no-const-assign': 2, //禁止对const定义重新赋值
'no-delete-var': 2, //禁止对变量使用delete关键字,delete只适用于对象的属性,提醒使用的范围
'no-dupe-args': 2, //函数参数禁止重名
'no-empty-function': 2, //禁止空的function,保证写的每一个function都有用
'no-eval': 2, //禁止使用eval
'no-extra-semi': 2, //禁止额外的分号,有些地方没必要加分号比如if () {};这样就是错误的
// "no-global-assign":2,//禁止对全局变量赋值
'array-bracket-spacing': 0, // 数组方括号前后的空格使用规则
'array-bracket-newline': 0, // 数组方括号前后的换行符使用规则
'accessor-pairs': 2, // 设置了 setter ,必须相应设置 getter ,反之不必须
'array-callback-return': 2, // 数组的 map、filter、sort 等方法,回调函数必须有返回值
'array-element-newline': 0, // 每个数组项是否独占一行
'arrow-body-style': 0, // 箭头函数的书写规则
'arrow-spacing': 0, // 箭头函数的空格使用规则
'arrow-parens': 0, // 箭头函数的圆括号使用规则
'block-scoped-var': 2, // 不能在块外使用块作用域内 var 定义的变量
'block-spacing': 0, // 代码块花括号前后的空格规则
'for-direction': 2, // for 循环不得因方向错误造成死循环
'no-alert': 1, // 禁止 alert,
'no-duplicate-imports': 2, // 禁止重复 import
'no-empty-pattern': 2, // 禁止解构中出现空 {} 或 []
'no-extend-native': [2, { exceptions: ['Array', 'Object'] }], // 禁止扩展原生对象
'no-floating-decimal': 2, // 不允许使用 2. 或 .5 来表示数字,需要用 2、2.0、0.5 的格式
'no-implied-eval': 2, // 禁止在 setTimeout 和 setInterval 中传入字符串,因会触发隐式 eval
// 'no-mixed-spaces-and-tabs': 2, // 禁止混用空格和 tab 来做缩进,必须统一
'no-multi-assign': 2, // 禁止连等赋值
'no-multiple-empty-lines': [
// 连续空行的数量限制
max: 3, // 文件内最多连续 3 个
maxEOF: 1, // 文件末尾最多连续 1 个
maxBOF: 1 // 文件头最多连续 1 个
'no-nested-ternary': 2, // 禁止嵌套的三元表达式
'no-octal': 2, // 禁止使用0开头的数字表示八进制
'no-redeclare': 2, // 禁止重复声明
'no-return-await': 2, // 禁止在 return 中使用 await
'no-return-assign': 2, // 禁止在return中赋值
'no-script-url': 2, // 禁止 location.href = 'javascript:void'
'no-self-assign': 2, // 禁止将自己赋值给自己
'no-shadow-restricted-names': 2, // 禁止使用保留字作为变量名
'no-unreachable': 2, // 禁止出现不可到达的代码,如在 return、throw 之后的代码
'no-useless-call': 2, // 禁止不必要的 call 和 apply
'no-useless-computed-key': 2, // 禁止使用不必要计算的key,如 var a = { ['0']: 0 }
'no-var': 2, // 禁止使用 var,必须用 let 或 const
'no-whitespace-before-property': 2, // 禁止属性前出现空格,如 foo. bar()
'no-with': 2, // 禁止 with
'nonblock-statement-body-position': 2, // 禁止 if 语句在没有花括号的情况下换行
'one-var': [
// 是否允许使用逗号一次声明多个变量
const: 'never' // 所有 const 声明必须独占一行,不允许用逗号定义多个
'symbol-description': 2, // 创建 Symbol 的时候必须传入描述
yoda: 2 // 禁止Yoda格式的判断条件,如 if (true === a),应使用 if (a === true)
ESLint
: 7.20.0
AssertionError [ERR_ASSERTION]: Node must be provided when reporting error if location is not provided
at assertValidNodeInfo (C:\work\ideaworkspace_cloud_html\ade-task-mobile-html\node_modules\eslint\lib\linter\report-translator.js:98:9)
at C:\work\ideaworkspace_cloud_html\ade-task-mobile-html\node_modules\eslint\lib\linter\report-translator.js:315:9
at Object.report (C:\work\ideaworkspace_cloud_html\ade-task-mobile-html\node_modules\eslint\lib\linter\linter.js:920:41)
at Program:exit (C:\work\ideaworkspace_cloud_html\ade-task-mobile-html\node_modules\eslint\lib\rules\no-unused-vars.js:622:33)
at C:\work\ideaworkspace_cloud_html\ade-task-mobile-html\node_modules\eslint\lib\linter\safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (C:\work\ideaworkspace_cloud_html\ade-task-mobile-html\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (C:\work\ideaworkspace_cloud_html\ade-task-mobile-html\node_modules\eslint\lib\linter\node-event-generator.js:256:26)
at NodeEventGenerator.applySelectors (C:\work\ideaworkspace_cloud_html\ade-task-mobile-html\node_modules\eslint\lib\linter\node-event-generator.js:285:22)
at NodeEventGenerator.leaveNode (C:\work\ideaworkspace_cloud_html\ade-task-mobile-html\node_modules\eslint\lib\linter\node-event-generator.js:308:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! ade-task-mobile-html@0.1.0 lint: `eslint --ext .vue,.js,.ts ./src/ --fix ./src`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the ade-task-mobile-html@0.1.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\newrank\AppData\Roaming\npm-cache\_logs\2022-01-06T03_03_08_696Z-debug.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
No one assigned
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly ESLint is working incorrectly repro:needed This issue should include a reproducible example This issue should include a reproducible example
Type
No type
Projects
Status
Complete
Milestone
No milestone
Relationships
None yet
Development
No branches or pull requests
Issue actions