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
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 @@ -148,6 +148,8 @@ Arguments:
Disable the automatic loading of nested configuration files
- **`--type-aware`** —
Enable rules that require type information
- **`--type-check`** —
Enable experimental type checking (includes TypeScript compiler diagnostics)
- **`-h`**, **`--help`** —
Prints help information
- **`-V`**, **`--version`** —
Expand Down
10 changes: 6 additions & 4 deletions src/docs/guide/usage/linter/generated-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ search: false

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

- Total number of rules: 615
- Total number of rules: 617
- Rules turned on by default: 103

**Legend for 'Fixable?' column:**
Expand Down Expand Up @@ -345,7 +345,7 @@ code that is most likely wrong or useless.
| [no-self-import](/docs/guide/usage/linter/rules/import/no-self-import.html) | import | | |
| [no-unassigned-import](/docs/guide/usage/linter/rules/import/no-unassigned-import.html) | import | | |
| [no-commented-out-tests](/docs/guide/usage/linter/rules/jest/no-commented-out-tests.html) | jest | | |
| [approx-constant](/docs/guide/usage/linter/rules/oxc/approx-constant.html) | oxc | | |
| [approx-constant](/docs/guide/usage/linter/rules/oxc/approx-constant.html) | oxc | | 🚧 |
| [misrefactored-assign-op](/docs/guide/usage/linter/rules/oxc/misrefactored-assign-op.html) | oxc | | 🚧 |
| [no-async-endpoint-handlers](/docs/guide/usage/linter/rules/oxc/no-async-endpoint-handlers.html) | oxc | | |
| [always-return](/docs/guide/usage/linter/rules/promise/always-return.html) | promise | | |
Expand Down Expand Up @@ -377,7 +377,7 @@ code that is most likely wrong or useless.
| [no-required-prop-with-default](/docs/guide/usage/linter/rules/vue/no-required-prop-with-default.html) | vue | | 🚧 |
| [require-default-export](/docs/guide/usage/linter/rules/vue/require-default-export.html) | vue | | |

## Pedantic (105):
## Pedantic (106):

Lints which are rather strict or have occasional false positives.

Expand Down Expand Up @@ -437,6 +437,7 @@ Lints which are rather strict or have occasional false positives.
| [no-unsafe-return](/docs/guide/usage/linter/rules/typescript/no-unsafe-return.html) | typescript | | 🚧 |
| [only-throw-error](/docs/guide/usage/linter/rules/typescript/only-throw-error.html) | typescript | | 🚧 |
| [prefer-enum-initializers](/docs/guide/usage/linter/rules/typescript/prefer-enum-initializers.html) | typescript | | 🚧 |
| [prefer-includes](/docs/guide/usage/linter/rules/typescript/prefer-includes.html) | typescript | | 🚧 |
| [prefer-promise-reject-errors](/docs/guide/usage/linter/rules/typescript/prefer-promise-reject-errors.html) | typescript | | 🚧 |
| [prefer-ts-expect-error](/docs/guide/usage/linter/rules/typescript/prefer-ts-expect-error.html) | typescript | | 🛠️ |
| [related-getter-setter-pairs](/docs/guide/usage/linter/rules/typescript/related-getter-setter-pairs.html) | typescript | | 🚧 |
Expand Down Expand Up @@ -489,7 +490,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 (167):
## Style (168):

Code that should be written in a more idiomatic way.

Expand Down Expand Up @@ -634,6 +635,7 @@ Code that should be written in a more idiomatic way.
| [number-literal-case](/docs/guide/usage/linter/rules/unicorn/number-literal-case.html) | unicorn | | 🛠️ |
| [numeric-separators-style](/docs/guide/usage/linter/rules/unicorn/numeric-separators-style.html) | unicorn | | 🛠️ |
| [prefer-array-index-of](/docs/guide/usage/linter/rules/unicorn/prefer-array-index-of.html) | unicorn | | 🚧 |
| [prefer-bigint-literals](/docs/guide/usage/linter/rules/unicorn/prefer-bigint-literals.html) | unicorn | | 🛠️ |
| [prefer-class-fields](/docs/guide/usage/linter/rules/unicorn/prefer-class-fields.html) | unicorn | | 🛠️💡 |
| [prefer-classlist-toggle](/docs/guide/usage/linter/rules/unicorn/prefer-classlist-toggle.html) | unicorn | | 🛠️ |
| [prefer-dom-node-text-content](/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-text-content.html) | unicorn | | 🛠️ |
Expand Down
8 changes: 6 additions & 2 deletions src/docs/guide/usage/linter/rules/eslint/curly.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ Examples of **correct** code for this rule:
```js
/* curly: ["error", "all"] */

if (foo) foo++;
while (bar) bar--;
if (foo) {
foo++;
}
while (bar) {
bar--;
}
do {
foo();
} while (bar);
Expand Down
26 changes: 16 additions & 10 deletions src/docs/guide/usage/linter/rules/eslint/default-case.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ makes the code more explicit and reduces mistakes.
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`.

### Options

First option:

- Type: `object`
- Properties:
- `commentPattern`: `string` (default: `/^no default$/i`) - A regex pattern used to detect comments that mark the absence of a `default` case as intentional.

Example configuration:

```json
Expand Down Expand Up @@ -70,12 +62,26 @@ switch (a) {
}
```

#### `commentPattern`
## Configuration

