Provided ESLint Auto fix information have incorrect positions
See original GitHub issue.eslintrc.json
{
"plugins": [
"html"
],
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"rules": {
"no-const-assign": "warn",
"no-this-before-super": "warn",
"no-undef": "warn",
"no-unreachable": "warn",
"no-unused-vars": "warn",
"constructor-super": "warn",
"valid-typeof": "warn",
"no-extra-semi": "warn"
}
}
test.html
<!DOCTYPE html>
<html lang="en">
<script>
function foo() {
}
foo();;
</script>
</html>
This correct reports the following error:
'Unnecessary semicolon. (no-extra-semi)'
However the auto fix information attached to the reported problem when using ESLints node API has the following information: { range: [75, 76] text: “” }
which will delete the second ‘o’ of foo();;
The content of the html file passed to ESLint as a string looks like:
I guess that the html plugin does some offset magic and might not apply it to the fixes attached to a problem.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Working with Rules - ESLint - Pluggable JavaScript Linter
If it guesses wrong, the resulting code will be automatically reported and fixed by the quotes rule. Note: Making fixes as small as...
Read more >ESLint in VSCode not fixing on save - Stack Overflow
When I save I would like my ESLint to run automatically and fix all the warnings for me automatically. This is my settings.json...
Read more >Auto-fix and format your JavaScript with ESLint - IBM Developer
Get the quick tips and tricks you need to use ESLint to autofix and format your JavaScript.
Read more >How To Lint and Format Code with ESLint in Visual Studio Code
You can use a linter to do this. Linters check your code for syntax errors and highlight errors to make sure you can...
Read more >JavaScript Programming with Visual Studio Code
"fixAll.eslint" - Auto Fix only for ESLint. "addMissingImports" - Adds all missing imports on save. See Node.js/JavaScript for more information. Code ...
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
Thanks. I tested it with the latest ESLint 1.2.2 plugin and it looks good to me:
I don’t think I’m affected by this, I don’t use parse5 and I have tests on
\r\n
support.Closing this issue since it’s resolved in v2.