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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ fn no_restricted_globals(global_name: &str, suffix: &str, span: Span) -> OxcDiag
format!("Unexpected use of '{global_name}'. {suffix}")
};

OxcDiagnostic::warn(warn_text).with_label(span)
OxcDiagnostic::warn(warn_text)
.with_help("Use a local variable or function parameter instead of the restricted global.")
.with_label(span)
}

#[derive(Debug, Default, Clone, JsonSchema)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use oxc_syntax::class::ElementKind;
use crate::{context::LintContext, rule::Rule};

fn no_unused_private_class_members_diagnostic(name: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("'{name}' is defined but never used.")).with_label(span)
OxcDiagnostic::warn(format!("'{name}' is defined but never used."))
.with_help("Remove the declaration or use it in the code.")
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,129 +7,151 @@ source: crates/oxc_linter/src/tester.rs
1 │ foo
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'.
╭─[no_restricted_globals.tsx:1:17]
1 │ function fn() { foo; }
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'.
╭─[no_restricted_globals.tsx:1:17]
1 │ function fn() { foo; }
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'event'.
╭─[no_restricted_globals.tsx:1:1]
1 │ event
· ─────
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'.
╭─[no_restricted_globals.tsx:1:1]
1 │ foo
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'.
╭─[no_restricted_globals.tsx:1:1]
1 │ foo()
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'.
╭─[no_restricted_globals.tsx:1:1]
1 │ foo.bar()
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'.
╭─[no_restricted_globals.tsx:1:1]
1 │ foo
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'.
╭─[no_restricted_globals.tsx:1:17]
1 │ function fn() { foo; }
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'.
╭─[no_restricted_globals.tsx:1:17]
1 │ function fn() { foo; }
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'event'.
╭─[no_restricted_globals.tsx:1:1]
1 │ event
· ─────
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'.
╭─[no_restricted_globals.tsx:1:1]
1 │ foo
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'.
╭─[no_restricted_globals.tsx:1:1]
1 │ foo()
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'.
╭─[no_restricted_globals.tsx:1:1]
1 │ foo.bar()
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'. Use bar instead.
╭─[no_restricted_globals.tsx:1:1]
1 │ foo
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'. Use bar instead.
╭─[no_restricted_globals.tsx:1:17]
1 │ function fn() { foo; }
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'. Use bar instead.
╭─[no_restricted_globals.tsx:1:17]
1 │ function fn() { foo; }
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'event'. Use local event parameter.
╭─[no_restricted_globals.tsx:1:1]
1 │ event
· ─────
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'. Use bar instead.
╭─[no_restricted_globals.tsx:1:1]
1 │ foo
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'. Use bar instead.
╭─[no_restricted_globals.tsx:1:1]
1 │ foo()
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'foo'. Use bar instead.
╭─[no_restricted_globals.tsx:1:1]
1 │ foo.bar()
· ───
╰────
help: Use a local variable or function parameter instead of the restricted global.

