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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 65 additions & 8 deletions src/docs/guide/usage/linter/generated-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Only the `.json` format is supported. You can use comments in configuration file

Example

```json [.oxlintrc.json]
`.oxlintrc.json`

```json
{
"env": {
"browser": true
Expand All @@ -28,17 +30,52 @@ Example
}
```

## env
## categories

type: `object`

Configure an entire category of rules all at once.

Rules enabled or disabled this way will be overwritten by individual rules in the `rules` field.

# Example

```json
{
"categories": {
"correctness": "warn"
},
"rules": {
"eslint/no-unused-vars": "error"
}
}
```

### categories.correctness

### categories.nursery

### categories.pedantic

### categories.perf

### categories.restriction

### categories.style

### categories.suspicious

## env

type: `Record<string, boolean>`

Predefine global variables.

Environments specify what global variables are predefined. See [ESLint's list of environments](https://eslint.org/docs/v8.x/use/configure/language-options#specifying-environments) for what environments are available and what each one provides.

## globals

type: `object`
type: `Record<string, string>`

Add or remove global variables.

Expand All @@ -61,11 +98,9 @@ You may also use `"readable"` or `false` to represent `"readonly"`, and `"writea

## plugins

type: `array`

### plugins[n]
type: `string[]`

type: `string`
default: `["react", "unicorn", "typescript", "oxc"]`

## rules

Expand All @@ -87,55 +122,73 @@ type: `object`

type: `boolean`

default: `false`

Only for `require-(yields|returns|description|example|param|throws)` rule

#### settings.jsdoc.exemptDestructuredRootsFromChecks

type: `boolean`

default: `false`

Only for `require-param-type` and `require-param-description` rule

#### settings.jsdoc.ignoreInternal

type: `boolean`

default: `false`

For all rules but NOT apply to `empty-tags` rule

#### settings.jsdoc.ignorePrivate

type: `boolean`

default: `false`

For all rules but NOT apply to `check-access` and `empty-tags` rule

#### settings.jsdoc.ignoreReplacesDocs

type: `boolean`

default: `true`

Only for `require-(yields|returns|description|example|param|throws)` rule

#### settings.jsdoc.implementsReplacesDocs

type: `boolean`

default: `false`

Only for `require-(yields|returns|description|example|param|throws)` rule

#### settings.jsdoc.overrideReplacesDocs

type: `boolean`

default: `true`

Only for `require-(yields|returns|description|example|param|throws)` rule

#### settings.jsdoc.tagNamePreference

type: `object`

default: `{}`

### settings.jsx-a11y

type: `object`

#### settings.jsx-a11y.components

type: `object`
type: `Record<string, string>`

default: `{}`

#### settings.jsx-a11y.polymorphicPropName

Expand All @@ -158,10 +211,14 @@ type: `object`

type: `array`

default: `[]`

##### settings.react.formComponents[n]

#### settings.react.linkComponents

type: `array`

default: `[]`

##### settings.react.linkComponents[n]
19 changes: 11 additions & 8 deletions src/docs/guide/usage/linter/generated-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

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

- Total number of rules: 436
- Rules turned on by default: 96
- Total number of rules: 439
- Rules turned on by default: 98

## Correctness (170):
## Correctness (173):

Code that is outright wrong or useless.
| Rule name | Source | Default | Fixable? |
Expand Down Expand Up @@ -47,6 +47,7 @@ Code that is outright wrong or useless.
| [no-this-before-super](/docs/guide/usage/linter/rules/eslint/no-this-before-super.html) | eslint | ✅ | |
| [no-unsafe-finally](/docs/guide/usage/linter/rules/eslint/no-unsafe-finally.html) | eslint | ✅ | |
| [no-unsafe-negation](/docs/guide/usage/linter/rules/eslint/no-unsafe-negation.html) | eslint | ✅ | 🛠️ |
| [no-unsafe-optional-chaining](/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.html) | eslint | ✅ | |
| [no-unused-labels](/docs/guide/usage/linter/rules/eslint/no-unused-labels.html) | eslint | ✅ | 🛠️ |
| [no-unused-private-class-members](/docs/guide/usage/linter/rules/eslint/no-unused-private-class-members.html) | eslint | ✅ | |
| [no-unused-vars](/docs/guide/usage/linter/rules/eslint/no-unused-vars.html) | eslint | ✅ | ⚠️💡 |
Expand Down Expand Up @@ -139,8 +140,10 @@ Code that is outright wrong or useless.
| [number-arg-out-of-range](/docs/guide/usage/linter/rules/oxc/number-arg-out-of-range.html) | oxc | ✅ | |
| [only-used-in-recursion](/docs/guide/usage/linter/rules/oxc/only-used-in-recursion.html) | oxc | ✅ | ⚠️🛠️️ |
| [uninvoked-array-callback](/docs/guide/usage/linter/rules/oxc/uninvoked-array-callback.html) | oxc | ✅ | |
| [no-callback-in-promise](/docs/guide/usage/linter/rules/promise/no-callback-in-promise.html) | promise | | |
| [no-new-statics](/docs/guide/usage/linter/rules/promise/no-new-statics.html) | promise | | 🛠️ |
| [valid-params](/docs/guide/usage/linter/rules/promise/valid-params.html) | promise | | |
| [iframe-missing-sandbox](/docs/guide/usage/linter/rules/react/iframe-missing-sandbox.html) | react | ✅ | 🚧 |
| [jsx-key](/docs/guide/usage/linter/rules/react/jsx-key.html) | react | ✅ | |
| [jsx-no-duplicate-props](/docs/guide/usage/linter/rules/react/jsx-no-duplicate-props.html) | react | ✅ | |
| [jsx-no-target-blank](/docs/guide/usage/linter/rules/react/jsx-no-target-blank.html) | react | ✅ | |
Expand Down Expand Up @@ -208,12 +211,11 @@ Lints which prevent the use of language and library features. Must not be enable
| [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-plusplus](/docs/guide/usage/linter/rules/eslint/no-plusplus.html) | eslint | | 💡 |
| [no-proto](/docs/guide/usage/linter/rules/eslint/no-proto.html) | eslint | | 🚧 |
| [no-regex-spaces](/docs/guide/usage/linter/rules/eslint/no-regex-spaces.html) | eslint | | 🚧 |
| [no-restricted-globals](/docs/guide/usage/linter/rules/eslint/no-restricted-globals.html) | eslint | | |
| [no-undefined](/docs/guide/usage/linter/rules/eslint/no-undefined.html) | eslint | | |
| [no-unsafe-optional-chaining](/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.html) | eslint | | |
| [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 | | 🛠️ |
Expand All @@ -224,6 +226,7 @@ Lints which prevent the use of language and library features. Must not be enable
| [no-webpack-loader-syntax](/docs/guide/usage/linter/rules/import/no-webpack-loader-syntax.html) | import | | |
| [check-access](/docs/guide/usage/linter/rules/jsdoc/check-access.html) | jsdoc | | |
| [empty-tags](/docs/guide/usage/linter/rules/jsdoc/empty-tags.html) | jsdoc | | |
| [no-new-require](/docs/guide/usage/linter/rules/node/no-new-require.html) | node | | |
| [bad-bitwise-operator](/docs/guide/usage/linter/rules/oxc/bad-bitwise-operator.html) | oxc | | |
| [no-async-await](/docs/guide/usage/linter/rules/oxc/no-async-await.html) | oxc | | |
| [no-barrel-file](/docs/guide/usage/linter/rules/oxc/no-barrel-file.html) | oxc | | |
Expand Down Expand Up @@ -282,7 +285,7 @@ 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 (71):
## Pedantic (70):

Lints which are rather strict or have occasional false positives.
| Rule name | Source | Default | Fixable? |
Expand All @@ -304,7 +307,6 @@ Lints which are rather strict or have occasional false positives.
| [no-throw-literal](/docs/guide/usage/linter/rules/eslint/no-throw-literal.html) | eslint | | 💡 |
| [radix](/docs/guide/usage/linter/rules/eslint/radix.html) | eslint | | |
| [require-await](/docs/guide/usage/linter/rules/eslint/require-await.html) | eslint | | |
| [sort-keys](/docs/guide/usage/linter/rules/eslint/sort-keys.html) | eslint | | 🚧 |
| [sort-vars](/docs/guide/usage/linter/rules/eslint/sort-vars.html) | eslint | | 🚧 |
| [symbol-description](/docs/guide/usage/linter/rules/eslint/symbol-description.html) | eslint | | |
| [max-dependencies](/docs/guide/usage/linter/rules/import/max-dependencies.html) | import | | |
Expand Down Expand Up @@ -359,7 +361,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 (102):
## Style (103):

Code that should be written in a more idiomatic way.
| Rule name | Source | Default | Fixable? |
Expand All @@ -381,6 +383,7 @@ Code that should be written in a more idiomatic way.
| [prefer-exponentiation-operator](/docs/guide/usage/linter/rules/eslint/prefer-exponentiation-operator.html) | eslint | | |
| [prefer-numeric-literals](/docs/guide/usage/linter/rules/eslint/prefer-numeric-literals.html) | eslint | | 🛠️ |
| [sort-imports](/docs/guide/usage/linter/rules/eslint/sort-imports.html) | eslint | | 🛠️ |
| [sort-keys](/docs/guide/usage/linter/rules/eslint/sort-keys.html) | eslint | | 🚧 |
| [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
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/no-else-return.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<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
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/no-plusplus.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

# eslint/no-unsafe-optional-chaining <Badge type="info" text="Restriction" />
# eslint/no-unsafe-optional-chaining <Badge type="info" text="Correctness" />

<div class="rule-meta">
<Alert class="default-on" type="success">
<span class="emoji">✅</span> This rule is turned on by default.
</Alert>
</div>

### What it does
Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/sort-keys.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

# eslint/sort-keys <Badge type="info" text="Pedantic" />
# eslint/sort-keys <Badge type="info" text="Style" />

<div class="rule-meta">
<Alert class="fix" type="info">
Expand Down
34 changes: 34 additions & 0 deletions src/docs/guide/usage/linter/rules/node/no-new-require.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

# node/no-new-require <Badge type="info" text="Restriction" />

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

### What it does

Warn about calling `new` on `require`.

### Why is this bad?

The `require` function is used to include modules and might return a constructor. As this
is not always the case this can be confusing.

### Examples

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

```js
var appHeader = new require("app-header");
```

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

```js
var AppHeader = require("app-header");
var appHeader = new AppHeader();
```

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/node/no_new_require.rs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

# promise/no-callback-in-promise <Badge type="info" text="Correctness" />

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

### What it does

Disallows calling a callback function (`cb()`) inside a `Promise.prototype.then()`
or `Promise.prototype.catch()`.

### Why is this bad?

Directly invoking a callback inside a `then()` or `catch()` method can lead to
unexpected behavior, such as the callback being called multiple times. Additionally,
mixing the callback and promise paradigms in this way can make the code confusing
and harder to maintain.

### Examples

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

```js
function callback(err, data) {
console.log("Callback got called with:", err, data);
throw new Error("My error");
}

Promise.resolve()
.then(() => callback(null, "data"))
.catch((err) => callback(err.message, null));
```

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

```js
Promise.resolve()
.then((data) => {
console.log(data);
})
.catch((err) => {
console.error(err);
});
```

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/promise/no_callback_in_promise.rs)
Loading