This rule accepts a configuration object with the following properties:

### commentPattern

type: `[
string,
null
]`

A regex pattern used to detect comments that mark the absence
of a `default` case as intentional.

Default value: `no default`.

Examples of **incorrect** code for this rule with the `{ "commentPattern": "^skip\\sdefault" }` option:

```js
/* default-case: ["error", { "commentPattern": "^skip\\sdefault" }] */
/* default-case: ["error", { "commentPattern": "^skip\sdefault" }] */

switch (a) {
case 1:
Expand Down
62 changes: 62 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/new-cap.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,68 @@ Examples of **correct** code for this rule with the `{ "properties": false }` op
var friend = new person.acquaintance();
```

## Configuration

This rule accepts a configuration object with the following properties:

### capIsNew

type: `boolean`

default: `true`

`true` to require that all functions with names starting with an uppercase letter to be called with `new`.

### capIsNewExceptionPattern

type: `[
string,
null
]`

A regex pattern to match exceptions for functions with names starting with an uppercase letter.

### capIsNewExceptions

type: `string[]`

default: `[]`

Exceptions to ignore for functions with names starting with an uppercase letter.

### newIsCap

type: `boolean`

default: `true`

`true` to require that all constructor names start with an uppercase letter, e.g. `new Person()`.

### newIsCapExceptionPattern

type: `[
string,
null
]`

A regex pattern to match exceptions for constructor names starting with an uppercase letter.

### newIsCapExceptions

type: `string[]`

default: `["Array", "Boolean", "Date", "Error", "Function", "Number", "Object", "RegExp", "String", "Symbol", "BigInt"]`

Exceptions to ignore for constructor names starting with an uppercase letter.

### properties

type: `boolean`

default: `true`

`true` to require capitalization for object properties (e.g., `new obj.Method()`).

## How to use

To **enable** this rule in the CLI or using the config file, you can use:
Expand Down
13 changes: 13 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/no-cond-assign.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ if (user.jobTitle === "manager") {
}
```

## Configuration

This rule accepts one of the following string values:

### `"except-parens"`

Allow assignments in conditional expressions only if they are
enclosed in parentheses.

### `"always"`

Disallow all assignments in conditional expressions.

## How to use

To **enable** this rule in the CLI or using the config file, you can use:
Expand Down
7 changes: 5 additions & 2 deletions src/docs/guide/usage/linter/rules/eslint/no-const-assign.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ Disallow reassigning `const` variables.

### Why is this bad?

We cannot modify variables that are declared using const keyword.
It will raise a runtime error.
We cannot modify variables that are declared using the `const` keyword,
as it will raise a runtime error.

Note that this rule is not necessary for TypeScript
code, as TypeScript will already catch this as an error.

### Examples

Expand Down
22 changes: 13 additions & 9 deletions src/docs/guide/usage/linter/rules/eslint/no-else-return.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ following an `if` containing a return statement. As such, it will warn
when it encounters an `else` following a chain of `if`s, all of them
containing a `return` statement.

Options
This rule has an object option:

- `allowElseIf`: `true` _(default)_ allows `else if` blocks after a return
- `allowElseIf`: `false` disallows `else if` blocks after a return

### Examples

#### `allowElseIf: true`
Expand Down Expand Up @@ -142,9 +136,19 @@ function foo4() {
}
```

#### `allowElseIf: false`
## Configuration

Examples of **incorrect** code for this rule:
This rule accepts a configuration object with the following properties:

### allowElseIf

type: `boolean`

default: `true`

Whether to allow `else if` blocks after a return statement.

Examples of **incorrect** code for this rule with `allowElseIf: false`:

```javascript
function foo() {
Expand All @@ -156,7 +160,7 @@ function foo() {
}
```

Examples of **correct** code for this rule:
Examples of **correct** code for this rule with `allowElseIf: false`:

```javascript
function foo() {
Expand Down
29 changes: 29 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/no-fallthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,35 @@ switch (foo) {
Note that the last case statement in these examples does not cause a
warning because there is nothing to fall through into.

## Configuration

This rule accepts a configuration object with the following properties:

### allowEmptyCase

type: `boolean`

default: `false`

Whether to allow empty case clauses to fall through.

### commentPattern

type: `[
string,
null
]`

Custom regex pattern to match fallthrough comments.

### reportUnusedFallthroughComment

type: `boolean`

default: `false`

Whether to report unused fallthrough comments.

## How to use

To **enable** this rule in the CLI or using the config file, you can use:
Expand Down
20 changes: 20 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/no-inner-declarations.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,36 @@ This rule accepts a configuration object with the following properties:

### blockScopedFunctions

type: `"allow" | "disallow"`

default: `null`

Controls whether function declarations in nested blocks are allowed in strict mode (ES6+ behavior).

#### `"allow"`

Allow function declarations in nested blocks in strict mode (ES6+ behavior).

#### `"disallow"`

Disallow function declarations in nested blocks regardless of strict mode.

### config

type: `"functions" | "both"`

default: `"functions"`

Determines what type of declarations to check.

#### `"functions"`

Disallows function declarations in nested blocks.

#### `"both"`

Disallows function and var declarations in nested blocks.

## How to use

To **enable** this rule in the CLI or using the config file, you can use:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_lin

### What it does

Disallow control flow statements in finally blocks
Disallow control flow statements in `finally` blocks.

### Why is this bad?

Expand Down
Loading