Skip to content

Commit 8ff5a07

Browse files
authored
Release 1.4.0 (#411)
1 parent 05c59ac commit 8ff5a07

File tree

11 files changed

+375
-20
lines changed

11 files changed

+375
-20
lines changed

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

Lines changed: 9 additions & 6 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: 521
5+
- Total number of rules: 524
66
- Rules turned on by default: 123
77

88
**Legend for 'Fixable?' column:**
@@ -213,7 +213,7 @@ Code that can be written to run faster.
213213
| [prefer-array-find](/docs/guide/usage/linter/rules/unicorn/prefer-array-find.html) | unicorn | | 🚧 |
214214
| [prefer-set-has](/docs/guide/usage/linter/rules/unicorn/prefer-set-has.html) | unicorn | | ⚠️🛠️️ |
215215

216-
## Restriction (67):
216+
## Restriction (66):
217217

218218
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.
219219

@@ -281,13 +281,12 @@ Lints which prevent the use of language and library features. Must not be enable
281281
| [no-document-cookie](/docs/guide/usage/linter/rules/unicorn/no-document-cookie.html) | unicorn | | |
282282
| [no-length-as-slice-end](/docs/guide/usage/linter/rules/unicorn/no-length-as-slice-end.html) | unicorn | | 🛠️ |
283283
| [no-magic-array-flat-depth](/docs/guide/usage/linter/rules/unicorn/no-magic-array-flat-depth.html) | unicorn | | |
284-
| [no-nested-ternary](/docs/guide/usage/linter/rules/unicorn/no-nested-ternary.html) | unicorn | | 🛠️ |
285284
| [no-process-exit](/docs/guide/usage/linter/rules/unicorn/no-process-exit.html) | unicorn | | 🚧 |
286285
| [prefer-modern-math-apis](/docs/guide/usage/linter/rules/unicorn/prefer-modern-math-apis.html) | unicorn | | 🚧 |
287286
| [prefer-node-protocol](/docs/guide/usage/linter/rules/unicorn/prefer-node-protocol.html) | unicorn | | 🛠️ |
288287
| [prefer-number-properties](/docs/guide/usage/linter/rules/unicorn/prefer-number-properties.html) | unicorn | | ⚠️🛠️️ |
289288

290-
## Suspicious (34):
289+
## Suspicious (33):
291290

292291
code that is most likely wrong or useless.
293292

@@ -302,7 +301,6 @@ code that is most likely wrong or useless.
302301
| [no-useless-concat](/docs/guide/usage/linter/rules/eslint/no-useless-concat.html) | eslint | | |
303302
| [no-useless-constructor](/docs/guide/usage/linter/rules/eslint/no-useless-constructor.html) | eslint | | 🛠️ |
304303
| [no-absolute-path](/docs/guide/usage/linter/rules/import/no-absolute-path.html) | import | | 🚧 |
305-
| [no-duplicates](/docs/guide/usage/linter/rules/import/no-duplicates.html) | import | | |
306304
| [no-empty-named-blocks](/docs/guide/usage/linter/rules/import/no-empty-named-blocks.html) | import | | 🛠️ |
307305
| [no-named-as-default](/docs/guide/usage/linter/rules/import/no-named-as-default.html) | import | | |
308306
| [no-named-as-default-member](/docs/guide/usage/linter/rules/import/no-named-as-default-member.html) | import | | |
@@ -417,19 +415,21 @@ Lints which are rather strict or have occasional false positives.
417415
| [prefer-type-error](/docs/guide/usage/linter/rules/unicorn/prefer-type-error.html) | unicorn | | 🛠️ |
418416
| [require-number-to-fixed-digits-argument](/docs/guide/usage/linter/rules/unicorn/require-number-to-fixed-digits-argument.html) | unicorn | | 🛠️ |
419417

420-
## Style (144):
418+
## Style (149):
421419

422420
Code that should be written in a more idiomatic way.
423421

424422
| Rule name | Source | Default | Fixable? |
425423
| ------------------------------------------------------------------------------------------------------------------------ | ---------- | ------- | -------- |
424+
| [arrow-body-style](/docs/guide/usage/linter/rules/eslint/arrow-body-style.html) | eslint | | 🚧 |
426425
| [curly](/docs/guide/usage/linter/rules/eslint/curly.html) | eslint | | 🛠️ |
427426
| [default-case-last](/docs/guide/usage/linter/rules/eslint/default-case-last.html) | eslint | | |
428427
| [default-param-last](/docs/guide/usage/linter/rules/eslint/default-param-last.html) | eslint | | |
429428
| [func-names](/docs/guide/usage/linter/rules/eslint/func-names.html) | eslint | | 🛠️💡 |
430429
| [func-style](/docs/guide/usage/linter/rules/eslint/func-style.html) | eslint | | 🚧 |
431430
| [grouped-accessor-pairs](/docs/guide/usage/linter/rules/eslint/grouped-accessor-pairs.html) | eslint | | 🚧 |
432431
| [guard-for-in](/docs/guide/usage/linter/rules/eslint/guard-for-in.html) | eslint | | |
432+
| [id-length](/docs/guide/usage/linter/rules/eslint/id-length.html) | eslint | | |
433433
| [init-declarations](/docs/guide/usage/linter/rules/eslint/init-declarations.html) | eslint | | |
434434
| [max-params](/docs/guide/usage/linter/rules/eslint/max-params.html) | eslint | | |
435435
| [new-cap](/docs/guide/usage/linter/rules/eslint/new-cap.html) | eslint | | 🚧 |
@@ -465,9 +465,11 @@ Code that should be written in a more idiomatic way.
465465
| [first](/docs/guide/usage/linter/rules/import/first.html) | import | | 🚧 |
466466
| [group-exports](/docs/guide/usage/linter/rules/import/group-exports.html) | import | | |
467467
| [no-anonymous-default-export](/docs/guide/usage/linter/rules/import/no-anonymous-default-export.html) | import | | |
468+
| [no-duplicates](/docs/guide/usage/linter/rules/import/no-duplicates.html) | import | | |
468469
| [no-mutable-exports](/docs/guide/usage/linter/rules/import/no-mutable-exports.html) | import | | |
469470
| [no-named-default](/docs/guide/usage/linter/rules/import/no-named-default.html) | import | | |
470471
| [no-namespace](/docs/guide/usage/linter/rules/import/no-namespace.html) | import | | 🚧 |
472+
| [prefer-default-export](/docs/guide/usage/linter/rules/import/prefer-default-export.html) | import | | |
471473
| [consistent-test-it](/docs/guide/usage/linter/rules/jest/consistent-test-it.html) | jest | | 🛠️ |
472474
| [max-expects](/docs/guide/usage/linter/rules/jest/max-expects.html) | jest | | |
473475
| [max-nested-describe](/docs/guide/usage/linter/rules/jest/max-nested-describe.html) | jest | | |
@@ -539,6 +541,7 @@ Code that should be written in a more idiomatic way.
539541
| [no-array-method-this-argument](/docs/guide/usage/linter/rules/unicorn/no-array-method-this-argument.html) | unicorn | | 🚧 |
540542
| [no-await-expression-member](/docs/guide/usage/linter/rules/unicorn/no-await-expression-member.html) | unicorn | | ⚠️🛠️️ |
541543
| [no-console-spaces](/docs/guide/usage/linter/rules/unicorn/no-console-spaces.html) | unicorn | | 🛠️ |
544+
| [no-nested-ternary](/docs/guide/usage/linter/rules/unicorn/no-nested-ternary.html) | unicorn | | 🛠️ |
542545
| [no-null](/docs/guide/usage/linter/rules/unicorn/no-null.html) | unicorn | | 🛠️ |
543546
| [no-unreadable-array-destructuring](/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.html) | unicorn | | |
544547
| [no-zero-fractions](/docs/guide/usage/linter/rules/unicorn/no-zero-fractions.html) | unicorn | | 🛠️ |
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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/arrow_body_style.rs`;
6+
</script>
7+
8+
# eslint/arrow-body-style <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+
This rule can enforce or disallow the use of braces around arrow function body.
19+
20+
### Why is this bad?
21+
22+
Arrow functions have two syntactic forms for their function bodies.
23+
They may be defined with a block body (denoted by curly braces) () => { ... }
24+
or with a single expression () => ..., whose value is implicitly returned.
25+
26+
### Examples
27+
28+
Examples of **incorrect** code for this rule with the `always` option:
29+
30+
```js
31+
const foo = () => 0;
32+
```
33+
34+
Examples of **correct** code for this rule with the `always` option:
35+
36+
```js
37+
const foo = () => {
38+
return 0;
39+
};
40+
```
41+
42+
Examples of **incorrect** code for this rule with the `as-needed` option:
43+
44+
```js
45+
const foo = () => {
46+
return 0;
47+
};
48+
```
49+
50+
Examples of **correct** code for this rule with the `as-needed` option:
51+
52+
```js
53+
const foo1 = () => 0;
54+
55+
const foo2 = (retv, name) => {
56+
retv[name] = true;
57+
return retv;
58+
};
59+
```
60+
61+
Examples of **incorrect** code for this rule with the { "requireReturnForObjectLiteral": true } option:
62+
63+
```js
64+
/* arrow-body-style: ["error", "as-needed", { "requireReturnForObjectLiteral": true }]*/
65+
const foo = () => ({});
66+
const bar = () => ({ bar: 0 });
67+
```
68+
69+
Examples of **correct** code for this rule with the { "requireReturnForObjectLiteral": true } option:
70+
71+
```js
72+
/* arrow-body-style: ["error", "as-needed", { "requireReturnForObjectLiteral": true }]*/
73+
const foo = () => {};
74+
const bar = () => {
75+
return { bar: 0 };
76+
};
77+
```
78+
79+
Examples of **incorrect** code for this rule with the `never` option:
80+
81+
```js
82+
const foo = () => {
83+
return 0;
84+
};
85+
```
86+
87+
Examples of **correct** code for this rule with the `never` option:
88+
89+
```js
90+
const foo = () => 0;
91+
const bar = () => ({ foo: 0 });
92+
```
93+
94+
### Options
95+
96+
The rule takes one or two options. The first is a string, which can be:
97+
98+
- `always` enforces braces around the function body
99+
- `never` enforces no braces where they can be omitted (default)
100+
- `as-needed` enforces no braces around the function body (constrains arrow functions to the role of returning an expression)
101+
102+
The second one is an object for more fine-grained configuration
103+
when the first option is "as-needed". Currently,
104+
the only available option is requireReturnForObjectLiteral, a boolean property.
105+
It’s false by default. If set to true, it requires braces and an explicit return for object literals.
106+
107+
```json
108+
{
109+
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }]
110+
}
111+
```
112+
113+
## How to use
114+
115+
To **enable** this rule in the CLI or using the config file, you can use:
116+
117+
::: code-group
118+
119+
```bash [CLI]
120+
oxlint --deny arrow-body-style
121+
```
122+
123+
```json [Config (.oxlintrc.json)]
124+
{
125+
"rules": {
126+
"arrow-body-style": "error"
127+
}
128+
}
129+
```
130+
131+
:::
132+
133+
## References
134+
135+
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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/id_length.rs`;
6+
</script>
7+
8+
# eslint/id-length <Badge type="info" text="Style" />
9+
10+
<div class="rule-meta">
11+
</div>
12+
13+
### What it does
14+
15+
This rule enforces a minimum and/or maximum identifier length convention by counting the
16+
graphemes for a given identifier.
17+
18+
### Why is this bad?
19+
20+
Very short identifier names like e, x, _t or very long ones like
21+
hashGeneratorResultOutputContainerObject can make code harder to read and potentially less
22+
maintainable. To prevent this, one may enforce a minimum and/or maximum identifier length.
23+
24+
### Examples
25+
26+
Examples of **incorrect** code for this rule:
27+
28+
```js
29+
/*eslint id-length: "error"*/
30+
// default is minimum 2-chars ({ "min": 2 })
31+
32+
const x = 5;
33+
obj.e = document.body;
34+
const foo = function(e) {};
35+
try {
36+
dangerousStuff();
37+
} catch (e) {
38+
// ignore as many do
39+
}
40+
const myObj = { a: 1 };
41+
((a) => {
42+
a * a;
43+
});
44+
class y {}
45+
class Foo {
46+
x() {}
47+
}
48+
class Bar {
49+
#x() {}
50+
}
51+
class Baz {
52+
x = 1;
53+
}
54+
class Qux {
55+
#x = 1;
56+
}
57+
function bar(...x) {}
58+
function baz([x]) {}
59+
const [z] = arr;
60+
const { prop: [i] } = {};
61+
function qux({ x }) {}
62+
const { j } = {};
63+
const { prop: a } = {};
64+
({ prop: obj.x } = {});
65+
```
66+
67+
Examples of **correct** code for this rule:
68+
69+
```js
70+
/*eslint id-length: "error"*/
71+
// default is minimum 2-chars ({ "min": 2 })
72+
73+
const num = 5;
74+
function _f() {
75+
return 42;
76+
}
77+
function _func() {
78+
return 42;
79+
}
80+
obj.el = document.body;
81+
const foo = function(evt) {/* do stuff */};
82+
try {
83+
dangerousStuff();
84+
} catch (error) {
85+
// ignore as many do
86+
}
87+
const myObj = { apple: 1 };
88+
((num) => {
89+
num * num;
90+
});
91+
function bar(num = 0) {}
92+
class MyClass {}
93+
class Foo {
94+
method() {}
95+
}
96+
class Bar {
97+
#method() {}
98+
}
99+
class Baz {
100+
field = 1;
101+
}
102+
class Qux {
103+
#field = 1;
104+
}
105+
function baz(...args) {}
106+
function qux([longName]) {}
107+
const { prop } = {};
108+
const { prop: [name] } = {};
109+
const [longName] = arr;
110+
function foobar({ prop }) {}
111+
function foobaz({ a: prop }) {}
112+
const { a: property } = {};
113+
({ prop: obj.longName } = {});
114+
const data = { "x": 1 }; // excused because of quotes
115+
data["y"] = 3; // excused because of calculated property access
116+
```
117+
118+
## How to use
119+
120+
To **enable** this rule in the CLI or using the config file, you can use:
121+
122+
::: code-group
123+
124+
```bash [CLI]
125+
oxlint --deny id-length
126+
```
127+
128+
```json [Config (.oxlintrc.json)]
129+
{
130+
"rules": {
131+
"id-length": "error"
132+
}
133+
}
134+
```
135+
136+
:::
137+
138+
## References
139+
140+
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>

src/docs/guide/usage/linter/rules/import/no-duplicates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { data } from '../version.data.js';
55
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/import/no_duplicates.rs`;
66
</script>
77

8-
# import/no-duplicates <Badge type="info" text="Suspicious" />
8+
# import/no-duplicates <Badge type="info" text="Style" />
99

1010
<div class="rule-meta">
1111
</div>

0 commit comments

Comments
 (0)