-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix range bug with no-extra-boolean-cast #11324
Copy link
Copy link
Closed
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyESLint is working incorrectlyruleRelates to ESLint's core rulesRelates to ESLint's core rules
Metadata
Metadata
Assignees
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyESLint is working incorrectlyruleRelates to ESLint's core rulesRelates to ESLint's core rules
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
{ "extends": ["eslint:recommended"], "rules": { "no-extra-boolean-cast": "error" } }What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
What did you expect to happen?
The information about the location of the fix appears to be off. Running
--fixapplies the fix correctly but the response from the JSON output is off (which means that other external tools cannot apply the fix).I would expect the location information to be something like:
{ "line": 2, "column": 11, "nodeType": "UnaryExpression", "messageId": "unexpectedNegation", "endLine": 2, "endColumn": 16, "fix": { "range": [24, 29], "text": "bar" } }Looking at AST Explorer seems to have the right location information.
https://astexplorer.net/#/gist/b5517bff697af4446176699497517e36/8f1a35f7594886e63d855960a1649120071963d4
What actually happened? Please include the actual, raw output from ESLint.
[ { "filePath": "/Volumes/Freelancer/scratch/eslint/test.js", "messages": [ { "ruleId": "no-unused-vars", "severity": 2, "message": "'foo' is assigned a value but never used.", "line": 2, "column": 5, "nodeType": "Identifier", "endLine": 2, "endColumn": 8 }, { "ruleId": "no-extra-boolean-cast", "severity": 2, "message": "Redundant double negation.", "line": 2, "column": 12, "nodeType": "UnaryExpression", "messageId": "unexpectedNegation", "endLine": 2, "endColumn": 16, "fix": { "range": [23, 28], "text": "bar" } } ], "errorCount": 2, "warningCount": 0, "fixableErrorCount": 1, "fixableWarningCount": 0, "source": "var bar = 1;\nvar foo = !!bar ? 'true' : 'false';\n" } ]Are you willing to submit a pull request to fix this bug? With help potentially. I'm unfamiliar with how rules output the position information.