Skip to content

Commit

Permalink
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions crates/oxc_linter/src/disable_directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ impl<'a, 'b> DisableDirectivesBuilder<'a, 'b> {
if let Some(text) = text.strip_prefix("eslint-disable") {
// `eslint-disable`
if text.trim().is_empty() {
self.disable_all_start = Some(span.end);
if self.disable_all_start.is_none() {
self.disable_all_start = Some(span.end);
}
continue;
}

Expand Down Expand Up @@ -116,7 +118,7 @@ impl<'a, 'b> DisableDirectivesBuilder<'a, 'b> {

// `eslint-disable rule-name1, rule-name2`
Self::get_rule_names(text, |rule_name| {
self.disable_start_map.insert(rule_name, span.end);
self.disable_start_map.entry(rule_name).or_insert(span.end);
});

continue;
Expand Down Expand Up @@ -237,6 +239,20 @@ fn test() {
*/
debugger;
",
// To disable all rules twice:
"
/* eslint-disable */
debugger;
/* eslint-disable */
debugger;
",
// To disable a rule twice:
"
/* eslint-disable no-debugger */
debugger;
/* eslint-disable no-debugger */
debugger;
",
// Comment descriptions
"
// eslint-disable-next-line no-debugger -- Here's a description about why this configuration is necessary.
Expand Down

0 comments on commit 49b6be6

Please sign in to comment.