Unexpected no-use-before-define error dependent on preceding code and/or tags
See original GitHub issueTell us about your environment
- ESLint Version: 4.8.0
- eslint-plugin-vue Version: 3.13.0
- Node Version: 7.10.1
Please show your full configuration:
// eslintrc.json
{
"env": {
"browser": true,
"node": true
},
"plugins": [
"vue"
],
"extends": [
"eslint:recommended",
"plugin:vue/recommended"
],
"parserOptions": {
"parser": "babel-eslint",
"sourceType": "module",
"ecmaVersion": 2017
},
"rules": {
"no-use-before-define": "error"
}
}
// babelrc
{
"presets": [
["env", { "targets": { "node": "7.10" } }]
],
"plugins": [
["transform-object-rest-spread", { "useBuiltIns": true }],
"babel-plugin-transform-decorators-legacy",
"transform-runtime"
]
}
What did you do? Please include the actual source code causing the issue.
https://github.com/shvetsovdm/eslint-plugin-vue-no-use-before-issue repo to reproduce the issue
What did you expect to happen?
expect no [Error/no-use-before-define] error
What actually happened? Please include the actual, raw output from ESLint.
$ npx eslint src/*.vue
/Users/shvetsovdm/TempProjects/eslint-plugin-vue-no-use-before-issue/src/issue.vue
18:16 error 'a' was used before it was defined no-use-before-define
18:20 error 'b' was used before it was defined no-use-before-define
/Users/shvetsovdm/TempProjects/eslint-plugin-vue-no-use-before-issue/src/issue2.vue
13:16 error 'a' was used before it was defined no-use-before-define
13:20 error 'b' was used before it was defined no-use-before-define
/Users/shvetsovdm/TempProjects/eslint-plugin-vue-no-use-before-issue/src/issue3.vue
19:16 error 'a' was used before it was defined no-use-before-define
/Users/shvetsovdm/TempProjects/eslint-plugin-vue-no-use-before-issue/src/issue4.vue
18:12 error 'a' was used before it was defined no-use-before-define
18:16 error 'b' was used before it was defined no-use-before-define
✖ 7 problems (7 errors, 0 warnings)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:5 (4 by maintainers)
Top Results From Across the Web
no-use-before-define - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Ask Question - Stack Overflow
Here I am using @typescript-eslint/eslint-plugin as an example. It may not be your direct dependency, use npm ls @typescript-eslint/eslint- ...
Read more >no-use-before-define - TypeScript ESLint
This rule extends the base eslint/no-use-before-define rule. ... Note: you must disable the base rule as it can report incorrect errors
Read more >How to fix Definition for rule typescript-eslint no-use-before ...
I am new to eslint and I cannot figure out how to solve this issue. The beginning of my imports is always underlined...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have published
vue-eslint-parser@2.0.1-beta.2
which fixes the issue. Please re-install this plugin to upgradevue-eslint-parser
. (Or donpm install --no-save vue-eslint-parser@2.0.1-beta.2
).The cause is that
babel-eslint
parser makes AST sharingNode#range
andNode#location
with multiple nodes.Vue-eslint-parser
is checking node objects to avoid fixing location objects twice. But because the location objects are shared with multiple nodes underbabel-eslint
, it had fixed the same location object twice via different node objects. https://github.com/mysticatea/vue-eslint-parser/commit/de0157434c614fe6192b31da1573ebe8792d08b8 fixedvue-eslint-parser
checking the location objects also to avoid fixing location objects twice.@mysticatea @michalsnik this solves the issue, thanks a lot!