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: 2 additions & 0 deletions crates/oxc_linter/src/rules/eslint/no_extend_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl Rule for NoExtendNative {
OxcDiagnostic::error(format!(
"{name} prototype is read-only, properties should not be added."
))
.with_help("Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.")
.with_label(prop_assign.span()),
);
}
Expand All @@ -126,6 +127,7 @@ impl Rule for NoExtendNative {
OxcDiagnostic::error(format!(
"{name} prototype is read-only, properties should not be added."
))
.with_help("Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.")
.with_label(define_property_call.span()),
);
}
Expand Down
27 changes: 20 additions & 7 deletions crates/oxc_linter/src/rules/eslint/no_useless_backreference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,26 @@ fn no_useless_backreference_diagnostic(
back_reference: &str,
group: &str,
) -> OxcDiagnostic {
match problem {
Problem::Nested =>OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' from within that group.")).with_label(span),
Problem::Disjunctive => OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' which is in another alternative.")).with_label(span),
Problem::Forward => OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' which appears later in the pattern.")).with_label(span),
Problem::Backward => OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' which appears before in the same lookbehind.")).with_label(span),
Problem::IntoNegativeLookaround => OxcDiagnostic::warn(format!("Backreference '{back_reference}' will be ignored. It references group '{group}' which is in a negative lookaround.")).with_label(span),
}
let diagnostic = match problem {
Problem::Nested => OxcDiagnostic::warn(format!(
"Backreference '{back_reference}' will be ignored. It references group '{group}' from within that group."
)),
Problem::Disjunctive => OxcDiagnostic::warn(format!(
"Backreference '{back_reference}' will be ignored. It references group '{group}' which is in another alternative."
)),
Problem::Forward => OxcDiagnostic::warn(format!(
"Backreference '{back_reference}' will be ignored. It references group '{group}' which appears later in the pattern."
)),
Problem::Backward => OxcDiagnostic::warn(format!(
"Backreference '{back_reference}' will be ignored. It references group '{group}' which appears before in the same lookbehind."
)),
Problem::IntoNegativeLookaround => OxcDiagnostic::warn(format!(
"Backreference '{back_reference}' will be ignored. It references group '{group}' which is in a negative lookaround."
)),
};
diagnostic
.with_help("Consider revising the pattern to remove or relocate the backreference so it points to a group that can be matched at the time of evaluation.")
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
27 changes: 27 additions & 0 deletions crates/oxc_linter/src/snapshots/eslint_no_extend_native.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,159 +7,186 @@ source: crates/oxc_linter/src/tester.rs
1 │ Object.prototype.p = 0
· ──────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): BigInt prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ BigInt.prototype.p = 0
· ──────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): WeakRef prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ WeakRef.prototype.p = 0
· ───────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): FinalizationRegistry prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ FinalizationRegistry.prototype.p = 0
· ────────────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): AggregateError prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ AggregateError.prototype.p = 0
· ──────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Function prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Function.prototype['p'] = 0
· ───────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): String prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ String['prototype'].p = 0
· ─────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Number prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Number['prototype']['p'] = 0
· ────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Object.defineProperty(Array.prototype, 'p', {value: 0})
· ───────────────────────────────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Object['defineProperty'](Array.prototype, 'p', {value: 0})
· ──────────────────────────────────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Object['defineProperty'](Array['prototype'], 'p', {value: 0})
· ─────────────────────────────────────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Object.defineProperties(Array.prototype, {p: {value: 0}})
· ─────────────────────────────────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Object.defineProperties(Array.prototype, {p: {value: 0}, q: {value: 0}})
· ────────────────────────────────────────────────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Number prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Number['prototype']['p'] = 0
· ────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Object.prototype.p = 0; Object.prototype.q = 0
· ──────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:25]
1 │ Object.prototype.p = 0; Object.prototype.q = 0
· ──────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:18]
1 │ function foo() { Object.prototype.p = 0 }
· ──────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ (Object?.prototype).p = 0
· ─────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ (Object?.['prototype'])['p'] = 0
· ────────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Object.defineProperty(Object?.prototype, 'p', { value: 0 })
· ───────────────────────────────────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Object?.defineProperty(Object.prototype, 'p', { value: 0 })
· ───────────────────────────────────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Object?.['defineProperty'](Object?.['prototype'], 'p', {value: 0})
· ──────────────────────────────────────────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Object prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ (Object?.defineProperty)(Object.prototype, 'p', { value: 0 })
· ─────────────────────────────────────────────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Array.prototype.p &&= 0
· ───────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Array.prototype.p ||= 0
· ───────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ Array.prototype.p ??= 0
· ───────────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.

⚠ eslint(no-extend-native): Array prototype is read-only, properties should not be added.
╭─[no_extend_native.tsx:1:1]
1 │ [Array.prototype.p] = [() => {}]
· ───────────────────
╰────
help: Consider using a utility function or a class that extends the built-in object instead of defining properties on the prototype.
Loading
Loading