Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions src/docs/guide/usage/linter/generated-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ Arguments:

- **` --rules`** —
list all the rules that are currently registered
- **` --experimental-nested-config`** —
Enables automatic loading of nested configuration files (experimental feature)
- **`-h`**, **`--help`** —
Prints help information
- **`-V`**, **`--version`** —
Expand Down
22 changes: 14 additions & 8 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: 481
- Total number of rules: 487
- Rules turned on by default: 123

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

## Correctness (171):
## Correctness (173):

Code that is outright wrong or useless.
| Rule name | Source | Default | Fixable? |
Expand All @@ -37,6 +37,7 @@ Code that is outright wrong or useless.
| [no-empty-character-class](/docs/guide/usage/linter/rules/eslint/no-empty-character-class.html) | eslint | ✅ | |
| [no-empty-pattern](/docs/guide/usage/linter/rules/eslint/no-empty-pattern.html) | eslint | ✅ | |
| [no-empty-static-block](/docs/guide/usage/linter/rules/eslint/no-empty-static-block.html) | eslint | ✅ | 💡 |
| [no-eval](/docs/guide/usage/linter/rules/eslint/no-eval.html) | eslint | ✅ | |
| [no-ex-assign](/docs/guide/usage/linter/rules/eslint/no-ex-assign.html) | eslint | ✅ | |
| [no-extra-boolean-cast](/docs/guide/usage/linter/rules/eslint/no-extra-boolean-cast.html) | eslint | ✅ | 🚧 |
| [no-func-assign](/docs/guide/usage/linter/rules/eslint/no-func-assign.html) | eslint | ✅ | |
Expand Down Expand Up @@ -177,6 +178,7 @@ Code that is outright wrong or useless.
| [no-await-in-promise-methods](/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.html) | unicorn | ✅ | |
| [no-document-cookie](/docs/guide/usage/linter/rules/unicorn/no-document-cookie.html) | unicorn | ✅ | |
| [no-empty-file](/docs/guide/usage/linter/rules/unicorn/no-empty-file.html) | unicorn | ✅ | |
| [no-invalid-fetch-options](/docs/guide/usage/linter/rules/unicorn/no-invalid-fetch-options.html) | unicorn | ✅ | |
| [no-invalid-remove-event-listener](/docs/guide/usage/linter/rules/unicorn/no-invalid-remove-event-listener.html) | unicorn | ✅ | |
| [no-new-array](/docs/guide/usage/linter/rules/unicorn/no-new-array.html) | unicorn | ✅ | 🚧 |
| [no-single-promise-in-promise-methods](/docs/guide/usage/linter/rules/unicorn/no-single-promise-in-promise-methods.html) | unicorn | ✅ | 🛠️ |
Expand Down Expand Up @@ -205,7 +207,7 @@ Code that can be written to run faster.
| [jsx-no-new-object-as-prop](/docs/guide/usage/linter/rules/react_perf/jsx-no-new-object-as-prop.html) | react_perf | | |
| [prefer-set-has](/docs/guide/usage/linter/rules/unicorn/prefer-set-has.html) | unicorn | | ⚠️🛠️️ |

