Skip to content

Commit 996afdb

Browse files
oxc-botgithub-actions[bot]
authored andcommitted
Release 1.12.0
1 parent 68e80c6 commit 996afdb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3794
-51
lines changed

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

Lines changed: 86 additions & 46 deletions
Large diffs are not rendered by default.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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/eslint/prefer_template.rs`;
6+
</script>
7+
8+
# eslint/prefer-template <Badge type="info" text="Style" />
9+
10+
<div class="rule-meta">
11+
<Alert class="fix" type="info">
12+
<span class="emoji">🚧</span> An auto-fix is still under development.
13+
</Alert>
14+
</div>
15+
16+
### What it does
17+
18+
Require template literals instead of string concatenation.
19+
20+
### Why is this bad?
21+
22+
In ES2015 (ES6), we can use template literals instead of string concatenation.
23+
24+
### Examples
25+
26+
Examples of **incorrect** code for this rule:
27+
28+
```js
29+
const str = "Hello, " + name + "!";
30+
const str1 = "Time: " + (12 * 60 * 60 * 1000);
31+
```
32+
33+
Examples of **correct** code for this rule:
34+
35+
```js
36+
const str = "Hello World!";
37+
const str2 = `Time: ${12 * 60 * 60 * 1000}`;
38+
const str4 = "Hello, " + "World!";
39+
```
40+
41+
## How to use
42+
43+
To **enable** this rule in the CLI or using the config file, you can use:
44+
45+
::: code-group
46+
47+
```bash [CLI]
48+
oxlint --deny prefer-template
49+
```
50+
51+
```json [Config (.oxlintrc.json)]
52+
{
53+
"rules": {
54+
"prefer-template": "error"
55+
}
56+
}
57+
```
58+
59+
:::
60+
61+
## References
62+
63+
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>

src/docs/guide/usage/linter/rules/jsx_a11y/tabindex-no-positive.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
99

1010
<div class="rule-meta">
1111
<Alert class="fix" type="info">
12-
<span class="emoji">🚧</span> An auto-fix is still under development.
12+
<span class="emoji">⚠️💡</span> A dangerous suggestion is available for this rule.
1313
</Alert>
1414
</div>
1515

src/docs/guide/usage/linter/rules/react/jsx-curly-brace-presence.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
99

1010
<div class="rule-meta">
1111
<Alert class="fix" type="info">
12-
<span class="emoji">🚧</span> An auto-fix is still under development.
12+
<span class="emoji">🛠️</span> An auto-fix is available for this rule.
1313
</Alert>
1414
</div>
1515

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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/jsx_fragments.rs`;
6+
</script>
7+
8+
# react/jsx-fragments <Badge type="info" text="Style" />
9+
10+
<div class="rule-meta">
11+
<Alert class="fix" type="info">
12+
<span class="emoji">🛠️</span> An auto-fix is available for this rule.
13+
</Alert>
14+
</div>
15+
16+
### What it does
17+
18+
Enforces the shorthand or standard form for React Fragments.
19+
20+
### Why is this bad?
21+
22+
Makes code using fragments more consistent one way or the other.
23+
24+
### Options
25+
26+
`{ "mode": "syntax" | "element" }`
27+
28+
#### `syntax` mode
29+
30+
This is the default mode. It will enforce the shorthand syntax for React fragments, with one exception.
31+
Keys or attributes are not supported by the shorthand syntax, so the rule will not warn on standard-form fragments that use those.
32+
33+
Examples of **incorrect** code for this rule:
34+
35+
```jsx
36+
<React.Fragment>
37+
<Foo />
38+
</React.Fragment>;
39+
```
40+
41+
Examples of **correct** code for this rule:
42+
43+
```jsx
44+
<>
45+
<Foo />
46+
</>;
47+
```
48+
49+
```jsx
50+
<React.Fragment key="key">
51+
<Foo />
52+
</React.Fragment>;
53+
```
54+
55+
#### `element` mode
56+
57+
This mode enforces the standard form for React fragments.
58+
59+
Examples of **incorrect** code for this rule:
60+
61+
```jsx
62+
<>
63+
<Foo />
64+
</>;
65+
```
66+
67+
Examples of **correct** code for this rule:
68+
69+
```jsx
70+
<React.Fragment>
71+
<Foo />
72+
</React.Fragment>;
73+
```
74+
75+
```jsx
76+
<React.Fragment key="key">
77+
<Foo />
78+
</React.Fragment>;
79+
```
80+
81+
## How to use
82+
83+
To **enable** this rule in the CLI or using the config file, you can use:
84+
85+
::: code-group
86+
87+
```bash [CLI]
88+
oxlint --deny react/jsx-fragments --react-plugin
89+
```
90+
91+
```json [Config (.oxlintrc.json)]
92+
{
93+
"plugins": ["react"],
94+
"rules": {
95+
"react/jsx-fragments": "error"
96+
}
97+
}
98+
```
99+
100+
:::
101+
102+
## References
103+
104+
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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/typescript/await_thenable.rs`;
6+
</script>
7+
8+
# typescript/await-thenable <Badge type="info" text="Correctness" />
9+
10+
<div class="rule-meta">
11+
<Alert class="default-on" type="success">
12+
<span class="emoji">✅</span> This rule is turned on by default.
13+
</Alert>
14+
<Alert class="fix" type="info">
15+
<span class="emoji">🚧</span> An auto-fix is still under development.
16+
</Alert>
17+
</div>
18+
19+
### What it does
20+
21+
This rule disallows awaiting a value that is not a Thenable.
22+
23+
### Why is this bad?
24+
25+
While it is valid JavaScript to await a non-Promise-like value (it will resolve immediately), this practice can be confusing for readers who are not aware of this behavior. It can also be a sign of a programmer error, such as forgetting to add parentheses to call a function that returns a Promise.
26+
27+
### Examples
28+
29+
Examples of **incorrect** code for this rule:
30+
31+
```ts
32+
await 12;
33+
await (() => {});
34+
35+
// non-Promise values
36+
await Math.random;
37+
await { then() {} };
38+
39+
// this is not a Promise - it's a function that returns a Promise
40+
declare const getPromise: () => Promise<string>;
41+
await getPromise;
42+
```
43+
44+
Examples of **correct** code for this rule:
45+
46+
```ts
47+
await Promise.resolve("value");
48+
await Promise.reject(new Error());
49+
50+
// Promise-like values
51+
await {
52+
then(onfulfilled, onrejected) {
53+
onfulfilled("value");
54+
},
55+
};
56+
57+
// this is a Promise - produced by calling a function
58+
declare const getPromise: () => Promise<string>;
59+
await getPromise();
60+
```
61+
62+
## How to use
63+
64+
To **enable** this rule in the CLI or using the config file, you can use:
65+
66+
::: code-group
67+
68+
```bash [CLI]
69+
oxlint --deny typescript/await-thenable
70+
```
71+
72+
```json [Config (.oxlintrc.json)]
73+
{
74+
"rules": {
75+
"typescript/await-thenable": "error"
76+
}
77+
}
78+
```
79+
80+
:::
81+
82+
## References
83+
84+
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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/typescript/no_array_delete.rs`;
6+
</script>
7+
8+
# typescript/no-array-delete <Badge type="info" text="Correctness" />
9+
10+
<div class="rule-meta">
11+
<Alert class="default-on" type="success">
12+
<span class="emoji">✅</span> This rule is turned on by default.
13+
</Alert>
14+
<Alert class="fix" type="info">
15+
<span class="emoji">🚧</span> An auto-fix is still under development.
16+
</Alert>
17+
</div>
18+
19+
### What it does
20+
21+
This rule disallows using the delete operator on array values.
22+
23+
### Why is this bad?
24+
25+
When using the delete operator on an array, the element is not actually removed, but instead the array slot is turned into undefined. This is usually not the intended behavior. Instead, you should use methods like Array.prototype.splice() to properly remove elements from an array.
26+
27+
### Examples
28+
29+
Examples of **incorrect** code for this rule:
30+
31+
```ts
32+
declare const arr: number[];
33+
delete arr[0];
34+
```
35+
36+
Examples of **correct** code for this rule:
37+
38+
```ts
39+
declare const arr: number[];
40+
arr.splice(0, 1);
41+
42+
// or with a filter
43+
const filteredArr = arr.filter((_, index) => index !== 0);
44+
45+
// delete on object is allowed
46+
declare const obj: { a?: number };
47+
delete obj.a;
48+
```
49+
50+
## How to use
51+
52+
To **enable** this rule in the CLI or using the config file, you can use:
53+
54+
::: code-group
55+
56+
```bash [CLI]
57+
oxlint --deny typescript/no-array-delete
58+
```
59+
60+
```json [Config (.oxlintrc.json)]
61+
{
62+
"rules": {
63+
"typescript/no-array-delete": "error"
64+
}
65+
}
66+
```
67+
68+
:::
69+
70+
## References
71+
72+
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>

0 commit comments

Comments
 (0)