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
1 change: 1 addition & 0 deletions apps/oxlint/fixtures/tsgolint/.oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"typescript/no-redundant-type-constituents": "error",
"typescript/no-unnecessary-boolean-literal-compare": "error",
"typescript/no-unnecessary-condition": "error",
"typescript/no-unnecessary-qualifier": "error",
"typescript/no-unnecessary-template-expression": "error",
"typescript/no-unnecessary-type-arguments": "error",
"typescript/no-unnecessary-type-assertion": "error",
Expand Down
6 changes: 6 additions & 0 deletions apps/oxlint/fixtures/tsgolint/no-unnecessary-qualifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Examples of incorrect code for no-unnecessary-qualifier rule

namespace A {
export type B = number;
const x: A.B = 3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ arguments: --type-aware --silent
working directory: fixtures/tsgolint
----------

Found 0 warnings and 62 errors.
Finished in <variable>ms on 51 files with 50 rules using 1 threads.
Found 0 warnings and 63 errors.
Finished in <variable>ms on 52 files with 51 rules using 1 threads.
----------
CLI result: LintFoundErrors
----------
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ working directory: fixtures/tsgolint
help: Remove the debugger statement

Found 2 warnings and 2 errors.
Finished in <variable>ms on 51 files with 1 rules using 1 threads.
Finished in <variable>ms on 52 files with 1 rules using 1 threads.
----------
CLI result: LintFoundErrors
----------
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ working directory: fixtures/tsgolint
help: Remove the debugger statement

Found 0 warnings and 1 error.
Finished in <variable>ms on 1 file with 50 rules using 1 threads.
Finished in <variable>ms on 1 file with 51 rules using 1 threads.
----------
CLI result: LintFoundErrors
----------
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ working directory: fixtures/tsgolint
: ^^
`----

x typescript-eslint(no-unnecessary-qualifier): Qualifier is unnecessary since 'B' is in scope.
,-[no-unnecessary-qualifier.ts:5:12]
4 | export type B = number;
5 | const x: A.B = 3;
: ^
6 | }
`----

x typescript-eslint(no-unnecessary-template-expression): Template literal expression is unnecessary and can be simplified.
,-[no-unnecessary-template-expression.ts:2:18]
1 | const text = 'hello';
Expand Down Expand Up @@ -486,8 +494,8 @@ working directory: fixtures/tsgolint
`----
help: If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead.

Found 0 warnings and 62 errors.
Finished in <variable>ms on 51 files with 50 rules using 1 threads.
Found 0 warnings and 63 errors.
Finished in <variable>ms on 52 files with 51 rules using 1 threads.
----------
CLI result: LintFoundErrors
----------
5 changes: 5 additions & 0 deletions crates/oxc_linter/src/generated/rule_runner_impls.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 36 additions & 1 deletion crates/oxc_linter/src/generated/rules_enum.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/oxc_linter/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ pub(crate) mod typescript {
pub mod no_unnecessary_boolean_literal_compare;
pub mod no_unnecessary_condition;
pub mod no_unnecessary_parameter_property_assignment;
pub mod no_unnecessary_qualifier;
pub mod no_unnecessary_template_expression;
pub mod no_unnecessary_type_arguments;
pub mod no_unnecessary_type_assertion;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use oxc_macros::declare_oxc_lint;

use crate::rule::Rule;

#[derive(Debug, Default, Clone)]
pub struct NoUnnecessaryQualifier;

declare_oxc_lint!(
/// ### What it does
///
/// Disallow namespace qualifiers when the referenced name is already in scope.
///
/// ### Why is this bad?
///
/// Redundant qualifiers add noise and make type references harder to read.
///
/// ### Examples
///
/// Examples of **incorrect** code for this rule:
/// ```ts
/// namespace A {
/// export type B = number;
/// const value: A.B = 1;
/// }
/// ```
///
/// Examples of **correct** code for this rule:
/// ```ts
/// namespace A {
/// export type B = number;
/// const value: B = 1;
/// }
/// ```
NoUnnecessaryQualifier(tsgolint),
typescript,
nursery,
);

impl Rule for NoUnnecessaryQualifier {}
Loading