⚠ eslint(no-restricted-globals): Unexpected use of 'hasOwnProperty'.
╭─[no_restricted_globals.tsx:1:18]
1 │ var foo = obj => hasOwnProperty(obj, 'name');
· ──────────────
╰────
help: Use a local variable or function parameter instead of the restricted global.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ source: crates/oxc_linter/src/tester.rs
· ─────────────
3 │ }
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedMemberInSecondClass' is defined but never used.
╭─[no_unused_private_class_members.tsx:3:17]
Expand All @@ -17,6 +18,7 @@ source: crates/oxc_linter/src/tester.rs
· ──────────────────────────
4 │ }
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedMemberInFirstClass' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -25,6 +27,7 @@ source: crates/oxc_linter/src/tester.rs
· ─────────────────────────
3 │ }
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'firstUnusedMemberInSameClass' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -33,6 +36,7 @@ source: crates/oxc_linter/src/tester.rs
· ─────────────────────────────
3 │ #secondUnusedMemberInSameClass = 5;
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'secondUnusedMemberInSameClass' is defined but never used.
╭─[no_unused_private_class_members.tsx:3:17]
Expand All @@ -41,6 +45,7 @@ source: crates/oxc_linter/src/tester.rs
· ──────────────────────────────
4 │ }
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'usedOnlyInWrite' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -49,6 +54,7 @@ source: crates/oxc_linter/src/tester.rs
· ────────────────
3 │ method() {
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'usedOnlyInWriteStatement' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -57,6 +63,7 @@ source: crates/oxc_linter/src/tester.rs
· ─────────────────────────
3 │ method() {
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'usedOnlyInIncrement' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -65,6 +72,7 @@ source: crates/oxc_linter/src/tester.rs
· ────────────────────
3 │
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedInOuterClass' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -73,6 +81,7 @@ source: crates/oxc_linter/src/tester.rs
· ───────────────────
3 │
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedOnlyInSecondNestedClass' is defined but never used.
╭─[no_unused_private_class_members.tsx:20:25]
Expand All @@ -81,6 +90,7 @@ source: crates/oxc_linter/src/tester.rs
· ──────────────────────────────
21 │ }
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedMethod' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -89,6 +99,7 @@ source: crates/oxc_linter/src/tester.rs
· ─────────────
3 │ }
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedMethod' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -97,6 +108,7 @@ source: crates/oxc_linter/src/tester.rs
· ─────────────
3 │ #usedMethod() {
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedSetter' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:21]
Expand All @@ -105,6 +117,7 @@ source: crates/oxc_linter/src/tester.rs
· ─────────────
3 │ }
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedForInLoop' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -113,6 +126,7 @@ source: crates/oxc_linter/src/tester.rs
· ────────────────
3 │ method() {
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedForOfLoop' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -121,6 +135,7 @@ source: crates/oxc_linter/src/tester.rs
· ────────────────
3 │ method() {
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedInDestructuring' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -129,6 +144,7 @@ source: crates/oxc_linter/src/tester.rs
· ──────────────────────
3 │ method() {
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedInRestPattern' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -137,6 +153,7 @@ source: crates/oxc_linter/src/tester.rs
· ────────────────────
3 │ method() {
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedInAssignmentPattern' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -145,6 +162,7 @@ source: crates/oxc_linter/src/tester.rs
· ──────────────────────────
3 │ method() {
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unusedInAssignmentPattern' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -153,6 +171,7 @@ source: crates/oxc_linter/src/tester.rs
· ──────────────────────────
3 │ method() {
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'usedOnlyInTheSecondInnerClass' is defined but never used.
╭─[no_unused_private_class_members.tsx:2:17]
Expand All @@ -161,45 +180,53 @@ source: crates/oxc_linter/src/tester.rs
· ──────────────────────────────
3 │
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'awaitedMember' is defined but never used.
╭─[no_unused_private_class_members.tsx:1:13]
1 │ class Foo { #awaitedMember; async method() { await this.#awaitedMember; } }
· ──────────────
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'unused' is defined but never used.
╭─[no_unused_private_class_members.tsx:1:13]
1 │ class Foo { #unused; method() { Math.random() > 0.5 ? this.#unused : []; } }
· ───────
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'x' is defined but never used.
╭─[no_unused_private_class_members.tsx:1:13]
1 │ class Foo { #x; #y; method(a, b, c) { a ? (b ? this.#x : c) : this.#y; } }
· ──
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'y' is defined but never used.
╭─[no_unused_private_class_members.tsx:1:17]
1 │ class Foo { #x; #y; method(a, b, c) { a ? (b ? this.#x : c) : this.#y; } }
· ──
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'x' is defined but never used.
╭─[no_unused_private_class_members.tsx:1:13]
1 │ class Foo { #x; method() { a && (b ? this.#x : c); } }
· ──
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'b' is defined but never used.
╭─[no_unused_private_class_members.tsx:1:17]
1 │ class Foo { #a; #b; #c; method() { this.#a ? this.#b : this.#c; } }
· ──
╰────
help: Remove the declaration or use it in the code.

⚠ eslint(no-unused-private-class-members): 'c' is defined but never used.
╭─[no_unused_private_class_members.tsx:1:21]
1 │ class Foo { #a; #b; #c; method() { this.#a ? this.#b : this.#c; } }
· ──
╰────
help: Remove the declaration or use it in the code.
Loading