Skip to content

Commit 58fdb7b

Browse files
committed
AG-29884 Add "Remove this rule" quick fix option
Squashed commit of the following: commit 131160f Author: Elizaveta <e.egorova@adguard.com> Date: Thu Oct 9 01:53:46 2025 +0300 rename quick fix option commit e447aa6 Author: Elizaveta <e.egorova@adguard.com> Date: Thu Oct 9 01:46:48 2025 +0300 AG-29884 Add Remove this rule quick fix option
1 parent d743aa1 commit 58fdb7b

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic
1212
### Added
1313

1414
- Support for multi-root workspaces [#112].
15+
- `Remove this rule` quick fix option [#126].
1516

1617
### Changed
1718

1819
- Updated `husky` dependency to version `9.0.1` [#129].
1920

2021
[#112]: https://github.com/AdguardTeam/VscodeAdblockSyntax/issues/112
2122
[#129]: https://github.com/AdguardTeam/VscodeAdblockSyntax/issues/129
23+
[#126]: https://github.com/AdguardTeam/VscodeAdblockSyntax/issues/126
2224

2325
## 1.1.17 - 2024-05-05
2426

server/src/server.ts

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,16 @@ connection.onCodeAction((params) => {
497497
// and parsing errors have more priority than linting errors: if a rule cannot be parsed,
498498
// it cannot be checked with linter rules.
499499
// So we need to suggest disabling AGLint for the line completely as a quick fix.
500-
const title = 'Disable AGLint for this line';
501-
const action = CodeAction.create(title, CodeActionKind.QuickFix);
500+
const titleDisableRule = 'Disable AGLint for this line';
501+
const actionDisableRule = CodeAction.create(titleDisableRule, CodeActionKind.QuickFix);
502+
503+
// Or delete this rule
504+
const titleRemoveRule = 'Remove this rule';
505+
const actionRemoveRule = CodeAction.create(titleRemoveRule, CodeActionKind.QuickFix);
502506

503507
if (line === 0) {
504508
// If there are no previous lines, just insert the comment before the problematic line.
505-
action.edit = {
509+
actionDisableRule.edit = {
506510
documentChanges: [
507511
TextDocumentEdit.create(
508512
{ uri: textDocument.uri, version: textDocument.version },
@@ -513,7 +517,23 @@ connection.onCodeAction((params) => {
513517
),
514518
],
515519
};
516-
actions.push(action);
520+
521+
actions.push(actionDisableRule);
522+
523+
actionRemoveRule.edit = {
524+
documentChanges: [
525+
TextDocumentEdit.create(
526+
{ uri: textDocument.uri, version: textDocument.version },
527+
[TextEdit.del(Range.create(
528+
Position.create(line, 0),
529+
Position.create(line + 1, 0),
530+
))],
531+
),
532+
],
533+
};
534+
535+
actions.push(actionRemoveRule);
536+
517537
continue;
518538
}
519539

@@ -541,7 +561,8 @@ connection.onCodeAction((params) => {
541561
&& commentNode.params
542562
) {
543563
delete commentNode.params;
544-
action.edit = {
564+
565+
actionDisableRule.edit = {
545566
documentChanges: [
546567
TextDocumentEdit.create(
547568
{ uri: textDocument.uri, version: textDocument.version },
@@ -555,12 +576,13 @@ connection.onCodeAction((params) => {
555576
),
556577
],
557578
};
558-
actions.push(action);
579+
580+
actions.push(actionDisableRule);
559581
continue;
560582
}
561583

562584
// Otherwise just insert the comment before the problematic line
563-
action.edit = {
585+
actionDisableRule.edit = {
564586
documentChanges: [
565587
TextDocumentEdit.create(
566588
{ uri: textDocument.uri, version: textDocument.version },
@@ -572,7 +594,22 @@ connection.onCodeAction((params) => {
572594
],
573595
};
574596

575-
actions.push(action);
597+
actions.push(actionDisableRule);
598+
599+
// Or remove rule
600+
actionRemoveRule.edit = {
601+
documentChanges: [
602+
TextDocumentEdit.create(
603+
{ uri: textDocument.uri, version: textDocument.version },
604+
[TextEdit.del(Range.create(
605+
Position.create(line, 0),
606+
Position.create(line + 1, 0),
607+
))],
608+
),
609+
],
610+
};
611+
612+
actions.push(actionRemoveRule);
576613
continue;
577614
}
578615
}

0 commit comments

Comments
 (0)