Skip to content

Release 1.4.0 #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/docs/guide/usage/linter/generated-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

- Total number of rules: 521
- Total number of rules: 524
- Rules turned on by default: 123

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

## Restriction (67):
## Restriction (66):

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.

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

## Suspicious (34):
## Suspicious (33):

code that is most likely wrong or useless.

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

## Style (144):
## Style (149):

Code that should be written in a more idiomatic way.

| Rule name | Source | Default | Fixable? |
| ------------------------------------------------------------------------------------------------------------------------ | ---------- | ------- | -------- |
| [arrow-body-style](/docs/guide/usage/linter/rules/eslint/arrow-body-style.html) | eslint | | 🚧 |
| [curly](/docs/guide/usage/linter/rules/eslint/curly.html) | eslint | | 🛠️ |
| [default-case-last](/docs/guide/usage/linter/rules/eslint/default-case-last.html) | eslint | | |
| [default-param-last](/docs/guide/usage/linter/rules/eslint/default-param-last.html) | eslint | | |
| [func-names](/docs/guide/usage/linter/rules/eslint/func-names.html) | eslint | | 🛠️💡 |
| [func-style](/docs/guide/usage/linter/rules/eslint/func-style.html) | eslint | | 🚧 |
| [grouped-accessor-pairs](/docs/guide/usage/linter/rules/eslint/grouped-accessor-pairs.html) | eslint | | 🚧 |
| [guard-for-in](/docs/guide/usage/linter/rules/eslint/guard-for-in.html) | eslint | | |
| [id-length](/docs/guide/usage/linter/rules/eslint/id-length.html) | eslint | | |
| [init-declarations](/docs/guide/usage/linter/rules/eslint/init-declarations.html) | eslint | | |
| [max-params](/docs/guide/usage/linter/rules/eslint/max-params.html) | eslint | | |
| [new-cap](/docs/guide/usage/linter/rules/eslint/new-cap.html) | eslint | | 🚧 |
Expand Down Expand Up @@ -465,9 +465,11 @@ Code that should be written in a more idiomatic way.
| [first](/docs/guide/usage/linter/rules/import/first.html) | import | | 🚧 |
| [group-exports](/docs/guide/usage/linter/rules/import/group-exports.html) | import | | |
| [no-anonymous-default-export](/docs/guide/usage/linter/rules/import/no-anonymous-default-export.html) | import | | |
| [no-duplicates](/docs/guide/usage/linter/rules/import/no-duplicates.html) | import | | |
| [no-mutable-exports](/docs/guide/usage/linter/rules/import/no-mutable-exports.html) | import | | |
| [no-named-default](/docs/guide/usage/linter/rules/import/no-named-default.html) | import | | |
| [no-namespace](/docs/guide/usage/linter/rules/import/no-namespace.html) | import | | 🚧 |
| [prefer-default-export](/docs/guide/usage/linter/rules/import/prefer-default-export.html) | import | | |
| [consistent-test-it](/docs/guide/usage/linter/rules/jest/consistent-test-it.html) | jest | | 🛠️ |
| [max-expects](/docs/guide/usage/linter/rules/jest/max-expects.html) | jest | | |
| [max-nested-describe](/docs/guide/usage/linter/rules/jest/max-nested-describe.html) | jest | | |
Expand Down Expand Up @@ -539,6 +541,7 @@ Code that should be written in a more idiomatic way.
| [no-array-method-this-argument](/docs/guide/usage/linter/rules/unicorn/no-array-method-this-argument.html) | unicorn | | 🚧 |
| [no-await-expression-member](/docs/guide/usage/linter/rules/unicorn/no-await-expression-member.html) | unicorn | | ⚠️🛠️️ |
| [no-console-spaces](/docs/guide/usage/linter/rules/unicorn/no-console-spaces.html) | unicorn | | 🛠️ |
| [no-nested-ternary](/docs/guide/usage/linter/rules/unicorn/no-nested-ternary.html) | unicorn | | 🛠️ |
| [no-null](/docs/guide/usage/linter/rules/unicorn/no-null.html) | unicorn | | 🛠️ |
| [no-unreadable-array-destructuring](/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.html) | unicorn | | |
| [no-zero-fractions](/docs/guide/usage/linter/rules/unicorn/no-zero-fractions.html) | unicorn | | 🛠️ |
Expand Down
135 changes: 135 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/arrow-body-style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

