Skip to content

Commit 8207455

Browse files
authored
Merge branch 'main' into vitest-compatible-prefer-to-have-been-called-times
2 parents 60276b3 + 5aee74c commit 8207455

23 files changed

+708
-219
lines changed

crates/oxc_linter/src/rules/import/export.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::{ModuleRecord, context::LintContext, rule::Rule};
1010

1111
fn no_named_export(module_name: &str, span: Span) -> OxcDiagnostic {
1212
OxcDiagnostic::warn(format!("No named exports found in module '{module_name}'"))
13+
.with_help("Remove the `export *` re-export, or add named exports to the target module.")
1314
.with_label(span)
1415
}
1516

@@ -93,6 +94,7 @@ impl Rule for Export {
9394

9495
ctx.diagnostic(
9596
OxcDiagnostic::warn(format!("Multiple exports of name '{name}'."))
97+
.with_help("Rename or remove the duplicate export so each name is exported only once.")
9698
.with_labels(labels),
9799
);
98100
}

crates/oxc_linter/src/rules/import/namespace.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ fn computed_reference(span: Span, namespace_name: &str) -> OxcDiagnostic {
3939
OxcDiagnostic::warn(format!(
4040
"Unable to validate computed reference to imported namespace {namespace_name:?}."
4141
))
42+
.with_help("Use a static property access (e.g. `namespace.name`) instead of a computed one.")
4243
.with_label(span)
4344
}
4445

4546
fn assignment(span: Span, namespace_name: &str) -> OxcDiagnostic {
4647
OxcDiagnostic::warn(format!("Assignment to member of namespace {namespace_name:?}.'"))
48+
.with_help("Imported namespace members are read-only. Assign to a local variable instead.")
4749
.with_label(span)
4850
}
4951

crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ use crate::{
1616
};
1717

1818
fn no_anonymous_default_export_diagnostic(span: Span, msg: &'static str) -> OxcDiagnostic {
19-
// See <https://oxc.rs/docs/contribute/linter/adding-rules.html#diagnostics> for details
20-
OxcDiagnostic::warn(msg).with_label(span)
19+
OxcDiagnostic::warn(msg)
20+
.with_note("Named default exports improve grepability and enable consistent auto-imports across the codebase.")
21+
.with_label(span)
2122
}
2223

2324
#[derive(Debug, Clone, JsonSchema, Deserialize)]

