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
11 changes: 7 additions & 4 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: 445
- Total number of rules: 448
- Rules turned on by default: 97

## Correctness (172):
Expand Down Expand Up @@ -195,7 +195,7 @@ Code that can be written to run faster.
| [jsx-no-new-function-as-prop](/docs/guide/usage/linter/rules/react_perf/jsx-no-new-function-as-prop.html) | react_perf | | |
| [jsx-no-new-object-as-prop](/docs/guide/usage/linter/rules/react_perf/jsx-no-new-object-as-prop.html) | react_perf | | |

## Restriction (58):
## Restriction (59):

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 Down Expand Up @@ -224,6 +224,7 @@ Lints which prevent the use of language and library features. Must not be enable
| [no-default-export](/docs/guide/usage/linter/rules/import/no-default-export.html) | import | | |
| [no-dynamic-require](/docs/guide/usage/linter/rules/import/no-dynamic-require.html) | import | | |
| [no-webpack-loader-syntax](/docs/guide/usage/linter/rules/import/no-webpack-loader-syntax.html) | import | | |
| [unambiguous](/docs/guide/usage/linter/rules/import/unambiguous.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 | | |
Expand Down Expand Up @@ -287,7 +288,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 (72):
## Pedantic (73):

Lints which are rather strict or have occasional false positives.
| Rule name | Source | Default | Fixable? |
Expand Down Expand Up @@ -325,6 +326,7 @@ Lints which are rather strict or have occasional false positives.
| [no-unescaped-entities](/docs/guide/usage/linter/rules/react/no-unescaped-entities.html) | react | | |
| [ban-ts-comment](/docs/guide/usage/linter/rules/typescript/ban-ts-comment.html) | typescript | | 🛠️ |
| [ban-types](/docs/guide/usage/linter/rules/typescript/ban-types.html) | typescript | | 🚧 |
| [no-unsafe-function-type](/docs/guide/usage/linter/rules/typescript/no-unsafe-function-type.html) | typescript | | |
| [prefer-enum-initializers](/docs/guide/usage/linter/rules/typescript/prefer-enum-initializers.html) | typescript | | 🚧 |
| [prefer-ts-expect-error](/docs/guide/usage/linter/rules/typescript/prefer-ts-expect-error.html) | typescript | | 🛠️ |
| [consistent-empty-array-spread](/docs/guide/usage/linter/rules/unicorn/consistent-empty-array-spread.html) | unicorn | | 💡 |
Expand Down Expand Up @@ -365,7 +367,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 (104):
## Style (105):

Code that should be written in a more idiomatic way.
| Rule name | Source | Default | Fixable? |
Expand All @@ -389,6 +391,7 @@ Code that should be written in a more idiomatic way.
| [prefer-object-has-own](/docs/guide/usage/linter/rules/eslint/prefer-object-has-own.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 | | 🚧 |
| [first](/docs/guide/usage/linter/rules/import/first.html) | import | | 🚧 |
| [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
60 changes: 60 additions & 0 deletions src/docs/guide/usage/linter/rules/import/first.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

# import/first <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

Forbids any non-import statements before imports except directives.

### Why is this bad?

Notably, imports are hoisted, which means the imported modules will be evaluated
before any of the statements interspersed between them.
Keeping all imports together at the top of the file may prevent surprises
resulting from this part of the spec

### Examples

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

```js
import { x } from "./foo";
export { x };
import { y } from "./bar";
```

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

```js
import { x } from "./foo";
import { y } from "./bar";
export { x, y };
```

### Options

with `"absolute-import"`:

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

```js
import { x } from "./foo";
import { y } from "bar";
```

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

```js
import { y } from "bar";
import { x } from "./foo";
```

## References

- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/import/first.rs)
48 changes: 48 additions & 0 deletions src/docs/guide/usage/linter/rules/import/unambiguous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

# import/unambiguous <Badge type="info" text="Restriction" />

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

### What it does

Warn if a `module` could be mistakenly parsed as a `script` and not pure ESM module

### Why is this bad?

For ESM-only environments helps to determine files that not pure ESM modules

### Examples

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

```js
function x() {}

(function x() {
return 42;
})();
```

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

```js
import "foo";
function x() {
return 42;
}

export function x() {
return 42;
}

(function x() {
return 42;
})();
export {}; // simple way to mark side-effects-only file as 'module' without any imports/exports
```

## References

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

# typescript/no-unsafe-function-type <Badge type="info" text="Pedantic" />

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

### What it does

Disallow using the unsafe built-in Function type.

### Why is this bad?

TypeScript's built-in Function type allows being called with any number of arguments and returns type any. Function also allows classes or plain objects that happen to possess all properties of the Function class. It's generally better to specify function parameters and return types with the function type syntax.

### Examples

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

```ts
let noParametersOrReturn: Function;
noParametersOrReturn = () => {};

let stringToNumber: Function;
stringToNumber = (text: string) => text.length;

let identity: Function;
identity = (value) => value;
```

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

```ts
let noParametersOrReturn: () => void;
noParametersOrReturn = () => {};

let stringToNumber: (text: string) => number;
stringToNumber = (text) => text.length;

let identity: <T>(value: T) => T;
identity = (value) => value;
```

## References

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