question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AssertionError [ERR_ASSERTION]: Node must be provided when reporting error if location is not provided

See original GitHub issue

Environment

Node version: 14.17.5 npm version: 6.14.14 Local ESLint version: 7.20.0 Global ESLint version: none Operating System: windows10

What parser are you using?

vue-eslint-parser

What did you do?

Configuration
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': [
			2,
			{
				// 连续空行的数量限制
				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': [
			2,
			{
				// 是否允许使用逗号一次声明多个变量
				const: 'never' // 所有 const 声明必须独占一行,不允许用逗号定义多个
			}
		],
		'symbol-description': 2, // 创建 Symbol 的时候必须传入描述
		yoda: 2 // 禁止Yoda格式的判断条件,如 if (true === a),应使用 if (a === true)
	}
}


image

What did you expect to happen?

I want to be tested normally

What actually happened?

When I perform npm run lint:

Oops! Something went wrong! :(

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

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aladdin-addcommented, Jan 6, 2022

ops, I missed the no-unused-vars.js in stack. there is a replacement rule @typescript-eslint/no-unused-vars if you are using ts.

{
   rules: {
    "no-unused-vars": 0,
    "@typescript-eslint/no-unused-vars": 2,
   }
}
0reactions
thomas-void0commented, Jan 6, 2022

ops, I missed the no-unused-vars.js in stack. there is a replacement rule @typescript-eslint/no-unused-vars if you are using ts.

{
   rules: {
    "no-unused-vars": 0,
    "@typescript-eslint/no-unused-vars": 2,
   }
}

thx, After I use eslint7.x and modify this configuration rule for you. The problem was solved successfully.

This project has been running normally before, and there is no conflict between the two rules. Perhaps I am installing a dependency and the dependent version is not locked. ^_^

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node must be provided when reporting error if location is not ...
... I'm just typing code Stack trace AssertionError [ERR_ASSERTION]: Node must be provided when reporting error if location is not provided.
Read more >
Node must be provided when reporting error if location is not ...
eslintrc file has no-unused-vars and @typescript-eslint/no-unused-vars , which I've read is an issue, but I've messed around with enabling and disabling each of ......
Read more >
assertionerror err_assertion node must be provided ... - 掘金
assertionerror err_assertion node must be provided when reporting error if location is not provided 技术、学习、经验文章掘金开发者社区搜索结果。
Read more >
Eslint fails on file position change with configured eslint-plugin ...
The error is sticky and doesn't disappear on window focus change/save etc while console script npm run lint has no problems with it ......
Read more >
eslint/eslint - Gitter
executeOnText() API and I implemented some caching logic on my side to store the CLIEngine object. I noticed that if I change my...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found