## Restriction (63):
## Restriction (62):

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.
| Rule name | Source | Default | Fixable? |
Expand All @@ -218,7 +220,6 @@ Lints which prevent the use of language and library features. Must not be enable
| [no-empty](/docs/guide/usage/linter/rules/eslint/no-empty.html) | eslint | | 💡 |
| [no-empty-function](/docs/guide/usage/linter/rules/eslint/no-empty-function.html) | eslint | | |
| [no-eq-null](/docs/guide/usage/linter/rules/eslint/no-eq-null.html) | eslint | | ⚠️🛠️️ |
| [no-eval](/docs/guide/usage/linter/rules/eslint/no-eval.html) | eslint | | |
| [no-iterator](/docs/guide/usage/linter/rules/eslint/no-iterator.html) | eslint | | 💡 |
| [no-plusplus](/docs/guide/usage/linter/rules/eslint/no-plusplus.html) | eslint | | 💡 |
| [no-proto](/docs/guide/usage/linter/rules/eslint/no-proto.html) | eslint | | 🚧 |
Expand Down Expand Up @@ -274,14 +275,15 @@ Lints which prevent the use of language and library features. Must not be enable
| [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 (24):
## Suspicious (25):

code that is most likely wrong or useless.
| Rule name | Source | Default | Fixable? |
| ------------------------------- | ---------- | ------- | -------- |
| [no-extend-native](/docs/guide/usage/linter/rules/eslint/no-extend-native.html) | eslint | | |
| [no-new](/docs/guide/usage/linter/rules/eslint/no-new.html) | eslint | | |
| [no-unexpected-multiline](/docs/guide/usage/linter/rules/eslint/no-unexpected-multiline.html) | eslint | | ⚠️🛠️️ |
| [no-unneeded-ternary](/docs/guide/usage/linter/rules/eslint/no-unneeded-ternary.html) | eslint | | 🚧 |
| [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-duplicates](/docs/guide/usage/linter/rules/import/no-duplicates.html) | import | | |
Expand All @@ -304,15 +306,18 @@ code that is most likely wrong or useless.
| [consistent-function-scoping](/docs/guide/usage/linter/rules/unicorn/consistent-function-scoping.html) | unicorn | | 🚧 |
| [prefer-add-event-listener](/docs/guide/usage/linter/rules/unicorn/prefer-add-event-listener.html) | unicorn | | 🚧 |

## Pedantic (75):
## Pedantic (78):

Lints which are rather strict or have occasional false positives.
| Rule name | Source | Default | Fixable? |
| --------------------------------------- | ---------- | ------- | -------- |
| [array-callback-return](/docs/guide/usage/linter/rules/eslint/array-callback-return.html) | eslint | | |
| [eqeqeq](/docs/guide/usage/linter/rules/eslint/eqeqeq.html) | eslint | | 🛠️ |
| [max-classes-per-file](/docs/guide/usage/linter/rules/eslint/max-classes-per-file.html) | eslint | | |
| [max-depth](/docs/guide/usage/linter/rules/eslint/max-depth.html) | eslint | | |
| [max-lines](/docs/guide/usage/linter/rules/eslint/max-lines.html) | eslint | | |
| [max-lines-per-function](/docs/guide/usage/linter/rules/eslint/max-lines-per-function.html) | eslint | | |
| [max-nested-callbacks](/docs/guide/usage/linter/rules/eslint/max-nested-callbacks.html) | eslint | | |
| [no-array-constructor](/docs/guide/usage/linter/rules/eslint/no-array-constructor.html) | eslint | | 🚧 |
| [no-case-declarations](/docs/guide/usage/linter/rules/eslint/no-case-declarations.html) | eslint | | |
| [no-constructor-return](/docs/guide/usage/linter/rules/eslint/no-constructor-return.html) | eslint | | |
Expand Down Expand Up @@ -385,7 +390,7 @@ 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 (127):
## Style (128):

Code that should be written in a more idiomatic way.
| Rule name | Source | Default | Fixable? |
Expand All @@ -394,6 +399,7 @@ Code that should be written in a more idiomatic way.
| [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 | | |
| [init-declarations](/docs/guide/usage/linter/rules/eslint/init-declarations.html) | eslint | | |
| [max-params](/docs/guide/usage/linter/rules/eslint/max-params.html) | eslint | | |
Expand Down Expand Up @@ -485,7 +491,7 @@ Code that should be written in a more idiomatic way.
| [prefer-for-of](/docs/guide/usage/linter/rules/typescript/prefer-for-of.html) | typescript | | 🚧 |
| [prefer-function-type](/docs/guide/usage/linter/rules/typescript/prefer-function-type.html) | typescript | | 🛠️ |
| [prefer-namespace-keyword](/docs/guide/usage/linter/rules/typescript/prefer-namespace-keyword.html) | typescript | | 🛠️ |
| [catch-error-name](/docs/guide/usage/linter/rules/unicorn/catch-error-name.html) | unicorn | | 🚧 |
| [catch-error-name](/docs/guide/usage/linter/rules/unicorn/catch-error-name.html) | unicorn | | 🛠️ |
| [consistent-existence-index-check](/docs/guide/usage/linter/rules/unicorn/consistent-existence-index-check.html) | unicorn | | 🛠️ |
| [empty-brace-spaces](/docs/guide/usage/linter/rules/unicorn/empty-brace-spaces.html) | unicorn | | 🛠️ |
| [error-message](/docs/guide/usage/linter/rules/unicorn/error-message.html) | unicorn | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ oxlint --deny array-callback-return

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/19fdf8993df7b697b99d9b92a3a546cce7171c42/crates/oxc_linter/src/rules/eslint/array_callback_return/mod.rs)
- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/array_callback_return/mod.rs)
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ oxlint --deny constructor-super

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/19fdf8993df7b697b99d9b92a3a546cce7171c42/crates/oxc_linter/src/rules/eslint/constructor_super.rs)
- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/constructor_super.rs)
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ oxlint --deny default-case-last

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/19fdf8993df7b697b99d9b92a3a546cce7171c42/crates/oxc_linter/src/rules/eslint/default_case_last.rs)
- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/default_case_last.rs)
71 changes: 67 additions & 4 deletions src/docs/guide/usage/linter/rules/eslint/default-case.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ Require default cases in switch statements

