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.

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:

capture

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:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dbaeumercommented, Dec 16, 2016

Thanks. I tested it with the latest ESLint 1.2.2 plugin and it looks good to me:

cast

0reactions
BenoitZugmeyercommented, Jan 15, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

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