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: 1 addition & 1 deletion src/docs/guide/usage/linter/generated-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Arguments:
## Output

- **`-f`**, **`--format`**=_`ARG`_ —
Use a specific output format. Possible values: `checkstyle`, `default`, `github`, `json`, `junit`, `stylish`, `unix`
Use a specific output format. Possible values: `checkstyle`, `default`, `github`, `gitlab`, `json`, `junit`, `stylish`, `unix`

## Miscellaneous

Expand Down
41 changes: 22 additions & 19 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: 509
- Total number of rules: 512
- Rules turned on by default: 123

**Legend for 'Fixable?' column:**
Expand Down Expand Up @@ -130,7 +130,7 @@ Code that is outright wrong or useless.
| [no-duplicate-head](/docs/guide/usage/linter/rules/nextjs/no-duplicate-head.html) | nextjs | ✅ | |
| [no-head-element](/docs/guide/usage/linter/rules/nextjs/no-head-element.html) | nextjs | ✅ | |
| [no-head-import-in-document](/docs/guide/usage/linter/rules/nextjs/no-head-import-in-document.html) | nextjs | ✅ | |
| [no-img-element](/docs/guide/usage/linter/rules/nextjs/no-img-element.html) | nextjs | ✅ | |
| [no-img-element](/docs/guide/usage/linter/rules/nextjs/no-img-element.html) | nextjs | ✅ | 🚧 |
| [no-page-custom-font](/docs/guide/usage/linter/rules/nextjs/no-page-custom-font.html) | nextjs | ✅ | |
| [no-script-component-in-head](/docs/guide/usage/linter/rules/nextjs/no-script-component-in-head.html) | nextjs | ✅ | |
| [no-styled-jsx-in-document](/docs/guide/usage/linter/rules/nextjs/no-styled-jsx-in-document.html) | nextjs | ✅ | |
Expand Down Expand Up @@ -211,7 +211,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 (65):
## Restriction (66):

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.

Expand Down Expand Up @@ -256,6 +256,7 @@ Lints which prevent the use of language and library features. Must not be enable
| [catch-or-return](/docs/guide/usage/linter/rules/promise/catch-or-return.html) | promise | | |
| [spec-only](/docs/guide/usage/linter/rules/promise/spec-only.html) | promise | | |
| [button-has-type](/docs/guide/usage/linter/rules/react/button-has-type.html) | react | | |
| [forbid-elements](/docs/guide/usage/linter/rules/react/forbid-elements.html) | react | | |
| [jsx-filename-extension](/docs/guide/usage/linter/rules/react/jsx-filename-extension.html) | react | | 🚧 |
| [no-danger](/docs/guide/usage/linter/rules/react/no-danger.html) | react | | |
| [no-unknown-property](/docs/guide/usage/linter/rules/react/no-unknown-property.html) | react | | 🚧 |
Expand Down Expand Up @@ -283,7 +284,7 @@ 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 (31):
## Suspicious (32):

code that is most likely wrong or useless.