### Why is this bad?

Some code conventions require that all switch statements have a default case, even if the
default case is empty.
Some code conventions require that all switch statements have a default case,
even if the default case is empty. The thinking is that it’s better to always
explicitly state what the default behavior should be so that it’s clear
whether or not the developer forgot to include the default behavior by mistake.

### Example
You may optionally include a `// no default` after the last case if there is
no default case. The comment may be in any desired case, such as `// No Default`.

### Examples

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

```javascript
switch (foo) {
Expand All @@ -23,6 +30,62 @@ switch (foo) {
}
```

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

```javascript
switch (a) {
case 1:
/* code */
break;

default:
/* code */
break;
}
```

```javascript
switch (a) {
case 1:
/* code */
break;

// no default
}
```

```javascript
switch (a) {
case 1:
/* code */
break;

// No Default
}
```

### Options

### commentPattern

`{ "commentPattern": string }`

This option is for specifying an alternative regular expression which
will override the default `/^no default$/i` comment test pattern.

For example if `{ "commentPattern": "^skip\\sdefault" }` were used
then the following example would not violate the rule:

```javascript
switch (a) {
case 1:
/* code */
break;

// skip default
}
```

## How to use

To **enable** this rule in the CLI or using the config file, you can use:
Expand All @@ -45,4 +108,4 @@ oxlint --deny default-case

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/19fdf8993df7b697b99d9b92a3a546cce7171c42/crates/oxc_linter/src/rules/eslint/default_case.rs)
- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/default_case.rs)
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ oxlint --deny default-param-last

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/19fdf8993df7b697b99d9b92a3a546cce7171c42/crates/oxc_linter/src/rules/eslint/default_param_last.rs)
- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/default_param_last.rs)
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/eqeqeq.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ oxlint --deny eqeqeq

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/19fdf8993df7b697b99d9b92a3a546cce7171c42/crates/oxc_linter/src/rules/eslint/eqeqeq.rs)
- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/eqeqeq.rs)
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/for-direction.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ oxlint --deny for-direction

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/19fdf8993df7b697b99d9b92a3a546cce7171c42/crates/oxc_linter/src/rules/eslint/for_direction.rs)
- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/for_direction.rs)
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/func-names.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ oxlint --deny func-names

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/19fdf8993df7b697b99d9b92a3a546cce7171c42/crates/oxc_linter/src/rules/eslint/func_names.rs)
- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/func_names.rs)
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/func-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ oxlint --deny func-style

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/19fdf8993df7b697b99d9b92a3a546cce7171c42/crates/oxc_linter/src/rules/eslint/func_style.rs)
- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/func_style.rs)
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/getter-return.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ oxlint --deny getter-return

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/19fdf8993df7b697b99d9b92a3a546cce7171c42/crates/oxc_linter/src/rules/eslint/getter_return.rs)
- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/getter_return.rs)
124 changes: 124 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/grouped-accessor-pairs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

# eslint/grouped-accessor-pairs <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

Require grouped accessor pairs in object literals and classes

### Why is this bad?

While it is allowed to define the pair for a getter or a setter anywhere in an object or class definition,
it’s considered a best practice to group accessor functions for the same property.

### Examples

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

```js
const foo = {
get a() {
return this.val;
},
b: 1,
set a(value) {
this.val = value;
},
};
```

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

```js
const foo = {
get a() {
return this.val;
},
set a(value) {
this.val = value;
},
b: 1,
};
```

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

```js
const foo = {
set a(value) {
this.val = value;
},
get a() {
return this.val;
},
};
```

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

```js
const foo = {
get a() {
return this.val;
},
set a(value) {
this.val = value;
},
};
```

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

```js
const foo = {
get a() {
return this.val;
},
set a(value) {
this.val = value;
},
};
```

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

```js
const foo = {
set a(value) {
this.val = value;
},
get a() {
return this.val;
},
};
```

## How to use

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

::: code-group

```bash [CLI]
oxlint --deny grouped-accessor-pairs
```

```json [Config (.oxlintrc.json)]
{
"rules": {
"grouped-accessor-pairs": "error"
}
}
```

:::

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/grouped_accessor_pairs.rs)
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/guard-for-in.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ oxlint --deny guard-for-in

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/19fdf8993df7b697b99d9b92a3a546cce7171c42/crates/oxc_linter/src/rules/eslint/guard_for_in.rs)
- [Rule Source](https://github.com/oxc-project/oxc/blob/30318457d425dbf627aa428aad8004f6b92b1c59/crates/oxc_linter/src/rules/eslint/guard_for_in.rs)
Loading