Skip to content

Release 1.2.0 #402

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 19, 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
5 changes: 3 additions & 2 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: 520
- Total number of rules: 521
- 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 (66):
## Restriction (67):

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 All @@ -238,6 +238,7 @@ Lints which prevent the use of language and library features. Must not be enable
| [no-var](/docs/guide/usage/linter/rules/eslint/no-var.html) | eslint | | 🛠️ |
| [no-void](/docs/guide/usage/linter/rules/eslint/no-void.html) | eslint | | 💡 |
| [unicode-bom](/docs/guide/usage/linter/rules/eslint/unicode-bom.html) | eslint | | 🛠️ |
| [extensions](/docs/guide/usage/linter/rules/import/extensions.html) | import | | |
| [no-amd](/docs/guide/usage/linter/rules/import/no-amd.html) | import | | |
| [no-commonjs](/docs/guide/usage/linter/rules/import/no-commonjs.html) | import | | |
| [no-cycle](/docs/guide/usage/linter/rules/import/no-cycle.html) | import | | |
Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/no-console.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin

<div class="rule-meta">
<Alert class="fix" type="info">
<span class="emoji">💡</span> A suggestion is available for this rule.
<span class="emoji">💡</span> A suggestion is available for this rule for some violations.
</Alert>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/no-var.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin

<div class="rule-meta">
<Alert class="fix" type="info">
<span class="emoji">🛠️</span> An auto-fix is available for this rule.
<span class="emoji">🛠️</span> An auto-fix is available for this rule for some violations.
</Alert>
</div>

Expand Down
91 changes: 91 additions & 0 deletions src/docs/guide/usage/linter/rules/import/extensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<!-- 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/import/extensions.rs`;
</script>

# import/extensions <Badge type="info" text="Restriction" />

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

### What it does

Some file resolve algorithms allow you to omit the file extension within the import source path.
For example the node resolver (which does not yet support ESM/import) can resolve ./foo/bar to the absolute path /User/someone/foo/bar.js because the .js extension is resolved automatically by default in CJS.
Depending on the resolver you can configure more extensions to get resolved automatically.
In order to provide a consistent use of file extensions across your code base, this rule can enforce or disallow the use of certain file extensions.

### Why is this bad?

ESM-based file resolve algorithms (e.g., the one that Vite provides) recommend specifying the file extension to improve performance.

### Examples

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

The following patterns are considered problems when configuration set to "always":

```js
import foo from "@/foo";
import bar from "./bar";
import Component from "./Component";
import foo from "./foo";
```

The following patterns are considered problems when configuration set to "never":

```js
import express from "express/index.js";
import bar from "./bar.json";
import Component from "./Component.jsx";
import foo from "./foo.js";
```

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

The following patterns are not considered problems when configuration set to "always":

```js
import foo from "@/foo.js";
import * as path from "path";
import bar from "./bar.json";
import Component from "./Component.jsx";
import foo from "./foo.js";
```

The following patterns are not considered problems when configuration set to "never":

```js
import express from "express/index";
import * as path from "path";
import bar from "./bar";
import Component from "./Component";
import foo from "./foo";
```

## How to use

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

::: code-group

```bash [CLI]
oxlint --deny import/extensions --import-plugin
```

```json [Config (.oxlintrc.json)]
{
"plugins": ["import"],
"rules": {
"import/extensions": "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-namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Namespaced imports, while sometimes used, are generally considered less ideal in

```json
{
"ignores": ["*.json"]
"ignore": ["*.json"]
}
```

Expand Down
4 changes: 3 additions & 1 deletion src/docs/guide/usage/linter/rules/jest/valid-expect.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Checks that `expect()` is called correctly.

### Why is this bad?

`expect()` is a function that is used to assert values in tests. It should be called with a single argument, which is the value to be tested. If you call `expect()` with no arguments, or with more than one argument, it will not work as expected.
`expect()` is a function that is used to assert values in tests.
It should be called with a single argument, which is the value to be tested.
If you call `expect()` with no arguments, or with more than one argument, it will not work as expected.

### Examples

Expand Down
35 changes: 35 additions & 0 deletions src/docs/guide/usage/linter/rules/typescript/array-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ const arr: Array<number> = new Array<number>();
const arr: number[] = new Array<number>();
```

```typescript
/*oxlint array-type: ["error", { "default": "array-simple" }] */
const a: (string | number)[] = ["a", "b"];
const b: { prop: string }[] = [{ prop: "a" }];
const c: Array<MyType> = ["a", "b"];
const d: Array<string> = ["a", "b"];
```

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

```typescript
Expand All @@ -47,6 +55,33 @@ const arr: number[] = new Array<number>();
const arr: Array<number> = new Array<number>();
```

```typescript
/*oxlint array-type: ["error", { "default": "array-simple" }] */
const a: Array<string | number> = ["a", "b"];
const b: Array<{ prop: string }> = [{ prop: "a" }];
const c: string[] = ["a", "b"];
const d: MyType[] = ["a", "b"];
```

### Options

```json
{
"typescript/array-type": ["error", { "default": "array", "readonly": "array" }]
}
```

- `default`: The array type expected for mutable cases.
- `readonly`: The array type expected for readonly cases. If omitted, the value for `default` will be used.

Both `default` and `readonly` can be one of:

- `"array"`
- `"generic"`
- `"array-simple"`

The default config will enforce that all mutable and readonly arrays use the 'array' syntax.

## How to use

To **enable** this rule in the CLI or using the config file, you can use:
Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/version.data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
load() {
return "40ca1ef8d4b2e923caf723ebd190a9d52efeaef5";
return "08e666fc2da750dc6e8659f1e71b0766058516d6";
},
};