`autofix` option for lint messages?
See original GitHub issueIn addition to the existing column
, line
, ruleId
, message
, severity
, etc. properties defined for a lint message, would you be open to supporting an autofix
property (and updating many of the built-in rules to use it)?
For example, a JavaScript linter that tells you that you are missing a semicolon should provide the user the option to just add the semicolon in the right spot. This is something that could easily have an autofix
option.
I was thinking the value of autofix
could be either a string diff to apply to the file to fix the lint or a JavaScript function that would take the source as input and return the “fixed” source as output (or it could return the diff as a string). The latter is not JSON-serializable, but might be useful for lazily generating the value from autofix
. In an IDE that runs the linter repeatedly, it’s important that the linter runs quickly, so I want to avoid a situation where autofix
support slows things down.
Arcanist Lint supports the autofix
property, though it appears to be a severity
level and the patches are a separate property. There isn’t a code example there, but it sounds like there can be an array of patches, which seems sensible.
See also https://github.com/AtomLinter/Linter/issues/418
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
Issue Analytics
- State:
- Created 9 years ago
- Comments:29 (12 by maintainers)
Top GitHub Comments
It always seems a little lame when a computer can tell me that I’m missing a semicolon yet can’t add it for me.
I am going to close this issue as this is one of the items on this issue: https://github.com/eslint/eslint/issues/2203 For further discussions lets talk on the above mentioned issue.