Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/default_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Rule for DefaultCase {
.comments_range(last_case.span.start..switch.span.end)
.last()
.is_some_and(|comment| {
let raw = comment.content_span().source_text(ctx.source_text()).trim();
let raw = ctx.source_range(comment.content_span()).trim();
match &self.comment_pattern {
Some(comment_pattern) => comment_pattern.is_match(raw),
None => raw.eq_ignore_ascii_case("no default"),
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_fallthrough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ impl NoFallthrough {
let is_fallthrough_comment_in_range = |range: Range<u32>| {
let comment = semantic
.comments_range(range)
.map(|comment| comment.content_span().source_text(semantic.source_text()))
.map(|comment| ctx.source_range(comment.content_span()))
.last()
.map(str::trim);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ impl Rule for NoCommentedOutTests {
Regex::new(r#"(?mu)^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\("#).unwrap();
}
let comments = ctx.semantic().comments();
let source_text = ctx.source_text();
let commented_tests = comments.iter().filter_map(|comment| {
let text = comment.content_span().source_text(source_text);
let text = ctx.source_range(comment.content_span());
if RE.is_match(text) {
Some(comment.content_span())
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Rule for BanTslintComment {
let comments = ctx.semantic().comments();
let source_text_len = ctx.semantic().source_text().len();
for comment in comments {
let raw = comment.content_span().source_text(ctx.source_text());
let raw = ctx.source_range(comment.content_span());
if is_tslint_comment_directive(raw) {
let comment_span = get_full_comment(source_text_len, comment.span);
ctx.diagnostic_with_fix(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Rule for PreferTsExpectError {
let comments = ctx.semantic().comments();

for comment in comments {
let raw = comment.content_span().source_text(ctx.source_text());
let raw = ctx.source_range(comment.content_span());

if !is_valid_ts_ignore_present(*comment, raw) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl Rule for TripleSlashReference {
let mut refs_for_import = FxHashMap::default();

for comment in ctx.semantic().comments_range(0..comments_range_end) {
let raw = comment.content_span().source_text(ctx.source_text());
let raw = ctx.source_range(comment.content_span());
if let Some((group1, group2)) = get_attr_key_and_value(raw) {
if (group1 == "types" && self.types == TypesOption::Never)
|| (group1 == "path" && self.path == PathOption::Never)
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/unicorn/no_empty_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn has_triple_slash_directive(ctx: &LintContext<'_>) -> bool {
if !comment.is_line() {
continue;
}
let text = comment.content_span().source_text(ctx.source_text());
let text = ctx.source_range(comment.content_span());
if text.starts_with("///") {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/utils/tree_shaking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub fn has_pure_notation(span: Span, ctx: &LintContext) -> bool {
let Some(comment) = ctx.semantic().comments_range(..span.start).next_back() else {
return false;
};
let raw = comment.content_span().source_text(ctx.source_text());
let raw = ctx.source_range(comment.content_span());
raw.contains("@__PURE__") || raw.contains("#__PURE__")
}

Expand Down