Skip to content

Commit a7ea3bc

Browse files
authored
Release 1.23.0 (#551)
Co-authored-by: Boshen <[email protected]>
1 parent 6aed318 commit a7ea3bc

File tree

8 files changed

+299
-20
lines changed

8 files changed

+299
-20
lines changed

src/docs/guide/usage/linter/generated-cli.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ Arguments:
9595
- **`--no-ignore`** &mdash;
9696
Disables excluding of files from .eslintignore files, **`--ignore-path`** flags and **`--ignore-pattern`** flags
9797

98+
> [!NOTE]
99+
> `.gitignore` is only respected inside a Git repository.
100+
98101
## Handle Warnings
99102

100103
- **`--quiet`** &mdash;

src/docs/guide/usage/linter/generated-rules.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The progress of all rule implementations is tracked [here](https://github.com/oxc-project/oxc/issues/481).
44

5-
- Total number of rules: 605
5+
- Total number of rules: 607
66
- Rules turned on by default: 103
77

88
**Legend for 'Fixable?' column:**
@@ -235,7 +235,7 @@ Code that can be written to run faster.
235235
| [prefer-array-flat-map](/docs/guide/usage/linter/rules/unicorn/prefer-array-flat-map.html) | unicorn | | 🛠️ |
236236
| [prefer-set-has](/docs/guide/usage/linter/rules/unicorn/prefer-set-has.html) | unicorn | | ⚠️🛠️️ |
237237

238-
## Restriction (75):
238+
## Restriction (77):
239239

240240
Lints which prevent the use of language and library features. Must not be enabled as a whole, should be considered on a case-by-case basis before enabling.
241241

@@ -273,6 +273,7 @@ Lints which prevent the use of language and library features. Must not be enable
273273
| [empty-tags](/docs/guide/usage/linter/rules/jsdoc/empty-tags.html) | jsdoc | | |
274274
| [anchor-ambiguous-text](/docs/guide/usage/linter/rules/jsx_a11y/anchor-ambiguous-text.html) | jsx_a11y | | |
275275
| [no-new-require](/docs/guide/usage/linter/rules/node/no-new-require.html) | node | | |
276+
| [no-process-env](/docs/guide/usage/linter/rules/node/no-process-env.html) | node | | |
276277
| [bad-bitwise-operator](/docs/guide/usage/linter/rules/oxc/bad-bitwise-operator.html) | oxc | | |
277278
| [no-async-await](/docs/guide/usage/linter/rules/oxc/no-async-await.html) | oxc | | |
278279
| [no-barrel-file](/docs/guide/usage/linter/rules/oxc/no-barrel-file.html) | oxc | | |
@@ -286,6 +287,7 @@ Lints which prevent the use of language and library features. Must not be enable
286287
| [jsx-filename-extension](/docs/guide/usage/linter/rules/react/jsx-filename-extension.html) | react | | 🚧 |
287288
| [no-danger](/docs/guide/usage/linter/rules/react/no-danger.html) | react | | |
288289
| [no-unknown-property](/docs/guide/usage/linter/rules/react/no-unknown-property.html) | react | | 🚧 |
290+
| [only-export-components](/docs/guide/usage/linter/rules/react/only-export-components.html) | react | | |
289291
| [explicit-function-return-type](/docs/guide/usage/linter/rules/typescript/explicit-function-return-type.html) | typescript | | |
290292
| [explicit-module-boundary-types](/docs/guide/usage/linter/rules/typescript/explicit-module-boundary-types.html) | typescript | | |
291293
| [no-dynamic-delete](/docs/guide/usage/linter/rules/typescript/no-dynamic-delete.html) | typescript | | |

src/docs/guide/usage/linter/rules/eslint/no-duplicate-imports.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@ export * as something from "module";
8181
export * from "module";
8282
```
8383

84+
#### allowSeparateTypeImports
85+
86+
`{ type: boolean, default: false }`
87+
88+
When `true`, imports with only type specifiers (inline types or type imports) are
89+
considered separate from imports with value specifiers, so they can be imported from the
90+
same module on separate import statements.
91+
92+
Examples of **correct** code when `allowSeparateTypeImports` is set to `true`:
93+
94+
```js
95+
import { foo } from "module";
96+
import type { Bar } from "module";
97+
```
98+
99+
```js
100+
import { type Foo } from "module";
101+
import type { Bar } from "module";
102+
```
103+
84104
## How to use
85105

86106
To **enable** this rule in the CLI or using the config file, you can use:

src/docs/guide/usage/linter/rules/nextjs/no-typos.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
1515

1616
### What it does
1717

18-
Prevent common typos in Next.js's data fetching functions
18+
Detects common typos in Next.js data fetching function names.
1919

2020
### Why is this bad?
2121

22+
Next.js will not call incorrectly named data fetching functions, causing pages to render without expected data.
23+
2224
### Examples
2325

2426
Examples of **incorrect** code for this rule:
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->
2+
3+
<script setup>
4+
import { data } from '../version.data.js';
5+
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/node/no_process_env.rs`;
6+
</script>
7+
8+
# node/no-process-env <Badge type="info" text="Restriction" />
9+
10+
<div class="rule-meta">
11+
</div>
12+
13+
### What it does
14+
15+
Disallows use of `process.env`.
16+
17+
### Why is this bad?
18+
19+
Directly reading `process.env` can lead to implicit runtime configuration,
20+
make code harder to test, and bypass configuration validation.
21+
22+
### Examples
23+
24+
Examples of **incorrect** code for this rule:
25+
26+
```js
27+
if (process.env.NODE_ENV === "development") {
28+
// ...
29+
}
30+
```
31+
32+
Examples of **correct** code for this rule:
33+
34+
```js
35+
import config from "./config";
36+
37+
if (config.env === "development") {
38+
// ...
39+
}
40+
```
41+
42+
## Configuration
43+
44+
### allowedVariables
45+
46+
type: `string[]`
47+
48+
## How to use
49+
50+
To **enable** this rule in the CLI or using the config file, you can use:
51+
52+
::: code-group
53+
54+
```bash [CLI]
55+
oxlint --deny node/no-process-env --node-plugin
56+
```
57+
58+
```json [Config (.oxlintrc.json)]
59+
{
60+
"plugins": ["node"],
61+
"rules": {
62+
"node/no-process-env": "error"
63+
}
64+
}
65+
```
66+
67+
:::
68+
69+
## References
70+
71+
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>

src/docs/guide/usage/linter/rules/oxc/branches-sharing-code.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,37 @@ and easier to maintain.
2424
Examples of **incorrect** code for this rule:
2525

2626
```javascript
27-
let foo = if (condition) {
28-
console.log("Hello");
29-
13
27+
if (condition) {
28+
console.log("Hello");
29+
return 13;
3030
} else {
31-
console.log("Hello");
32-
42
33-
};
31+
console.log("Hello");
32+
return 42;
33+
}
3434

3535
if (condition) {
36-
doSomething();
37-
cleanup();
36+
doSomething();
37+
cleanup();
3838
} else {
39-
doSomethingElse();
40-
cleanup();
39+
doSomethingElse();
40+
cleanup();
4141
}
4242
```
4343

4444
Examples of **correct** code for this rule:
4545

4646
```javascript
4747
console.log("Hello");
48-
let foo = if (condition) {
49-
13
48+
if (condition) {
49+
return 13;
5050
} else {
51-
42
52-
};
51+
return 42;
52+
}
5353

5454
if (condition) {
55-
doSomething();
55+
doSomething();
5656
} else {
57-
doSomethingElse();
57+
doSomethingElse();
5858
}
5959
cleanup();
6060
```
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->
2+
3+
<script setup>
4+
import { data } from '../version.data.js';
5+
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/react/only_export_components.rs`;
6+
</script>
7+
8+
# react/only-export-components <Badge type="info" text="Restriction" />
9+
10+
<div class="rule-meta">
11+
</div>
12+
13+
### What it does
14+
15+
Ensures that modules only **export React components (and related HMR-safe items)** so
16+
that Fast Refresh (a.k.a. hot reloading) can safely preserve component state.
17+
Concretely, it validates the shape of your module’s exports and common entrypoints
18+
(e.g. `createRoot(...).render(<App />)`) to match what integrations like
19+
`react-refresh` expect. The rule name is `react-refresh/only-export-components`.
20+
21+
### Why is this bad?
22+
23+
Fast Refresh can only reliably retain state if a module exports components and
24+
avoids patterns that confuse the refresh runtime. Problematic patterns (like
25+
`export *`, anonymous default functions, exporting arrays of JSX, or mixing
26+
non-component exports in unsupported ways) can cause:
27+
28+
- Components to remount and lose state on edit
29+
- Missed updates (no refresh) or overly broad reloads
30+
- Fragile HMR behavior that differs between bundlers
31+
32+
By enforcing predictable exports, edits stay fast and stateful during development.
33+
34+
### Examples
35+
36+
Examples of **incorrect** code for this rule:
37+
38+
```jsx
39+
// 1) Mixing util exports with components in unsupported ways
40+
export const foo = () => {}; // util, not a component
41+
export const Bar = () => <></>; // component
42+
```
43+
44+
```jsx
45+
// 2) Anonymous default export (name is required)
46+
export default function() {}
47+
```
48+
49+
```jsx
50+
// 3) Re-exporting everything hides what’s exported
51+
export * from "./foo";
52+
```
53+
54+
```jsx
55+
// 4) Exporting JSX collections makes components non-discoverable
56+
const Tab = () => null;
57+
export const tabs = [<Tab />, <Tab />];
58+
```
59+
60+
```jsx
61+
// 5) Bootstrapping a root within the same module that defines components
62+
const App = () => null;
63+
createRoot(document.getElementById("root")).render(<App />);
64+
```
65+
66+
Examples of **correct** code for this rule:
67+
68+
```jsx
69+
// Named or default component exports are fine
70+
export default function Foo() {
71+
return null;
72+
}
73+
```
74+
75+
```jsx
76+
// Utilities may coexist if allowed by options or naming conventions
77+
const foo = () => {};
78+
export const Bar = () => null;
79+
```
80+
81+
```jsx
82+
// Entrypoint files may render an imported component
83+
import { App } from "./App";
84+
createRoot(document.getElementById("root")).render(<App />);
85+
```
86+
87+
### Options (or not)
88+
89+
#### allowExportNames
90+
91+
`{ type: string[], default: [] }`
92+
93+
Treat specific named exports as HMR-safe (useful for frameworks that hot-replace
94+
certain exports). For example, in Remix:
95+
96+
```json
97+
{
98+
"react/only-export-components": [
99+
"error",
100+
{ "allowExportNames": ["meta", "links", "headers", "loader", "action"] }
101+
]
102+
}
103+
```
104+
105+
#### allowConstantExport
106+
107+
`{ type: boolean, default: false }`
108+
109+
Allow exporting primitive constants (string/number/boolean/template literal)
110+
alongside component exports without triggering a violation. Recommended when your
111+
bundler’s Fast Refresh integration supports this (enabled by the plugin’s `vite`
112+
preset).
113+
114+
```json
115+
{
116+
"react/only-export-components": [
117+
"error",
118+
{ "allowConstantExport": true }
119+
]
120+
}
121+
```
122+
123+
```jsx
124+
// Allowed when allowConstantExport: true
125+
export const VERSION = "3";
126+
export const Foo = () => null;
127+
```
128+
129+
#### customHOCs
130+
131+
`{ type: string[], default: [] }`
132+
133+
If you export components wrapped in custom higher-order components, list their
134+
identifiers here to avoid false positives:
135+
136+
```json
137+
{
138+
"react/only-export-components": [
139+
"error",
140+
{ "customHOCs": ["observer", "withAuth"] }
141+
]
142+
}
143+
```
144+
145+
#### checkJS
146+
147+
`{ type: boolean, default: false }`
148+
149+
Check `.js` files that contain JSX (in addition to `.tsx`/`.jsx`). To reduce
150+
false positives, only files that import React are checked when this is enabled.
151+
152+
```json
153+
{
154+
"react/only-export-components": ["error", { "checkJS": true }]
155+
}
156+
```
157+
158+
## How to use
159+
160+
To **enable** this rule in the CLI or using the config file, you can use:
161+
162+
::: code-group
163+
164+
```bash [CLI]
165+
oxlint --deny react/only-export-components --react-plugin
166+
```
167+
168+
```json [Config (.oxlintrc.json)]
169+
{
170+
"plugins": ["react"],
171+
"rules": {
172+
"react/only-export-components": "error"
173+
}
174+
}
175+
```
176+
177+
:::
178+
179+
## References
180+
181+
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
22
load() {
3-
return "5c29bb65e7d20e682ff27e534332b3489a344954";
3+
return "6440cde67502bdc72020a1b8992b5445b7b490f3";
44
},
55
};

0 commit comments

Comments
 (0)