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
13 changes: 11 additions & 2 deletions .vitepress/data/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@
"value": "no-useless-constructor",
"category": "suspicious",
"type_aware": false,
"fix": "fixable_fix",
"fix": "fixable_suggestion",
"default": false,
"docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-useless-constructor.html"
},
Expand Down Expand Up @@ -4382,6 +4382,15 @@
"default": false,
"docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-unnecessary-type-constraint.html"
},
{
"scope": "typescript",
"value": "no-unnecessary-type-conversion",
"category": "nursery",
"type_aware": true,
"fix": "none",
"default": false,
"docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-unnecessary-type-conversion.html"
},
{
"scope": "typescript",
"value": "no-unnecessary-type-parameters",
Expand Down Expand Up @@ -5809,7 +5818,7 @@
"value": "prefer-string-slice",
"category": "pedantic",
"type_aware": false,
"fix": "fixable_fix",
"fix": "conditional_fix",
"default": false,
"docs_url": "https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-string-slice.html"
},
Expand Down
12 changes: 10 additions & 2 deletions src/docs/guide/usage/formatter/generated-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,11 @@ by including a `{ "newlinesBetween": boolean }` marker object in the `groups` li

####### overrides[n].options.sortImports.groups[n]

type: `array | string`
type: `object | array | string`

######## overrides[n].options.sortImports.groups[n].newlinesBetween

type: `boolean`

###### overrides[n].options.sortImports.ignoreCase

Expand Down Expand Up @@ -771,7 +775,11 @@ by including a `{ "newlinesBetween": boolean }` marker object in the `groups` li

#### sortImports.groups[n]

type: `array | string`
type: `object | array | string`

##### sortImports.groups[n].newlinesBetween

type: `boolean`

### sortImports.ignoreCase

Expand Down
4 changes: 2 additions & 2 deletions src/docs/guide/usage/linter/generated-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ search: false
- **`-c`**, **`--config`**=_`<./.oxlintrc.json>`_ &mdash;
Oxlint configuration file

* `.json` config files are supported in all runtimes
* `.json` and `.jsonc` config files are supported in all runtimes
* JavaScript/TypeScript config files are experimental and require running via Node.js
* you can use comments in configuration files.
* tries to be compatible with ESLint v8's format

If not provided, Oxlint will look for `.oxlintrc.json` in the current working directory.
If not provided, Oxlint will look for a `.oxlintrc.json`, `.oxlintrc.jsonc`, or `oxlint.config.ts` file in the current working directory.

- **` --tsconfig`**=_`<./tsconfig.json>`_ &mdash;
TypeScript `tsconfig.json` path for reading path alias and project references for import plugin. If not provided, will look for `tsconfig.json` in the current working directory.
Expand Down
72 changes: 65 additions & 7 deletions src/docs/guide/usage/linter/generated-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ search: false

This configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).

Usage: `oxlint -c oxlintrc.json --import-plugin`

::: danger NOTE

Only the `.json` format is supported. You can use comments in configuration files.

:::
Usage: `oxlint -c oxlintrc.json`

Example

Expand Down Expand Up @@ -57,6 +51,42 @@ Example
}
```

`oxlint.config.ts`

```ts
import { defineConfig } from "oxlint";

export default defineConfig({
plugins: ["import", "typescript", "unicorn"],
env: {
"browser": true
},
globals: {
"foo": "readonly"
},
settings: {
react: {
version: "18.2.0"
},
custom: { option: true }
},
rules: {
"eqeqeq": "warn",
"import/no-cycle": "error",
"react/self-closing-comp": ["error", { "html": false }]
},
overrides: [
{
files: ["*.test.ts", "*.spec.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "off"
}
}
]
}
});
```

## $schema

type: `string`
Expand Down Expand Up @@ -234,6 +264,30 @@ type: `object`

Options for the linter.

### options.denyWarnings

type: `boolean`

Ensure warnings produce a non-zero exit code.

Equivalent to passing `--deny-warnings` on the CLI.

### options.maxWarnings

type: `integer`

Specify a warning threshold. Exits with an error status if warnings exceed this value.

Equivalent to passing `--max-warnings` on the CLI.

### options.reportUnusedDisableDirectives

Report unused disable directives (e.g. `// oxlint-disable-line` or `// eslint-disable-line`).

Equivalent to passing `--report-unused-disable-directives-severity` on the CLI.
CLI flags take precedence over this value when both are set.
Only supported in the root configuration file.

### options.typeAware

type: `boolean`
Expand All @@ -242,6 +296,8 @@ Enable rules that require type information.

Equivalent to passing `--type-aware` on the CLI.

Note that this requires the `oxlint-tsgolint` package to be installed.

### options.typeCheck

type: `boolean`
Expand All @@ -250,6 +306,8 @@ Enable experimental type checking (includes TypeScript compiler diagnostics).

Equivalent to passing `--type-check` on the CLI.

Note that this requires the `oxlint-tsgolint` package to be installed.

## overrides

type: `array`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "eslint/no-useless-constructor"
category: "Suspicious"
default: false
type_aware: false
fix: "fixable_fix"
fix: "fixable_suggestion"
---

<!-- This file is auto-generated by tasks/website_linter/src/rules/doc_page.rs. Do not edit it manually. -->
Expand Down
26 changes: 25 additions & 1 deletion src/docs/guide/usage/linter/rules/import/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ In order to provide a consistent use of file extensions across your code base, t

### Why is this bad?

