Ignore rule if file is dirty#2175
Open
FunctionDJ wants to merge 2 commits into
Open
Conversation
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2171.
Adds an
unsavedOnlyboolean property toeslint.rules.customizationsentries. Whentrue, the customization only applies while the file has unsaved changes; once saved, the rule reports at its original severity.Motivating use case:
eslint-plugin-prettieris useful in CI but noisy during active editing. With this option you can suppressprettier/prettierwhile typing while still seeing violations in committed/saved code:Implementation notes:
Dirty state is tracked server-side by recording the document version at open/save (
textDocument/didOpen,textDocument/didSave) and comparing against the current version. This avoids a false-dirty state that would arise from usingTextDocuments.onDidChangeContent, which fires for bothdidOpenanddidChangenotifications.Because the pull diagnostics model doesn't automatically re-pull after a save when in-memory content is unchanged,
onDidSavetriggersconnection.languages.diagnostics.refresh()so the updated dirty state is reflected immediately.The
RuleSeveritiescache key is extended with the dirty flag (ruleId:0/1) so clean and dirty results are cached independently and invalidated correctly on settings change.Human written AI Disclaimer: I used Copilot to help me with this implementation and the above PR text body, but I reviewed it, ran the mocha tests, used the Launch Config to test it, and iterated on the feature until it actually worked with Launch Config. I take responsibility for this code. I also looked into if there's a simpler way to determine if a document is dirty, but according to Copilot this would require a client-server roundtrip that's not necessary when the implementation in this PR also works server-side-only.