<script setup>
import { data } from '../version.data.js';
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/eslint/arrow_body_style.rs`;
</script>

# eslint/arrow-body-style <Badge type="info" text="Style" />

<div class="rule-meta">
<Alert class="fix" type="info">
<span class="emoji">🚧</span> An auto-fix is still under development.
</Alert>
</div>

### What it does

This rule can enforce or disallow the use of braces around arrow function body.

### Why is this bad?

Arrow functions have two syntactic forms for their function bodies.
They may be defined with a block body (denoted by curly braces) () => { ... }
or with a single expression () => ..., whose value is implicitly returned.

### Examples

Examples of **incorrect** code for this rule with the `always` option:

```js
const foo = () => 0;
```

Examples of **correct** code for this rule with the `always` option:

```js
const foo = () => {
return 0;
};
```

Examples of **incorrect** code for this rule with the `as-needed` option:

```js
const foo = () => {
return 0;
};
```

Examples of **correct** code for this rule with the `as-needed` option:

```js
const foo1 = () => 0;

const foo2 = (retv, name) => {
retv[name] = true;
return retv;
};
```

Examples of **incorrect** code for this rule with the { "requireReturnForObjectLiteral": true } option:

```js
/* arrow-body-style: ["error", "as-needed", { "requireReturnForObjectLiteral": true }]*/
const foo = () => ({});
const bar = () => ({ bar: 0 });
```

Examples of **correct** code for this rule with the { "requireReturnForObjectLiteral": true } option:

```js
/* arrow-body-style: ["error", "as-needed", { "requireReturnForObjectLiteral": true }]*/
const foo = () => {};
const bar = () => {
return { bar: 0 };
};
```

Examples of **incorrect** code for this rule with the `never` option:

```js
const foo = () => {
return 0;
};
```

Examples of **correct** code for this rule with the `never` option:

```js
const foo = () => 0;
const bar = () => ({ foo: 0 });
```

### Options

The rule takes one or two options. The first is a string, which can be:

- `always` enforces braces around the function body
- `never` enforces no braces where they can be omitted (default)
- `as-needed` enforces no braces around the function body (constrains arrow functions to the role of returning an expression)

The second one is an object for more fine-grained configuration
when the first option is "as-needed". Currently,
the only available option is requireReturnForObjectLiteral, a boolean property.
It’s false by default. If set to true, it requires braces and an explicit return for object literals.

```json
{
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }]
}
```

## How to use

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

::: code-group

```bash [CLI]
oxlint --deny arrow-body-style
```

```json [Config (.oxlintrc.json)]
{
"rules": {
"arrow-body-style": "error"
}
}
```

:::

## References

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
140 changes: 140 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/id-length.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

<script setup>
import { data } from '../version.data.js';
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/eslint/id_length.rs`;
</script>

# eslint/id-length <Badge type="info" text="Style" />

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

### What it does

This rule enforces a minimum and/or maximum identifier length convention by counting the
graphemes for a given identifier.

### Why is this bad?

Very short identifier names like e, x, _t or very long ones like
hashGeneratorResultOutputContainerObject can make code harder to read and potentially less
maintainable. To prevent this, one may enforce a minimum and/or maximum identifier length.

### Examples

Examples of **incorrect** code for this rule:

```js
/*eslint id-length: "error"*/
// default is minimum 2-chars ({ "min": 2 })

const x = 5;
obj.e = document.body;
const foo = function(e) {};
try {
dangerousStuff();
} catch (e) {
// ignore as many do
}
const myObj = { a: 1 };
((a) => {
a * a;
});
class y {}
class Foo {
x() {}
}
class Bar {
#x() {}
}
class Baz {
x = 1;
}
class Qux {
#x = 1;
}
function bar(...x) {}
function baz([x]) {}
const [z] = arr;
const { prop: [i] } = {};
function qux({ x }) {}
const { j } = {};
const { prop: a } = {};
({ prop: obj.x } = {});
```

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

```js
/*eslint id-length: "error"*/
// default is minimum 2-chars ({ "min": 2 })

const num = 5;
function _f() {
return 42;
}
function _func() {
return 42;
}
obj.el = document.body;
const foo = function(evt) {/* do stuff */};
try {
dangerousStuff();
} catch (error) {
// ignore as many do
}
const myObj = { apple: 1 };
((num) => {
num * num;
});
function bar(num = 0) {}
class MyClass {}
class Foo {
method() {}
}
class Bar {
#method() {}
}
class Baz {
field = 1;
}
class Qux {
#field = 1;
}
function baz(...args) {}
function qux([longName]) {}
const { prop } = {};
const { prop: [name] } = {};
const [longName] = arr;
function foobar({ prop }) {}
function foobaz({ a: prop }) {}
const { a: property } = {};
({ prop: obj.longName } = {});
const data = { "x": 1 }; // excused because of quotes
data["y"] = 3; // excused because of calculated property access
```

## How to use

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

::: code-group

```bash [CLI]
oxlint --deny id-length
```

```json [Config (.oxlintrc.json)]
{
"rules": {
"id-length": "error"
}
}
```

:::

## References

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/import/no-duplicates.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { data } from '../version.data.js';
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/import/no_duplicates.rs`;
</script>

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

<div class="rule-meta">
</div>
Expand Down
Loading