-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to Fix References #306
Comments
Welcome @samjcombs! 👋
Not currently, see #82
I'd be cautious outright removing the reference or definitions as a fix.
Given that there are multiple scenarios, I'm not sure
I'm not sure the value of adding a comment would have here. Given your interest in fixes. |
@samjcombs thoughts on the above? Is thing something you'd be interested in working on? |
const message = new VFileMessage('Undefined reference [foo]', nodeOrPosition, 'remark-lint:no-undefined-references')
message.expected = ['foo'] For removal, suggest an empty string. const message = new VFileMessage('Duplicate reference [foo]', nodeOrPosition, 'remark-lint:no-duplicate-definitions')
message.expected = [''] This This doesn’t provide an option to fix all issues with a single command though. |
Closing as is discussed in GH-82. Adding |
Duplicate of #82 |
This comment has been minimized.
This comment has been minimized.
Hi! Thanks for taking the time to contribute! Because we treat issues as our backlog, we close duplicates to focus our work and not have to touch the same chunk of code for the same reason multiple times. This is also why we may mark something as duplicate that isn’t an exact duplicate but is closely related. Thanks, |
Initial checklist
Problem
It would be great if these three rules:
no-undefined-references
no-duplicate-definitions
no-unused-definitions
had a
--fix
or--output
option to do the following:no-undefined-references
- remove the brackets around the undefined referenceno-duplicate-definitions
- add a comment to each duplicate so the user can decide which one to keepno-unused-definitions
- remove the definition entirelyI have been looking into how to achieve this but before I dive in completely I was wondering if theres a simple option to turn a rule into a write rule instead of just a warning reporter.
Great work on this repo, very impressive stuff here!
Solution
For
no-undefined-references
Given this input:
Desired output:
For
no-duplicate-definitions
Given this input:
Desired output:
For
no-unused-definitions
Given this input:
Desired output:
Alternatives
I tried piping the output of the cli with these three rules enabled to a script that would parse it and determine where to do file edits, but it got too complicated as lots of work has to be done to make sure that when it starts editing the file, future edits take into account what was already removed and translate positions of everything accordingly. All in all, not a good solution.
Another option I've been toying with is to use these rules to output the AST tree instead of the files, and then parse through that AST and perform the modifications, but I'm not sure how I'd find the violating AST nodes, unless these rules actually add
isAllowed
to the ast nodes themselves.Open to other solutions here and it may be easier to do this on a rule by rule basis.
But an abstract solution to provide a
fix
andfix options
for each rule would be great, so users could say, for nodes that violate this rule, fix it in this way.Thanks much!
The text was updated successfully, but these errors were encountered: