Skip to content

Commit a6c3c35

Browse files
authored
Release 1.13.0 (#469)
1 parent 9f7a147 commit a6c3c35

File tree

7 files changed

+353
-14
lines changed

7 files changed

+353
-14
lines changed

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

Lines changed: 6 additions & 3 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: 570
5+
- Total number of rules: 573
66
- Rules turned on by default: 103
77

88
**Legend for 'Fixable?' column:**
@@ -308,7 +308,7 @@ Lints which prevent the use of language and library features. Must not be enable
308308
| [prefer-node-protocol](/docs/guide/usage/linter/rules/unicorn/prefer-node-protocol.html) | unicorn | | 🛠️ |
309309
| [prefer-number-properties](/docs/guide/usage/linter/rules/unicorn/prefer-number-properties.html) | unicorn | | ⚠️🛠️️ |
310310

311-
## Suspicious (39):
311+
## Suspicious (40):
312312

313313
code that is most likely wrong or useless.
314314

@@ -332,6 +332,7 @@ code that is most likely wrong or useless.
332332
| [approx-constant](/docs/guide/usage/linter/rules/oxc/approx-constant.html) | oxc | | |
333333
| [misrefactored-assign-op](/docs/guide/usage/linter/rules/oxc/misrefactored-assign-op.html) | oxc | | 🚧 |
334334
| [no-async-endpoint-handlers](/docs/guide/usage/linter/rules/oxc/no-async-endpoint-handlers.html) | oxc | | |
335+
| [always-return](/docs/guide/usage/linter/rules/promise/always-return.html) | promise | | |
335336
| [no-promise-in-callback](/docs/guide/usage/linter/rules/promise/no-promise-in-callback.html) | promise | | |
336337
| [iframe-missing-sandbox](/docs/guide/usage/linter/rules/react/iframe-missing-sandbox.html) | react | | 🚧 |
337338
| [jsx-no-comment-textnodes](/docs/guide/usage/linter/rules/react/jsx-no-comment-textnodes.html) | react | | |
@@ -457,7 +458,7 @@ Lints which are rather strict or have occasional false positives.
457458
| [prefer-type-error](/docs/guide/usage/linter/rules/unicorn/prefer-type-error.html) | unicorn | | 🛠️ |
458459
| [require-number-to-fixed-digits-argument](/docs/guide/usage/linter/rules/unicorn/require-number-to-fixed-digits-argument.html) | unicorn | | 🛠️ |
459460

460-
## Style (153):
461+
## Style (155):
461462

462463
Code that should be written in a more idiomatic way.
463464

@@ -533,6 +534,7 @@ Code that should be written in a more idiomatic way.
533534
| [no-test-prefixes](/docs/guide/usage/linter/rules/jest/no-test-prefixes.html) | jest | | 🛠️ |
534535
| [no-test-return-statement](/docs/guide/usage/linter/rules/jest/no-test-return-statement.html) | jest | | |
535536
| [no-untyped-mock-factory](/docs/guide/usage/linter/rules/jest/no-untyped-mock-factory.html) | jest | | 🛠️ |
537+
| [padding-around-test-blocks](/docs/guide/usage/linter/rules/jest/padding-around-test-blocks.html) | jest | | 🛠️ |
536538
| [prefer-called-with](/docs/guide/usage/linter/rules/jest/prefer-called-with.html) | jest | | |
537539
| [prefer-comparison-matcher](/docs/guide/usage/linter/rules/jest/prefer-comparison-matcher.html) | jest | | 🛠️ |
538540
| [prefer-each](/docs/guide/usage/linter/rules/jest/prefer-each.html) | jest | | |
@@ -562,6 +564,7 @@ Code that should be written in a more idiomatic way.
562564
| [jsx-boolean-value](/docs/guide/usage/linter/rules/react/jsx-boolean-value.html) | react | | 🛠️ |
563565
| [jsx-curly-brace-presence](/docs/guide/usage/linter/rules/react/jsx-curly-brace-presence.html) | react | | 🛠️ |
564566
| [jsx-fragments](/docs/guide/usage/linter/rules/react/jsx-fragments.html) | react | | 🛠️ |
567+
| [jsx-handler-names](/docs/guide/usage/linter/rules/react/jsx-handler-names.html) | react | | |
565568
| [no-set-state](/docs/guide/usage/linter/rules/react/no-set-state.html) | react | | |
566569
| [prefer-es6-class](/docs/guide/usage/linter/rules/react/prefer-es6-class.html) | react | | |
567570
| [self-closing-comp](/docs/guide/usage/linter/rules/react/self-closing-comp.html) | react | | 🛠️ |

src/docs/guide/usage/linter/rules/eslint/func-style.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,22 @@ You can specify which you prefer in the configuration.
2424

2525
### Examples
2626

27+
```js
2728
// function declaration
2829
function doSomething() {
29-
// ...
30+
// ...
3031
}
3132

3233
// arrow function expression assigned to a variable
3334
const doSomethingElse = () => {
34-
// ...
35+
// ...
3536
};
3637

3738
// function expression assigned to a variable
3839
const doSomethingAgain = function() {
39-
// ...
40+
// ...
4041
};
42+
```
4143

4244
Examples of incorrect code for this rule with the default "expression" option:
4345

@@ -82,23 +84,25 @@ export var bar = () => {};
8284

8385
Examples of correct code for this rule with the default "expression" option:
8486

85-
````js
87+
```js
8688
/*eslint func-style: ["error", "expression"]*/
8789
var foo = function() {
88-
// ...
90+
// ...
8991
};
92+
```
9093

9194
Examples of correct code for this rule with the "declaration" option:
95+
9296
```js
9397
/*eslint func-style: ["error", "declaration"]*/
9498
function foo() {
95-
// ...
99+
// ...
96100
}
97-
// Methods (functions assigned to objects) are not checked by this rule
101+
// Methods (functions assigned to objects) are not checked by this rule
98102
SomeObject.foo = function() {
99-
// ...
103+
// ...
100104
};
101-
````
105+
```
102106

103107
Examples of additional correct code for this rule with the "declaration", { "allowArrowFunctions": true } options:
104108

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Example of **incorrect** code for this option:
6060
console.log("foo");
6161
```
6262

63-
Example of **incorrect** code for this option:
63+
Example of **correct** code for this option:
6464

6565
```javascript
6666
console.info("foo");
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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/jest/padding_around_test_blocks.rs`;
6+
</script>
7+
8+
# jest/padding-around-test-blocks <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+
This rule enforces a line of padding before and after 1 or more test/it statements
19+
20+
### Examples
21+
22+
Examples of **incorrect** code for this rule:
23+
24+
```js
25+
const thing = 123;
26+
test("foo", () => {});
27+
test("bar", () => {});
28+
```
29+
30+
```js
31+
const thing = 123;
32+
it("foo", () => {});
33+
it("bar", () => {});
34+
```
35+
36+
Examples of **correct** code for this rule:
37+
38+
```js
39+
const thing = 123;
40+
41+
test("foo", () => {});
42+
43+
test("bar", () => {});
44+
```
45+
46+
```js
47+
const thing = 123;
48+
49+
it("foo", () => {});
50+
51+
it("bar", () => {});
52+
```
53+
54+
## How to use
55+
56+
To **enable** this rule in the CLI or using the config file, you can use:
57+
58+
::: code-group
59+
60+
```bash [CLI]
61+
oxlint --deny jest/padding-around-test-blocks --jest-plugin
62+
```
63+
64+
```json [Config (.oxlintrc.json)]
65+
{
66+
"plugins": ["jest"],
67+
"rules": {
68+
"jest/padding-around-test-blocks": "error"
69+
}
70+
}
71+
```
72+
73+
:::
74+
75+
## References
76+
77+
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
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/promise/always_return.rs`;
6+
</script>
7+
8+
# promise/always-return <Badge type="info" text="Suspicious" />
9+
10+
<div class="rule-meta">
11+
</div>
12+
13+
### What it does
14+
15+
Require returning inside each `then()` to create readable and reusable Promise chains.
16+
We also allow someone to throw inside a `then()` which is essentially the same as return `Promise.reject()`.
17+
18+
### Why is this bad?
19+
20+
Broken Promise Chain.
21+
Inside the first `then()` callback, a function is called but not returned.
22+
This causes the next `then()` in the chain to execute immediately without waiting for the called function to complete.
23+
24+
### Examples
25+
26+
Examples of **incorrect** code for this rule:
27+
28+
```javascript
29+
myPromise.then(function(val) {});
30+
myPromise.then(() => {
31+
doSomething();
32+
});
33+
myPromise.then((b) => {
34+
if (b) {
35+
return "yes";
36+
} else {
37+
forgotToReturn();
38+
}
39+
});
40+
```
41+
42+
Examples of **correct** code for this rule:
43+
44+
```javascript
45+
myPromise.then((val) => val * 2);
46+
myPromise.then(function(val) {
47+
return val * 2;
48+
});
49+
myPromise.then(doSomething); // could be either
50+
myPromise.then((b) => {
51+
if (b) {
52+
return "yes";
53+
} else {
54+
return "no";
55+
}
56+
});
57+
```
58+
59+
### Options
60+
61+
#### `ignoreLastCallback`
62+
63+
You can pass an `{ ignoreLastCallback: true }` as an option to this rule so that
64+
the last `then()` callback in a promise chain does not warn if it does not have
65+
a `return`. Default is `false`.
66+
67+
```javascript
68+
// OK
69+
promise.then((x) => {
70+
console.log(x);
71+
});
72+
// OK
73+
void promise.then((x) => {
74+
console.log(x);
75+
});
76+
// OK
77+
await promise.then((x) => {
78+
console.log(x);
79+
});
80+
81+
promise
82+
// NG
83+
.then((x) => {
84+
console.log(x);
85+
})
86+
// OK
87+
.then((x) => {
88+
console.log(x);
89+
});
90+
91+
// NG
92+
const v = promise.then((x) => {
93+
console.log(x);
94+
});
95+
// NG
96+
const v = await promise.then((x) => {
97+
console.log(x);
98+
});
99+
function foo() {
100+
// NG
101+
return promise.then((x) => {
102+
console.log(x);
103+
});
104+
}
105+
```
106+
107+
#### `ignoreAssignmentVariable`
108+
109+
You can pass an `{ ignoreAssignmentVariable: [] }` as an option to this rule
110+
with a list of variable names so that the last `then()` callback in a promise
111+
chain does not warn if it does an assignment to a global variable. Default is
112+
`["globalThis"]`.
113+
114+
```javascript
115+
/* eslint promise/always-return: ["error", { ignoreAssignmentVariable: ["globalThis"] }] */
116+
117+
// OK
118+
promise.then((x) => {
119+
globalThis = x;
120+
});
121+
122+
promise.then((x) => {
123+
globalThis.x = x;
124+
});
125+
126+
// OK
127+
promise.then((x) => {
128+
globalThis.x.y = x;
129+
});
130+
131+
// NG
132+
promise.then((x) => {
133+
anyOtherVariable = x;
134+
});
135+
136+
// NG
137+
promise.then((x) => {
138+
anyOtherVariable.x = x;
139+
});
140+
141+
// NG
142+
promise.then((x) => {
143+
x();
144+
});
145+
```
146+
147+
## How to use
148+
149+
To **enable** this rule in the CLI or using the config file, you can use:
150+
151+
::: code-group
152+
153+
```bash [CLI]
154+
oxlint --deny promise/always-return --promise-plugin
155+
```
156+
157+
```json [Config (.oxlintrc.json)]
158+
{
159+
"plugins": ["promise"],
160+
"rules": {
161+
"promise/always-return": "error"
162+
}
163+
}
164+
```
165+
166+
:::
167+
168+
## References
169+
170+
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>

0 commit comments

Comments
 (0)