Expand All @@ -302,6 +303,7 @@ code that is most likely wrong or useless.
| [no-named-as-default](/docs/guide/usage/linter/rules/import/no-named-as-default.html) | import | | |
| [no-named-as-default-member](/docs/guide/usage/linter/rules/import/no-named-as-default-member.html) | import | | |
| [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 | | |
| [misrefactored-assign-op](/docs/guide/usage/linter/rules/oxc/misrefactored-assign-op.html) | oxc | | 🚧 |
Expand All @@ -314,7 +316,7 @@ code that is most likely wrong or useless.
| [react-in-jsx-scope](/docs/guide/usage/linter/rules/react/react-in-jsx-scope.html) | react | | |
| [style-prop-object](/docs/guide/usage/linter/rules/react/style-prop-object.html) | react | | |
| [no-confusing-non-null-assertion](/docs/guide/usage/linter/rules/typescript/no-confusing-non-null-assertion.html) | typescript | | 🚧 |
| [no-extraneous-class](/docs/guide/usage/linter/rules/typescript/no-extraneous-class.html) | typescript | | |
| [no-extraneous-class](/docs/guide/usage/linter/rules/typescript/no-extraneous-class.html) | typescript | | ⚠️💡 |
| [no-unnecessary-type-constraint](/docs/guide/usage/linter/rules/typescript/no-unnecessary-type-constraint.html) | typescript | | |
| [consistent-function-scoping](/docs/guide/usage/linter/rules/unicorn/consistent-function-scoping.html) | unicorn | | 🚧 |
| [no-accessor-recursion](/docs/guide/usage/linter/rules/unicorn/no-accessor-recursion.html) | unicorn | | |
Expand Down Expand Up @@ -409,7 +411,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 (138):
## Style (140):

Code that should be written in a more idiomatic way.

Expand Down Expand Up @@ -452,6 +454,7 @@ Code that should be written in a more idiomatic way.
| [sort-keys](/docs/guide/usage/linter/rules/eslint/sort-keys.html) | eslint | | 🚧 |
| [vars-on-top](/docs/guide/usage/linter/rules/eslint/vars-on-top.html) | eslint | | |
| [yoda](/docs/guide/usage/linter/rules/eslint/yoda.html) | eslint | | 🛠️ |
| [consistent-type-specifier-style](/docs/guide/usage/linter/rules/import/consistent-type-specifier-style.html) | import | | 🛠️ |
| [exports-last](/docs/guide/usage/linter/rules/import/exports-last.html) | import | | |
| [first](/docs/guide/usage/linter/rules/import/first.html) | import | | 🚧 |
| [group-exports](/docs/guide/usage/linter/rules/import/group-exports.html) | import | | |
Expand Down Expand Up @@ -515,6 +518,7 @@ Code that should be written in a more idiomatic way.
| [consistent-generic-constructors](/docs/guide/usage/linter/rules/typescript/consistent-generic-constructors.html) | typescript | | 🚧 |
| [consistent-indexed-object-style](/docs/guide/usage/linter/rules/typescript/consistent-indexed-object-style.html) | typescript | | 🛠️ |
| [consistent-type-definitions](/docs/guide/usage/linter/rules/typescript/consistent-type-definitions.html) | typescript | | 🛠️ |
| [consistent-type-imports](/docs/guide/usage/linter/rules/typescript/consistent-type-imports.html) | typescript | | 🛠️ |
| [no-empty-interface](/docs/guide/usage/linter/rules/typescript/no-empty-interface.html) | typescript | | |
| [no-inferrable-types](/docs/guide/usage/linter/rules/typescript/no-inferrable-types.html) | typescript | | 🚧 |
| [prefer-for-of](/docs/guide/usage/linter/rules/typescript/prefer-for-of.html) | typescript | | 🚧 |
Expand Down Expand Up @@ -554,19 +558,18 @@ Code that should be written in a more idiomatic way.
| [prefer-to-be-object](/docs/guide/usage/linter/rules/vitest/prefer-to-be-object.html) | vitest | | 🛠️ |
| [prefer-to-be-truthy](/docs/guide/usage/linter/rules/vitest/prefer-to-be-truthy.html) | vitest | | 🛠️ |

## Nursery (10):
## Nursery (9):

New lints that are still under development.

| Rule name | Source | Default | Fixable? |
| ------------------------------------------------------------------------------------------------- | ---------- | ------- | -------- |
| [getter-return](/docs/guide/usage/linter/rules/eslint/getter-return.html) | eslint | | |
| [no-undef](/docs/guide/usage/linter/rules/eslint/no-undef.html) | eslint | | |
| [no-unreachable](/docs/guide/usage/linter/rules/eslint/no-unreachable.html) | eslint | | |
| [export](/docs/guide/usage/linter/rules/import/export.html) | import | | |
| [named](/docs/guide/usage/linter/rules/import/named.html) | import | | |
| [no-map-spread](/docs/guide/usage/linter/rules/oxc/no-map-spread.html) | oxc | | 🛠️💡 |
| [no-return-in-finally](/docs/guide/usage/linter/rules/promise/no-return-in-finally.html) | promise | | |
| [exhaustive-deps](/docs/guide/usage/linter/rules/react/exhaustive-deps.html) | react | | |
| [require-render-return](/docs/guide/usage/linter/rules/react/require-render-return.html) | react | | |
| [consistent-type-imports](/docs/guide/usage/linter/rules/typescript/consistent-type-imports.html) | typescript | | 🛠️ |
| Rule name | Source | Default | Fixable? |
| ---------------------------------------------------------------------------------------- | ------- | ------- | -------- |
| [getter-return](/docs/guide/usage/linter/rules/eslint/getter-return.html) | eslint | | |
| [no-undef](/docs/guide/usage/linter/rules/eslint/no-undef.html) | eslint | | |
| [no-unreachable](/docs/guide/usage/linter/rules/eslint/no-unreachable.html) | eslint | | |
| [export](/docs/guide/usage/linter/rules/import/export.html) | import | | |
| [named](/docs/guide/usage/linter/rules/import/named.html) | import | | |
| [no-map-spread](/docs/guide/usage/linter/rules/oxc/no-map-spread.html) | oxc | | 🛠️💡 |
| [no-return-in-finally](/docs/guide/usage/linter/rules/promise/no-return-in-finally.html) | promise | | |
| [exhaustive-deps](/docs/guide/usage/linter/rules/react/exhaustive-deps.html) | react | | |
| [require-render-return](/docs/guide/usage/linter/rules/react/require-render-return.html) | react | | |
12 changes: 12 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/array-callback-return.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,22 @@ consider using .forEach instead.

### Example

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

```javascript
let foo = [1, 2, 3, 4];
foo.map((a) => {
console.log(a);
});
```

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

```javascript
let foo = [1, 2, 3, 4];
foo.map((a) => {
console.log(a);
return a;
});
```

Expand Down
18 changes: 18 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/default-case-last.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ If a switch statement should have a default clause, it’s considered a best pra

### Example

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

```javascript
switch (foo) {
default:
Expand All @@ -46,6 +48,22 @@ switch (foo) {
}
```

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

```javascript
switch (foo) {
case 1:
bar();
break;
case 2:
qux();
break;
default:
baz();
break;
}
```

## How to use

To **enable** this rule in the CLI or using the config file, you can use:
Expand Down
13 changes: 9 additions & 4 deletions src/docs/guide/usage/linter/rules/eslint/default-param-last.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ Putting default parameter at last allows function calls to omit optional tail ar

### Example

```javascript
// Correct: optional argument can be omitted
function createUser(id, isAdmin = false) {}
createUser("tabby");
Examples of **incorrect** code for this rule:

```javascript
// Incorrect: optional argument can **not** be omitted
function createUser(isAdmin = false, id) {}
createUser(undefined, "tabby");
```

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

```javascript
function createUser(id, isAdmin = false) {}
createUser("tabby");
```

## 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 @@ -27,7 +27,7 @@ This rule disallows constant expressions in the test condition of:
- `if`, `for`, `while`, or `do...while` statement
- `?`: ternary expression

### Example
### Examples

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

Expand Down Expand Up @@ -60,6 +60,16 @@ while (typeof x === "undefined") {
}
```

### Options

#### checkLoops

`{ type: "all" | "allExceptWhileTrue" | "none" | boolean, default: "allExceptWhileTrue" }`

- `"all"` or `true` disallows constant expressions in loops
- `"allExceptWhileTrue"` disallows constant expressions in loops except while loops with expression `true`
- `"none"` or `false` allows constant expressions in loops

## How to use

To **enable** this rule in the CLI or using the config file, you can use:
Expand Down
11 changes: 11 additions & 0 deletions src/docs/guide/usage/linter/rules/eslint/no-debugger.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ They're most commonly an accidental debugging leftover.

### Example

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

```javascript
async function main() {
const data = await getData();
Expand All @@ -35,6 +37,15 @@ async function main() {
}
```

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

```javascript
async function main() {
const data = await getData();
const result = complexCalculation(data);
}
```

## How to use

To **enable** this rule in the CLI or using the config file, you can use:
Expand Down
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/eslint/no-redeclare.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ a = 10;

#### builtinGlobals

`{ type: bool, default: false }`
`{ type: bool, default: true }`

When set `true`, it flags redeclaring built-in globals (e.g., `let Object = 1;`).

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

<script setup>
import { data } from '../version.data.js';
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/import/consistent_type_specifier_style.rs`;
</script>

# import/consistent-type-specifier-style <Badge type="info" text="Style" />

<div class="rule-meta">
<Alert class="fix" type="info">
<span class="emoji">🛠️</span> An auto-fix is available for this rule for some violations.
</Alert>
</div>

### What it does

This rule either enforces or bans the use of inline type-only markers for named imports.

### Why is this bad?

Mixing top-level `import type { Foo } from 'foo'` with inline `{ type Bar }`
forces readers to mentally switch contexts when scanning your imports.
Enforcing one style makes it immediately obvious which imports are types and which are value imports.

### Examples

Examples of incorrect code for the default `prefer-top-level` option:

```typescript
import { type Foo } from "Foo";
import Foo, { type Bar } from "Foo";
```

Examples of correct code for the default option:

```typescript
import type { Foo } from "Foo";
import type Foo, { Bar } from "Foo";
```

Examples of incorrect code for the `prefer-inline` option:

```typescript
import type { Foo } from "Foo";
import type Foo, { Bar } from "Foo";
```

Examples of correct code for the `prefer-inline` option:

```typescript
import { type Foo } from "Foo";
import Foo, { type Bar } from "Foo";
```

## How to use

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

::: code-group

```bash [CLI]
oxlint --deny import/consistent-type-specifier-style --import-plugin
```

```json [Config (.oxlintrc.json)]
{
"plugins": ["import"],
"rules": {
"import/consistent-type-specifier-style": "error"
}
}
```

:::

## References

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
Loading