Skip to content
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

Handle unused directive problems #1588

Merged
merged 9 commits into from Feb 16, 2023
Merged

Conversation

MariaSolOs
Copy link
Member

Fixes #1585.

@@ -845,7 +845,7 @@ messageQueue.registerRequest(CodeActionRequest.type, async (params) => {
});
}

if (settings.codeAction.disableRuleComment.enable) {
if (settings.codeAction.disableRuleComment.enable && ruleId !== RuleMetaData.unusedDisableDirectiveId) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since unused-directive problems are disabling comments themselves, we cannot disable them.

server/src/eslint.ts Outdated Show resolved Hide resolved
@dbaeumer
Copy link
Member

@MariaSolOs please see my comment above.

@MariaSolOs
Copy link
Member Author

@dbaeumer let me know if you have further comments :)

@@ -167,6 +179,10 @@ export namespace RuleMetaData {
export function hasRuleId(ruleId: string): boolean {
return ruleId2Meta.has(ruleId);
}

export function isUnusedDisableDirectiveProblem(problem: ESLintProblem): boolean {
return problem.ruleId === null && problem.message.startsWith('Unused eslint-disable directive');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last question: I checked myself and I think the answer is no: but does ESLint support localization. If not right now then we are fine but this check might break in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. All I could find was this proposal but it looks stale, and for this specific diagnostic the message is hardcoded here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think we're good for now...

@dbaeumer
Copy link
Member

Thanks for the ping. See my last comment. I always wanted to ask that but I forgot about it.

@dbaeumer dbaeumer merged commit 560df86 into microsoft:main Feb 16, 2023
@shawnmcknight
Copy link

Thanks @MariaSolOs !

@MariaSolOs MariaSolOs deleted the unused-directives branch February 16, 2023 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto Fix on Save does not fix unused disable directives unless there are other lint problems
4 participants