Skip to content

Commit a39a6a9

Browse files
authored
Release 1.14.0 (#471)
1 parent bd28df2 commit a39a6a9

File tree

6 files changed

+263
-44
lines changed

6 files changed

+263
-44
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
## Usage
22

3-
**`oxlint`** \[**`-c`**=_`<./oxlintrc.json>`_\] \[_`PATH`_\]...
3+
**`oxlint`** \[**`-c`**=_`<./.oxlintrc.json>`_\] \[_`PATH`_\]...
44

55
## Basic Configuration
66

7-
- **`-c`**, **`--config`**=_`<./oxlintrc.json>`_ &mdash;
7+
- **`-c`**, **`--config`**=_`<./.oxlintrc.json>`_ &mdash;
88
Oxlint configuration file (experimental)
99

1010
* only `.json` extension is supported
11+
* you can use comments in configuration files.
1112
* tries to be compatible with the ESLint v8's format
1213

1314
If not provided, Oxlint will look for `.oxlintrc.json` in the current working directory.

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: 573
5+
- Total number of rules: 574
66
- Rules turned on by default: 103
77

88
**Legend for 'Fixable?' column:**
@@ -13,7 +13,7 @@ The progress of all rule implementations is tracked [here](https://github.com/ox
1313
- ⚠️💡: a dangerous suggestion is available for this rule
1414
- 🚧: an auto-fix or suggestion is possible, but currently not implemented
1515

16-
## Correctness (193):
16+
## Correctness (194):
1717

1818
Code that is outright wrong or useless.
1919

@@ -212,6 +212,7 @@ Code that is outright wrong or useless.
212212
| [prefer-string-starts-ends-with](/docs/guide/usage/linter/rules/unicorn/prefer-string-starts-ends-with.html) | unicorn || 🛠️ |
213213
| [no-conditional-tests](/docs/guide/usage/linter/rules/vitest/no-conditional-tests.html) | vitest | | |
214214
| [require-local-test-context-for-concurrent-snapshots](/docs/guide/usage/linter/rules/vitest/require-local-test-context-for-concurrent-snapshots.html) | vitest | | 🚧 |
215+
| [valid-define-emits](/docs/guide/usage/linter/rules/vue/valid-define-emits.html) | vue | | 🚧 |
215216

216217
## Perf (11):
217218

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

Lines changed: 87 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,101 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin
1616
### What it does
1717

1818
This rule can enforce or disallow the use of braces around arrow function body.
19+
Arrow functions can use either:
20+
21+
- a block body `() => { ... }`
22+
- or a concise body `() => expression` with an implicit return.
1923

2024
### Why is this bad?
2125

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.
26+
Inconsistent use of block vs. concise bodies makes code harder to read.
27+
Concise bodies are limited to a single expression, whose value is implicitly returned.
28+
29+
### Options
30+
31+
First option:
32+
33+
- Type: `string`
34+
- Enum: `"always"`, `"as-needed"`, `"never"`
35+
- Default: `"never"`
36+
37+
Possible values:
38+
39+
- `never` enforces no braces where they can be omitted (default)
40+
- `always` enforces braces around the function body
41+
- `as-needed` enforces no braces around the function body (constrains arrow functions to the role of returning an expression)
42+
43+
Second option:
44+
45+
- Type: `object`
46+
- Properties:
47+
- `requireReturnForObjectLiteral`: `boolean` (default: `false`) - requires braces and an explicit return for object literals.
48+
49+
Note: This option only applies when the first option is `"as-needed"`.
50+
51+
Example configuration:
52+
53+
```json
54+
{
55+
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }]
56+
}
57+
```
2558

2659
### Examples
2760

61+
#### `"never"` (default)
62+
63+
Examples of **incorrect** code for this rule with the `never` option:
64+
65+
```js
66+
/* arrow-body-style: ["error", "never"] */
67+
68+
/* ✘ Bad: */
69+
const foo = () => {
70+
return 0;
71+
};
72+
```
73+
74+
Examples of **correct** code for this rule with the `never` option:
75+
76+
```js
77+
/* arrow-body-style: ["error", "never"] */
78+
79+
/* ✔ Good: */
80+
const foo = () => 0;
81+
const bar = () => ({ foo: 0 });
82+
```
83+
84+
#### `"always"`
85+
2886
Examples of **incorrect** code for this rule with the `always` option:
2987

3088
```js
89+
/* arrow-body-style: ["error", "always"] */
90+
91+
/* ✘ Bad: */
3192
const foo = () => 0;
3293
```
3394

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

3697
```js
98+
/* arrow-body-style: ["error", "always"] */
99+
100+
/* ✔ Good: */
37101
const foo = () => {
38102
return 0;
39103
};
40104
```
41105

106+
#### `"as-needed"`
107+
42108
Examples of **incorrect** code for this rule with the `as-needed` option:
43109

44110
```js
111+
/* arrow-body-style: ["error", "as-needed"] */
112+
113+
/* ✘ Bad: */
45114
const foo = () => {
46115
return 0;
47116
};
@@ -50,66 +119,45 @@ const foo = () => {
50119
Examples of **correct** code for this rule with the `as-needed` option:
51120

52121
```js
122+
/* arrow-body-style: ["error", "as-needed"] */
123+
124+
/* ✔ Good: */
53125
const foo1 = () => 0;
54126

55127
const foo2 = (retv, name) => {
56128
retv[name] = true;
57129
return retv;
58130
};
131+
132+
const foo3 = () => {
133+
bar();
134+
};
59135
```
60136

61-
Examples of **incorrect** code for this rule with the { "requireReturnForObjectLiteral": true } option:
137+
#### `"as-needed"` with `requireReturnForObjectLiteral`
138+
139+
Examples of **incorrect** code for this rule with the `{ "requireReturnForObjectLiteral": true }` option:
62140

63141
```js
64142
/* arrow-body-style: ["error", "as-needed", { "requireReturnForObjectLiteral": true }]*/
143+
144+
/* ✘ Bad: */
65145
const foo = () => ({});
66146
const bar = () => ({ bar: 0 });
67147
```
68148

69-
Examples of **correct** code for this rule with the { "requireReturnForObjectLiteral": true } option:
149+
Examples of **correct** code for this rule with the `{ "requireReturnForObjectLiteral": true }` option:
70150

71151
```js
72152
/* arrow-body-style: ["error", "as-needed", { "requireReturnForObjectLiteral": true }]*/
153+
154+
/* ✔ Good: */
73155
const foo = () => {};
74156
const bar = () => {
75157
return { bar: 0 };
76158
};
77159
```
78160

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-
113161
## How to use
114162

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

src/docs/guide/usage/linter/rules/eslint/grouped-accessor-pairs.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,53 @@ const foo = {
104104
};
105105
```
106106

107+
### Options
108+
109+
This rule accepts two arguments:
110+
111+
1. A string value to control the order of the getter/setter pairs:
112+
- `"anyOrder"` (default): Accessors can be in any order
113+
- `"getBeforeSet"`: Getters must come before setters
114+
- `"setBeforeGet"`: Setters must come before getters
115+
2. An object with the following option:
116+
- `enforceForTSTypes` (boolean, default: false): When enabled, also checks TypeScript interfaces and type aliases for grouped accessor pairs
117+
118+
### TypeScript
119+
120+
When `enforceForTSTypes` is enabled, this rule also applies to TypeScript interfaces and type aliases:
121+
122+
Examples of **incorrect** TypeScript code:
123+
124+
```ts
125+
interface Foo {
126+
get a(): string;
127+
someProperty: string;
128+
set a(value: string);
129+
}
130+
131+
type Bar = {
132+
get b(): string;
133+
someProperty: string;
134+
set b(value: string);
135+
};
136+
```
137+
138+
Examples of **correct** TypeScript code:
139+
140+
```ts
141+
interface Foo {
142+
get a(): string;
143+
set a(value: string);
144+
someProperty: string;
145+
}
146+
147+
type Bar = {
148+
get b(): string;
149+
set b(value: string);
150+
someProperty: string;
151+
};
152+
```
153+
107154
## How to use
108155

109156
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 "6efb63a67ede0145468c83ff17217547d2e00ef8";
3+
return "7fc4aef229419ae73e4feae806eb73b7fed3b983";
44
},
55
};

0 commit comments

Comments
 (0)