ESM-based file resolve algorithms (e.g., the one that Vite provides) recommend specifying the file extension to improve performance.
ESM-based file resolve algorithms (e.g., the one that Vite provides) recommend
specifying the file extension to improve performance. Without extensions, the
bundler must check for various possible file extensions, which can slow down
the build process on large projects. In addition, common ESM environments
(such as browsers and Node.js) typically require fully specified relative imports,
which means extensionless imports are not supported there.

For personal preference and compatibility reasons, the rule also allows configuration
to _disallow_ extensions in imports. This is generally not recommended, but it can be
done if preferred.

### Examples

Expand Down Expand Up @@ -83,6 +92,21 @@ import foo from "./foo"; // ✓ OK - no extension
import bar from "lodash/fp"; // ✓ OK - package import, ignored (ignorePackages sets this to true)
```

### Differences compared to `eslint-plugin-import`

If you see differences between this rule implementation and the original `eslint-plugin-import`
rule, please note that there are some intentional, inherent differences in the behavior of this
rule and the original.

Oxlint understands and can resolve TypeScript paths out-of-the-box. If your ESLint
configuration did not include `eslint-import-resolver-typescript` or similar, then the original
rule will not have been able to resolve TypeScript paths correctly, and so the behavior
between ESLint and Oxlint may differ. Generally, this means that Oxlint will catch _more_
valid violations than the original rule, though this depends on the specific configuration.

Oxlint is also able to resolve multiple `tsconfig.json` files in a single repo, and so in a
monorepo setup will be more capable with regards to resolving file paths.

## Configuration

This rule accepts three types of configuration:
Expand Down
12 changes: 11 additions & 1 deletion src/docs/guide/usage/linter/rules/import/no-named-as-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Given
```javascript
// foo.js
export default "foo";
export const bar = "baz";
export const bar = true;
```

Examples of **incorrect** code for this rule:
Expand All @@ -52,6 +52,16 @@ Examples of **correct** code for this rule:
import foo from "./foo.js";
```

### Differences compared to `eslint-plugin-import`

If you see differences between this rule implementation and the original `eslint-plugin-import`
rule, please note that the behavior may differ in certain cases due to differences in how
module resolution is implemented and configured.

For example, the original rule may require additional resolver configuration to handle certain
imports, especially when TypeScript paths are used or in monorepo setups with multiple
`tsconfig.json` files.

## How to use

To **enable** this rule using the config file or in the CLI, you can use:
Expand Down
22 changes: 21 additions & 1 deletion src/docs/guide/usage/linter/rules/react/forbid-dom-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,30 @@ Examples:

#### forbid[n]

type: `string`
type: `object | string`

A forbidden prop, either as a plain prop name string or with options.

##### forbid[n].disallowedFor

type: `string[]`

A list of DOM element names (e.g. `["div", "span"]`) on which this
prop is forbidden. If empty or omitted, the prop is forbidden on all
DOM elements.

##### forbid[n].message

type: `string`

A custom message to display when this prop is used.

##### forbid[n].propName

type: `string`

The name of the prop to forbid.

## How to use

To **enable** this rule using the config file or in the CLI, you can use:
Expand Down
23 changes: 22 additions & 1 deletion src/docs/guide/usage/linter/rules/typescript/no-deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Use this to allow specific deprecated APIs that you intentionally want to contin

#### allow[n]

type: `string`
type: `object | string`

Type or value specifier for matching specific declarations

Expand Down Expand Up @@ -108,6 +108,27 @@ Supports four types of specifiers:
{ "from": "package", "name": ["Observable", "Subject"], "package": "rxjs" }
```

##### allow[n].from

type: `"file"`

##### allow[n].name

type: `array | string`

Name specifier that can be a single string or array of strings

###### allow[n].name[n]

type: `string`

##### allow[n].path

type: `string`

Optional file path to specify where the types or values must be declared.
If omitted, all files will be matched.

## How to use

To **enable** this rule using the config file or in the CLI, you can use:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Allows specific calls to be ignored, specified as type or value specifiers.

#### allowForKnownSafeCalls[n]

type: `string`
type: `object | string`

Type or value specifier for matching specific declarations

Expand Down Expand Up @@ -131,6 +131,27 @@ Supports four types of specifiers:
{ "from": "package", "name": ["Observable", "Subject"], "package": "rxjs" }
```

##### allowForKnownSafeCalls[n].from

type: `"file"`

##### allowForKnownSafeCalls[n].name

type: `array | string`

Name specifier that can be a single string or array of strings

###### allowForKnownSafeCalls[n].name[n]

type: `string`

##### allowForKnownSafeCalls[n].path

type: `string`

Optional file path to specify where the types or values must be declared.
If omitted, all files will be matched.

### allowForKnownSafePromises

type: `array`
Expand All @@ -141,7 +162,7 @@ Allows specific Promise types to be ignored, specified as type or value specifie

#### allowForKnownSafePromises[n]

type: `string`
type: `object | string`

Type or value specifier for matching specific declarations

Expand Down Expand Up @@ -175,6 +196,27 @@ Supports four types of specifiers:
{ "from": "package", "name": ["Observable", "Subject"], "package": "rxjs" }
```

##### allowForKnownSafePromises[n].from

type: `"file"`

##### allowForKnownSafePromises[n].name

type: `array | string`

Name specifier that can be a single string or array of strings

###### allowForKnownSafePromises[n].name[n]

type: `string`

##### allowForKnownSafePromises[n].path

type: `string`

Optional file path to specify where the types or values must be declared.
If omitted, all files will be matched.

### checkThenables

type: `boolean`
Expand Down
Loading