@@ -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