Skip to content

Commit adb9d6e

Browse files
oxc-botgithub-actions[bot]
authored andcommitted
Release 1.2.0
1 parent c4c27aa commit adb9d6e

File tree

8 files changed

+136
-7
lines changed

8 files changed

+136
-7
lines changed

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

Lines changed: 3 additions & 2 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: 520
5+
- Total number of rules: 521
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 (66):
216+
## Restriction (67):
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

@@ -238,6 +238,7 @@ Lints which prevent the use of language and library features. Must not be enable
238238
| [no-var](/docs/guide/usage/linter/rules/eslint/no-var.html) | eslint | | 🛠️ |
239239
| [no-void](/docs/guide/usage/linter/rules/eslint/no-void.html) | eslint | | 💡 |
240240
| [unicode-bom](/docs/guide/usage/linter/rules/eslint/unicode-bom.html) | eslint | | 🛠️ |
241+
| [extensions](/docs/guide/usage/linter/rules/import/extensions.html) | import | | |
241242
| [no-amd](/docs/guide/usage/linter/rules/import/no-amd.html) | import | | |
242243
| [no-commonjs](/docs/guide/usage/linter/rules/import/no-commonjs.html) | import | | |
243244
| [no-cycle](/docs/guide/usage/linter/rules/import/no-cycle.html) | import | | |

src/docs/guide/usage/linter/rules/eslint/no-console.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> A suggestion is available for this rule.
12+
<span class="emoji">💡</span> A suggestion is available for this rule for some violations.
1313
</Alert>
1414
</div>
1515

src/docs/guide/usage/linter/rules/eslint/no-var.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 available for this rule.
12+
<span class="emoji">🛠️</span> An auto-fix is available for this rule for some violations.
1313
</Alert>
1414
</div>
1515

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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/import/extensions.rs`;
6+
</script>
7+
8+
# import/extensions <Badge type="info" text="Restriction" />
9+
10+
<div class="rule-meta">
11+
</div>
12+
13+
### What it does
14+
15+
Some file resolve algorithms allow you to omit the file extension within the import source path.
16+
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.
17+
Depending on the resolver you can configure more extensions to get resolved automatically.
18+
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.
19+
20+
### Why is this bad?
21+
22+
ESM-based file resolve algorithms (e.g., the one that Vite provides) recommend specifying the file extension to improve performance.
23+
24+
### Examples
25+
26+
Examples of **incorrect** code for this rule:
27+
28+
The following patterns are considered problems when configuration set to "always":
29+
30+
```js
31+
import foo from "@/foo";
32+
import bar from "./bar";
33+
import Component from "./Component";
34+
import foo from "./foo";
35+
```
36+
37+
The following patterns are considered problems when configuration set to "never":
38+
39+
```js
40+
import express from "express/index.js";
41+
import bar from "./bar.json";
42+
import Component from "./Component.jsx";
43+
import foo from "./foo.js";
44+
```
45+
46+
Examples of **correct** code for this rule:
47+
48+
The following patterns are not considered problems when configuration set to "always":
49+
50+
```js
51+
import foo from "@/foo.js";
52+
import * as path from "path";
53+
import bar from "./bar.json";
54+
import Component from "./Component.jsx";
55+
import foo from "./foo.js";
56+
```
57+
58+
The following patterns are not considered problems when configuration set to "never":
59+
60+
```js
61+
import express from "express/index";
62+
import * as path from "path";
63+
import bar from "./bar";
64+
import Component from "./Component";
65+
import foo from "./foo";
66+
```
67+
68+
## How to use
69+
70+
To **enable** this rule in the CLI or using the config file, you can use:
71+
72+
::: code-group
73+
74+
```bash [CLI]
75+
oxlint --deny import/extensions --import-plugin
76+
```
77+
78+
```json [Config (.oxlintrc.json)]
79+
{
80+
"plugins": ["import"],
81+
"rules": {
82+
"import/extensions": "error"
83+
}
84+
}
85+
```
86+
87+
:::
88+
89+
## References
90+
91+
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Namespaced imports, while sometimes used, are generally considered less ideal in
4242

4343
```json
4444
{
45-
"ignores": ["*.json"]
45+
"ignore": ["*.json"]
4646
}
4747
```
4848

src/docs/guide/usage/linter/rules/jest/valid-expect.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ Checks that `expect()` is called correctly.
1919

2020
### Why is this bad?
2121

22-
`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.
22+
`expect()` is a function that is used to assert values in tests.
23+
It should be called with a single argument, which is the value to be tested.
24+
If you call `expect()` with no arguments, or with more than one argument, it will not work as expected.
2325

2426
### Examples
2527

src/docs/guide/usage/linter/rules/typescript/array-type.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ const arr: Array<number> = new Array<number>();
3535
const arr: number[] = new Array<number>();
3636
```
3737

38+
```typescript
39+
/*oxlint array-type: ["error", { "default": "array-simple" }] */
40+
const a: (string | number)[] = ["a", "b"];
41+
const b: { prop: string }[] = [{ prop: "a" }];
42+
const c: Array<MyType> = ["a", "b"];
43+
const d: Array<string> = ["a", "b"];
44+
```
45+
3846
Examples of **correct** code for this rule:
3947

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

58+
```typescript
59+
/*oxlint array-type: ["error", { "default": "array-simple" }] */
60+
const a: Array<string | number> = ["a", "b"];
61+
const b: Array<{ prop: string }> = [{ prop: "a" }];
62+
const c: string[] = ["a", "b"];
63+
const d: MyType[] = ["a", "b"];
64+
```
65+
66+
### Options
67+
68+
```json
69+
{
70+
"typescript/array-type": ["error", { "default": "array", "readonly": "array" }]
71+
}
72+
```
73+
74+
- `default`: The array type expected for mutable cases.
75+
- `readonly`: The array type expected for readonly cases. If omitted, the value for `default` will be used.
76+
77+
Both `default` and `readonly` can be one of:
78+
79+
- `"array"`
80+
- `"generic"`
81+
- `"array-simple"`
82+
83+
The default config will enforce that all mutable and readonly arrays use the 'array' syntax.
84+
5085
## How to use
5186

5287
To **enable** this rule in the CLI or using the config file, you can use:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
22
load() {
3-
return "40ca1ef8d4b2e923caf723ebd190a9d52efeaef5";
3+
return "08e666fc2da750dc6e8659f1e71b0766058516d6";
44
},
55
};

0 commit comments

Comments
 (0)