crates/oxc_linter/src/rules/import/no_nodejs_modules.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use crate::{
1818

1919
fn no_nodejs_modules_diagnostic(span: Span, module_name: &str) -> OxcDiagnostic {
2020
OxcDiagnostic::warn(format!("Do not import Node.js builtin module `{module_name}`"))
21+
.with_help("Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.")
2122
.with_label(span)
2223
}
2324

crates/oxc_linter/src/snapshots/import_export.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ source: crates/oxc_linter/src/tester.rs
77
1let foo; export { foo }; export * from "./export-all"
88
· ─── ────────────────────────────
99
╰────
10+
help: Rename or remove the duplicate export so each name is exported only once.
1011

1112
eslint-plugin-import(export): Multiple exports of name 'foo'.
1213
╭─[index.ts:1:26]
1314
1let foo; export { foo as "foo" }; export * from "./export-all"
1415
· ───── ────────────────────────────
1516
╰────
17+
help: Rename or remove the duplicate export so each name is exported only once.
1618

1719
× Identifier `Foo` has already been declared
1820
╭─[index.ts:2:29]

crates/oxc_linter/src/snapshots/import_namespace.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@ source: crates/oxc_linter/src/tester.rs
1313
1import * as names from './named-exports'; console.log(names['a']);
1414
· ──────────
1515
╰────
16+
help: Use a static property access (e.g. `namespace.name`) instead of a computed one.
1617

1718
eslint-plugin-import(namespace): Assignment to member of namespace "foo".'
1819
╭─[index.js:1:31]
1920
1import * as foo from './bar'; foo.foo = 'y';
2021
· ───────
2122
╰────
23+
help: Imported namespace members are read-only. Assign to a local variable instead.
2224

2325
eslint-plugin-import(namespace): Assignment to member of namespace "foo".'
2426
╭─[index.js:1:31]
2527
1import * as foo from './bar'; foo.x = 'y';
2628
· ─────
2729
╰────
30+
help: Imported namespace members are read-only. Assign to a local variable instead.
2831

2932
eslint-plugin-import(namespace): "x" not found in imported namespace "./bar".
3033
╭─[index.js:1:35]

crates/oxc_linter/src/snapshots/import_no_anonymous_default_export.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,67 @@ source: crates/oxc_linter/src/tester.rs
77
1export default []
88
· ─────────────────
99
╰────
10+
note: Named default exports improve grepability and enable consistent auto-imports across the codebase.
1011

1112
eslint-plugin-import(no-anonymous-default-export): Assign arrow function to a variable before exporting as module default
1213
╭─[no_anonymous_default_export.tsx:1:1]
1314
1export default () => {}
1415
· ───────────────────────
1516
╰────
17+
note: Named default exports improve grepability and enable consistent auto-imports across the codebase.
1618

1719
eslint-plugin-import(no-anonymous-default-export): Unexpected default export of anonymous class
1820
╭─[no_anonymous_default_export.tsx:1:1]
1921
1export default class {}
2022
· ───────────────────────
2123
╰────
24+
note: Named default exports improve grepability and enable consistent auto-imports across the codebase.
2225

2326
eslint-plugin-import(no-anonymous-default-export): Unexpected default export of anonymous function
2427
╭─[no_anonymous_default_export.tsx:1:1]
2528
1export default function () {}
2629
· ─────────────────────────────
2730
╰────
31+
note: Named default exports improve grepability and enable consistent auto-imports across the codebase.
2832

2933
eslint-plugin-import(no-anonymous-default-export): Assign call result to a variable before exporting as module default
3034
╭─[no_anonymous_default_export.tsx:1:1]
3135
1export default foo(bar)
3236
· ───────────────────────
3337
╰────
38+
note: Named default exports improve grepability and enable consistent auto-imports across the codebase.
3439

3540
eslint-plugin-import(no-anonymous-default-export): Assign literal to a variable before exporting as module default
3641
╭─[no_anonymous_default_export.tsx:1:1]
3742
1export default 123
3843
· ──────────────────
3944
╰────
45+
note: Named default exports improve grepability and enable consistent auto-imports across the codebase.
4046

4147
eslint-plugin-import(no-anonymous-default-export): Assign object to a variable before exporting as module default
4248
╭─[no_anonymous_default_export.tsx:1:1]
4349
1export default {}
4450
· ─────────────────
4551
╰────
52+
note: Named default exports improve grepability and enable consistent auto-imports across the codebase.
4653

4754
eslint-plugin-import(no-anonymous-default-export): Assign instance to a variable before exporting as module default
4855
╭─[no_anonymous_default_export.tsx:1:1]
4956
1export default new Foo()
5057
· ────────────────────────
5158
╰────
59+
note: Named default exports improve grepability and enable consistent auto-imports across the codebase.
5260

5361
eslint-plugin-import(no-anonymous-default-export): Assign literal to a variable before exporting as module default
5462
╭─[no_anonymous_default_export.tsx:1:1]
5563
1export default `foo`
5664
· ────────────────────
5765
╰────
66+
note: Named default exports improve grepability and enable consistent auto-imports across the codebase.
5867

5968
eslint-plugin-import(no-anonymous-default-export): Assign literal to a variable before exporting as module default
6069
╭─[no_anonymous_default_export.tsx:1:1]
6170
1export default /^123/
6271
· ─────────────────────
6372
╰────
73+
note: Named default exports improve grepability and enable consistent auto-imports across the codebase.

crates/oxc_linter/src/snapshots/import_no_nodejs_modules.snap

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,141 +7,165 @@ source: crates/oxc_linter/src/tester.rs
77
1import path from "path"
88
· ───────────────────────
99
╰────
10+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
1011

1112
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `fs`
1213
╭─[no_nodejs_modules.tsx:1:1]
1314
1import fs from "fs"
1415
· ───────────────────
1516
╰────
17+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
1618

1719
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `path`
1820
╭─[no_nodejs_modules.tsx:1:12]
1921
1var path = require("path")
2022
· ───────────────
2123
╰────
24+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
2225

2326
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `fs`
2427
╭─[no_nodejs_modules.tsx:1:10]
2528
1var fs = require("fs")
2629
· ─────────────
2730
╰────
31+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
2832

2933
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `fs`
3034
╭─[no_nodejs_modules.tsx:1:1]
3135
1import(`fs`)
3236
· ────────────
3337
╰────
38+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
3439

3540
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `fs`
3641
╭─[no_nodejs_modules.tsx:1:1]
3742
1import fs from "fs"
3843
· ───────────────────
3944
╰────
45+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
4046

4147
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `crypto`
4248
╭─[no_nodejs_modules.tsx:1:1]
4349
1import crypto from "crypto"
4450
· ───────────────────────────
4551
╰────
52+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
4653

4754
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `util`
4855
╭─[no_nodejs_modules.tsx:1:1]
4956
1import("util")
5057
· ──────────────
5158
╰────
59+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
5260

5361
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `fs`
5462
╭─[no_nodejs_modules.tsx:1:1]
5563
1export * from "fs"
5664
· ──────────────────
5765
╰────
66+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
5867

5968
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `node:path`
6069
╭─[no_nodejs_modules.tsx:1:1]
6170
1import path from "node:path"
6271
· ────────────────────────────
6372
╰────
73+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
6474

6575
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `node:path`
6676
╭─[no_nodejs_modules.tsx:1:12]
6777
1var path = require("node:path")
6878
· ────────────────────
6979
╰────
80+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
7081

7182
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `node:fs`
7283
╭─[no_nodejs_modules.tsx:1:1]
7384
1import fs from "node:fs"
7485
· ────────────────────────
7586
╰────
87+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
7688

7789
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `node:fs`
7890
╭─[no_nodejs_modules.tsx:1:10]
7991
1var fs = require("node:fs")
8092
· ──────────────────
8193
╰────
94+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
8295

8396
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `node:crypto`
8497
╭─[no_nodejs_modules.tsx:1:1]
8598
1import crypto from "node:crypto"
8699
· ────────────────────────────────
87100
╰────
101+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
88102

89103
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `node:fs`
90104
╭─[no_nodejs_modules.tsx:1:1]
91105
1import("node:fs")
92106
· ─────────────────
93107
╰────
108+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
94109

95110
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `node:path`
96111
╭─[no_nodejs_modules.tsx:1:1]
97112
1export { foo } from "node:path"
98113
· ───────────────────────────────
99114
╰────
115+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
100116

101117
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `node:util`
102118
╭─[no_nodejs_modules.tsx:1:1]
103119
1import util = require("node:util")
104120
· ──────────────────────────────────
105121
╰────
122+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
106123

107124
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `node:fs`
108125
╭─[no_nodejs_modules.tsx:1:1]
109126
1import fs from "node:fs"
110127
· ────────────────────────
111128
╰────
129+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
112130

113131
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `node:crypto`
114132
╭─[no_nodejs_modules.tsx:1:1]
115133
1import("node:crypto")
116134
· ─────────────────────
117135
╰────
136+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
118137

119138
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `fs`
120139
╭─[no_nodejs_modules.tsx:1:1]
121140
1import fs = require("fs")
122141
· ─────────────────────────
123142
╰────
143+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
124144

125145
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `path`
126146
╭─[no_nodejs_modules.tsx:1:1]
127147
1import path = require("path")
128148
· ─────────────────────────────
129149
╰────
150+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
130151

131152
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `fs`
132153
╭─[no_nodejs_modules.tsx:1:1]
133154
1export { foo } from "fs"
134155
· ────────────────────────
135156
╰────
157+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
136158

137159
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `crypto`
138160
╭─[no_nodejs_modules.tsx:1:1]
139161
1export { default as foo } from "crypto"
140162
· ───────────────────────────────────────
141163
╰────
164+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.
142165

143166
eslint-plugin-import(no-nodejs-modules): Do not import Node.js builtin module `path`
144167
╭─[no_nodejs_modules.tsx:1:1]
145168
1export * from "path"
146169
· ────────────────────
147170
╰────
171+
help: Use a browser-compatible alternative or add this module to the `allow` list if Node.js usage is intentional.

0 commit comments

Comments
 (0)