Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Feb 24, 2024
1 parent c48e6d1 commit a867592
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions crates/oxc_linter/src/rules/typescript/prefer_ts_expect_error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
use lazy_static::lazy_static;
use regex::Regex;

use oxc_ast::Comment;
use oxc_diagnostics::{
miette::{self, Diagnostic},
Expand Down Expand Up @@ -49,7 +46,7 @@ declare_oxc_lint!(
/// const multiLine: number = 'value';
/// ```
PreferTsExpectError,
correctness
pedantic
);

impl Rule for PreferTsExpectError {
Expand Down Expand Up @@ -103,20 +100,12 @@ fn is_valid_ts_ignore_present(comment: Comment, raw: &str) -> bool {
}

fn test_single_line_comment(line: &str) -> bool {
lazy_static! {
static ref TS_IGNORE_SINGLE_LINE_REGEX: Regex = Regex::new(r"^\s*/?\s*@ts-ignore").unwrap();
}

TS_IGNORE_SINGLE_LINE_REGEX.is_match(line)
line.trim_start_matches(|c: char| c.is_whitespace() || c == '/').starts_with("@ts-ignore")
}

fn test_multi_line_comment(line: &str) -> bool {
lazy_static! {
static ref TS_IGNORE_MULTI_LINE_REGEX: Regex =
Regex::new(r"^\s*(?:\/|\*)*\s*@ts-ignore").unwrap();
}

TS_IGNORE_MULTI_LINE_REGEX.is_match(line)
line.trim_start_matches(|c: char| c.is_whitespace() || c == '/' || c == '*')
.starts_with("@ts-ignore")
}

#[test]
Expand Down

0 comments on commit a867592

Please sign in to comment.