diff --git a/src/docs/guide/usage/linter/generated-cli.md b/src/docs/guide/usage/linter/generated-cli.md index 66acc05dfb7..9ce07466fac 100644 --- a/src/docs/guide/usage/linter/generated-cli.md +++ b/src/docs/guide/usage/linter/generated-cli.md @@ -63,6 +63,8 @@ Arguments: Enable the React performance plugin and detect rendering performance problems - **` --promise-plugin`** — Enable the promise plugin and detect promise usage problems +- **` --node-plugin`** — + Enable the node plugin and detect node usage problems ## Fix Problems diff --git a/src/docs/guide/usage/linter/generated-config.md b/src/docs/guide/usage/linter/generated-config.md index 9624abd6923..2e271988957 100644 --- a/src/docs/guide/usage/linter/generated-config.md +++ b/src/docs/guide/usage/linter/generated-config.md @@ -2,7 +2,7 @@ This configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`). -Usage: `oxlint -c oxlintrc.json` +Usage: `oxlint -c oxlintrc.json --import-plugin` ::: danger NOTE @@ -24,7 +24,8 @@ Example }, "settings": {}, "rules": { - "eqeqeq": "warn" + "eqeqeq": "warn", + "import/no-cycle": "error" } } ``` diff --git a/src/docs/guide/usage/linter/generated-rules.md b/src/docs/guide/usage/linter/generated-rules.md index 5fe07e95d9a..cc7ba67029a 100644 --- a/src/docs/guide/usage/linter/generated-rules.md +++ b/src/docs/guide/usage/linter/generated-rules.md @@ -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: 419 -- Rules turned on by default: 93 +- Total number of rules: 427 +- Rules turned on by default: 94 -## Correctness (166): +## Correctness (167): Code that is outright wrong or useless. | Rule name | Source | Default | Fixable? | @@ -34,10 +34,11 @@ Code that is outright wrong or useless. | [no-func-assign](/docs/guide/usage/linter/rules/eslint/no-func-assign.html) | eslint | ✅ | | | [no-global-assign](/docs/guide/usage/linter/rules/eslint/no-global-assign.html) | eslint | ✅ | | | [no-import-assign](/docs/guide/usage/linter/rules/eslint/no-import-assign.html) | eslint | ✅ | | +| [no-invalid-regexp](/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.html) | eslint | ✅ | | | [no-irregular-whitespace](/docs/guide/usage/linter/rules/eslint/no-irregular-whitespace.html) | eslint | ✅ | | | [no-loss-of-precision](/docs/guide/usage/linter/rules/eslint/no-loss-of-precision.html) | eslint | ✅ | | | [no-new-native-nonconstructor](/docs/guide/usage/linter/rules/eslint/no-new-native-nonconstructor.html) | eslint | ✅ | | -| [no-nonoctal-decimal-escape](/docs/guide/usage/linter/rules/eslint/no-nonoctal-decimal-escape.html) | eslint | ✅ | | +| [no-nonoctal-decimal-escape](/docs/guide/usage/linter/rules/eslint/no-nonoctal-decimal-escape.html) | eslint | ✅ | 🚧 | | [no-obj-calls](/docs/guide/usage/linter/rules/eslint/no-obj-calls.html) | eslint | ✅ | | | [no-self-assign](/docs/guide/usage/linter/rules/eslint/no-self-assign.html) | eslint | ✅ | | | [no-setter-return](/docs/guide/usage/linter/rules/eslint/no-setter-return.html) | eslint | ✅ | | @@ -123,7 +124,7 @@ Code that is outright wrong or useless. | [no-styled-jsx-in-document](/docs/guide/usage/linter/rules/nextjs/no-styled-jsx-in-document.html) | nextjs | | | | [no-sync-scripts](/docs/guide/usage/linter/rules/nextjs/no-sync-scripts.html) | nextjs | | | | [no-title-in-document-head](/docs/guide/usage/linter/rules/nextjs/no-title-in-document-head.html) | nextjs | | | -| [no-typos](/docs/guide/usage/linter/rules/nextjs/no-typos.html) | nextjs | | | +| [no-typos](/docs/guide/usage/linter/rules/nextjs/no-typos.html) | nextjs | | 🚧 | | [no-unwanted-polyfillio](/docs/guide/usage/linter/rules/nextjs/no-unwanted-polyfillio.html) | nextjs | | | | [bad-array-method-on-arguments](/docs/guide/usage/linter/rules/oxc/bad-array-method-on-arguments.html) | oxc | ✅ | | | [bad-char-at-comparison](/docs/guide/usage/linter/rules/oxc/bad-char-at-comparison.html) | oxc | ✅ | | @@ -133,7 +134,7 @@ Code that is outright wrong or useless. | [bad-replace-all-arg](/docs/guide/usage/linter/rules/oxc/bad-replace-all-arg.html) | oxc | ✅ | | | [const-comparisons](/docs/guide/usage/linter/rules/oxc/const-comparisons.html) | oxc | ✅ | | | [double-comparisons](/docs/guide/usage/linter/rules/oxc/double-comparisons.html) | oxc | ✅ | 🛠️ | -| [erasing-op](/docs/guide/usage/linter/rules/oxc/erasing-op.html) | oxc | ✅ | | +| [erasing-op](/docs/guide/usage/linter/rules/oxc/erasing-op.html) | oxc | ✅ | 💡 | | [missing-throw](/docs/guide/usage/linter/rules/oxc/missing-throw.html) | oxc | ✅ | 💡 | | [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 | ✅ | ⚠️🛠️️ | @@ -165,17 +166,17 @@ Code that is outright wrong or useless. | [no-document-cookie](/docs/guide/usage/linter/rules/unicorn/no-document-cookie.html) | unicorn | ✅ | | | [no-empty-file](/docs/guide/usage/linter/rules/unicorn/no-empty-file.html) | unicorn | ✅ | | | [no-invalid-remove-event-listener](/docs/guide/usage/linter/rules/unicorn/no-invalid-remove-event-listener.html) | unicorn | ✅ | | -| [no-new-array](/docs/guide/usage/linter/rules/unicorn/no-new-array.html) | unicorn | ✅ | | +| [no-new-array](/docs/guide/usage/linter/rules/unicorn/no-new-array.html) | unicorn | ✅ | 🚧 | | [no-single-promise-in-promise-methods](/docs/guide/usage/linter/rules/unicorn/no-single-promise-in-promise-methods.html) | unicorn | ✅ | 🛠️ | | [no-thenable](/docs/guide/usage/linter/rules/unicorn/no-thenable.html) | unicorn | ✅ | | | [no-unnecessary-await](/docs/guide/usage/linter/rules/unicorn/no-unnecessary-await.html) | unicorn | ✅ | 🛠️ | | [no-useless-fallback-in-spread](/docs/guide/usage/linter/rules/unicorn/no-useless-fallback-in-spread.html) | unicorn | ✅ | 🛠️ | -| [no-useless-length-check](/docs/guide/usage/linter/rules/unicorn/no-useless-length-check.html) | unicorn | ✅ | | +| [no-useless-length-check](/docs/guide/usage/linter/rules/unicorn/no-useless-length-check.html) | unicorn | ✅ | 🚧 | | [no-useless-spread](/docs/guide/usage/linter/rules/unicorn/no-useless-spread.html) | unicorn | ✅ | 🛠️ | | [prefer-set-size](/docs/guide/usage/linter/rules/unicorn/prefer-set-size.html) | unicorn | ✅ | 🛠️ | | [prefer-string-starts-ends-with](/docs/guide/usage/linter/rules/unicorn/prefer-string-starts-ends-with.html) | unicorn | ✅ | 🛠️ | | [no-conditional-tests](/docs/guide/usage/linter/rules/vitest/no-conditional-tests.html) | vitest | | | -| [require-local-test-context-for-concurrent-snapshots](/docs/guide/usage/linter/rules/vitest/require-local-test-context-for-concurrent-snapshots.html) | vitest | | | +| [require-local-test-context-for-concurrent-snapshots](/docs/guide/usage/linter/rules/vitest/require-local-test-context-for-concurrent-snapshots.html) | vitest | | 🚧 | ## Perf (6): @@ -189,12 +190,13 @@ 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 (55): +## Restriction (57): 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? | | --------------------------------------- | ---------- | ------- | -------- | | [default-case](/docs/guide/usage/linter/rules/eslint/default-case.html) | eslint | | | +| [no-alert](/docs/guide/usage/linter/rules/eslint/no-alert.html) | eslint | | | | [no-bitwise](/docs/guide/usage/linter/rules/eslint/no-bitwise.html) | eslint | | | | [no-console](/docs/guide/usage/linter/rules/eslint/no-console.html) | eslint | | | | [no-div-regex](/docs/guide/usage/linter/rules/eslint/no-div-regex.html) | eslint | | 🛠️ | @@ -214,6 +216,7 @@ Lints which prevent the use of language and library features. Must not be enable | [no-amd](/docs/guide/usage/linter/rules/import/no-amd.html) | import | | | | [no-cycle](/docs/guide/usage/linter/rules/import/no-cycle.html) | import | | | | [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 | | | | [check-access](/docs/guide/usage/linter/rules/jsdoc/check-access.html) | jsdoc | | | | [empty-tags](/docs/guide/usage/linter/rules/jsdoc/empty-tags.html) | jsdoc | | | @@ -228,7 +231,7 @@ Lints which prevent the use of language and library features. Must not be enable | [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 | | | | [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 | | | +| [no-unknown-property](/docs/guide/usage/linter/rules/react/no-unknown-property.html) | react | | 🚧 | | [explicit-function-return-type](/docs/guide/usage/linter/rules/typescript/explicit-function-return-type.html) | typescript | | | | [no-dynamic-delete](/docs/guide/usage/linter/rules/typescript/no-dynamic-delete.html) | typescript | | | | [no-explicit-any](/docs/guide/usage/linter/rules/typescript/no-explicit-any.html) | typescript | | 🛠️ | @@ -240,7 +243,7 @@ Lints which prevent the use of language and library features. Must not be enable | [prefer-literal-enum-member](/docs/guide/usage/linter/rules/typescript/prefer-literal-enum-member.html) | typescript | | | | [no-abusive-eslint-disable](/docs/guide/usage/linter/rules/unicorn/no-abusive-eslint-disable.html) | unicorn | | | | [no-anonymous-default-export](/docs/guide/usage/linter/rules/unicorn/no-anonymous-default-export.html) | unicorn | | | -| [no-array-for-each](/docs/guide/usage/linter/rules/unicorn/no-array-for-each.html) | unicorn | | | +| [no-array-for-each](/docs/guide/usage/linter/rules/unicorn/no-array-for-each.html) | unicorn | | 🚧 | | [no-array-reduce](/docs/guide/usage/linter/rules/unicorn/no-array-reduce.html) | unicorn | | | | [no-length-as-slice-end](/docs/guide/usage/linter/rules/unicorn/no-length-as-slice-end.html) | unicorn | | 🛠️ | | [no-magic-array-flat-depth](/docs/guide/usage/linter/rules/unicorn/no-magic-array-flat-depth.html) | unicorn | | | @@ -248,7 +251,7 @@ Lints which prevent the use of language and library features. Must not be enable | [no-process-exit](/docs/guide/usage/linter/rules/unicorn/no-process-exit.html) | unicorn | | | | [prefer-modern-math-apis](/docs/guide/usage/linter/rules/unicorn/prefer-modern-math-apis.html) | unicorn | | 🚧 | | [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 | | | +| [prefer-number-properties](/docs/guide/usage/linter/rules/unicorn/prefer-number-properties.html) | unicorn | | 🚧 | ## Suspicious (18): @@ -264,17 +267,17 @@ code that is most likely wrong or useless. | [no-self-import](/docs/guide/usage/linter/rules/import/no-self-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 | | | +| [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 | | | | [jsx-no-comment-textnodes](/docs/guide/usage/linter/rules/react/jsx-no-comment-textnodes.html) | react | | | | [react-in-jsx-scope](/docs/guide/usage/linter/rules/react/react-in-jsx-scope.html) | react | | | -| [no-confusing-non-null-assertion](/docs/guide/usage/linter/rules/typescript/no-confusing-non-null-assertion.html) | typescript | | | +| [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-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 | | 🚧 | -| [prefer-add-event-listener](/docs/guide/usage/linter/rules/unicorn/prefer-add-event-listener.html) | unicorn | | | +| [prefer-add-event-listener](/docs/guide/usage/linter/rules/unicorn/prefer-add-event-listener.html) | unicorn | | 🚧 | -## Pedantic (68): +## Pedantic (70): Lints which are rather strict or have occasional false positives. | Rule name | Source | Default | Fixable? | @@ -294,6 +297,8 @@ Lints which are rather strict or have occasional false positives. | [no-self-compare](/docs/guide/usage/linter/rules/eslint/no-self-compare.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 | | | | [no-conditional-in-test](/docs/guide/usage/linter/rules/jest/no-conditional-in-test.html) | jest | | | @@ -308,9 +313,9 @@ Lints which are rather strict or have occasional false positives. | [jsx-no-useless-fragment](/docs/guide/usage/linter/rules/react/jsx-no-useless-fragment.html) | react | | | | [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 | | | +| [ban-types](/docs/guide/usage/linter/rules/typescript/ban-types.html) | typescript | | 🚧 | | [no-duplicate-enum-values](/docs/guide/usage/linter/rules/typescript/no-duplicate-enum-values.html) | typescript | | | -| [prefer-enum-initializers](/docs/guide/usage/linter/rules/typescript/prefer-enum-initializers.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 | | 🛠️ | | [escape-case](/docs/guide/usage/linter/rules/unicorn/escape-case.html) | unicorn | | 🛠️ | | [explicit-length-check](/docs/guide/usage/linter/rules/unicorn/explicit-length-check.html) | unicorn | | 🛠️ | @@ -318,27 +323,27 @@ Lints which are rather strict or have occasional false positives. | [no-hex-escape](/docs/guide/usage/linter/rules/unicorn/no-hex-escape.html) | unicorn | | 🛠️ | | [no-instanceof-array](/docs/guide/usage/linter/rules/unicorn/no-instanceof-array.html) | unicorn | | 🛠️ | | [no-lonely-if](/docs/guide/usage/linter/rules/unicorn/no-lonely-if.html) | unicorn | | | -| [no-negated-condition](/docs/guide/usage/linter/rules/unicorn/no-negated-condition.html) | unicorn | | | -| [no-negation-in-equality-check](/docs/guide/usage/linter/rules/unicorn/no-negation-in-equality-check.html) | unicorn | | | -| [no-new-buffer](/docs/guide/usage/linter/rules/unicorn/no-new-buffer.html) | unicorn | | | +| [no-negated-condition](/docs/guide/usage/linter/rules/unicorn/no-negated-condition.html) | unicorn | | 🚧 | +| [no-negation-in-equality-check](/docs/guide/usage/linter/rules/unicorn/no-negation-in-equality-check.html) | unicorn | | 🚧 | +| [no-new-buffer](/docs/guide/usage/linter/rules/unicorn/no-new-buffer.html) | unicorn | | 🚧 | | [no-object-as-default-parameter](/docs/guide/usage/linter/rules/unicorn/no-object-as-default-parameter.html) | unicorn | | | | [no-static-only-class](/docs/guide/usage/linter/rules/unicorn/no-static-only-class.html) | unicorn | | | | [no-this-assignment](/docs/guide/usage/linter/rules/unicorn/no-this-assignment.html) | unicorn | | | -| [no-typeof-undefined](/docs/guide/usage/linter/rules/unicorn/no-typeof-undefined.html) | unicorn | | | +| [no-typeof-undefined](/docs/guide/usage/linter/rules/unicorn/no-typeof-undefined.html) | unicorn | | 🚧 | | [no-unreadable-iife](/docs/guide/usage/linter/rules/unicorn/no-unreadable-iife.html) | unicorn | | | | [no-useless-promise-resolve-reject](/docs/guide/usage/linter/rules/unicorn/no-useless-promise-resolve-reject.html) | unicorn | | 🛠️ | -| [no-useless-switch-case](/docs/guide/usage/linter/rules/unicorn/no-useless-switch-case.html) | unicorn | | | +| [no-useless-switch-case](/docs/guide/usage/linter/rules/unicorn/no-useless-switch-case.html) | unicorn | | 🚧 | | [no-useless-undefined](/docs/guide/usage/linter/rules/unicorn/no-useless-undefined.html) | unicorn | | 🛠️ | | [prefer-array-flat](/docs/guide/usage/linter/rules/unicorn/prefer-array-flat.html) | unicorn | | 🛠️ | | [prefer-array-some](/docs/guide/usage/linter/rules/unicorn/prefer-array-some.html) | unicorn | | 🛠️ | -| [prefer-blob-reading-methods](/docs/guide/usage/linter/rules/unicorn/prefer-blob-reading-methods.html) | unicorn | | | +| [prefer-blob-reading-methods](/docs/guide/usage/linter/rules/unicorn/prefer-blob-reading-methods.html) | unicorn | | 🚧 | | [prefer-code-point](/docs/guide/usage/linter/rules/unicorn/prefer-code-point.html) | unicorn | | 🛠️ | | [prefer-date-now](/docs/guide/usage/linter/rules/unicorn/prefer-date-now.html) | unicorn | | 🛠️ | | [prefer-dom-node-append](/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-append.html) | unicorn | | 🛠️ | -| [prefer-dom-node-dataset](/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-dataset.html) | unicorn | | | +| [prefer-dom-node-dataset](/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-dataset.html) | unicorn | | 🚧 | | [prefer-dom-node-remove](/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-remove.html) | unicorn | | | | [prefer-event-target](/docs/guide/usage/linter/rules/unicorn/prefer-event-target.html) | unicorn | | | -| [prefer-math-trunc](/docs/guide/usage/linter/rules/unicorn/prefer-math-trunc.html) | unicorn | | | +| [prefer-math-trunc](/docs/guide/usage/linter/rules/unicorn/prefer-math-trunc.html) | unicorn | | 🚧 | | [prefer-native-coercion-functions](/docs/guide/usage/linter/rules/unicorn/prefer-native-coercion-functions.html) | unicorn | | 🚧 | | [prefer-prototype-methods](/docs/guide/usage/linter/rules/unicorn/prefer-prototype-methods.html) | unicorn | | 🛠️ | | [prefer-query-selector](/docs/guide/usage/linter/rules/unicorn/prefer-query-selector.html) | unicorn | | 🛠️ | @@ -348,7 +353,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 (96): +## Style (99): Code that should be written in a more idiomatic way. | Rule name | Source | Default | Fixable? | @@ -360,6 +365,7 @@ Code that should be written in a more idiomatic way. | [max-params](/docs/guide/usage/linter/rules/eslint/max-params.html) | eslint | | | | [no-continue](/docs/guide/usage/linter/rules/eslint/no-continue.html) | eslint | | | | [no-label-var](/docs/guide/usage/linter/rules/eslint/no-label-var.html) | eslint | | | +| [no-magic-numbers](/docs/guide/usage/linter/rules/eslint/no-magic-numbers.html) | eslint | | 🚧 | | [no-multi-str](/docs/guide/usage/linter/rules/eslint/no-multi-str.html) | eslint | | | | [no-new-func](/docs/guide/usage/linter/rules/eslint/no-new-func.html) | eslint | | | | [no-script-url](/docs/guide/usage/linter/rules/eslint/no-script-url.html) | eslint | | | @@ -404,22 +410,24 @@ Code that should be written in a more idiomatic way. | [prefer-todo](/docs/guide/usage/linter/rules/jest/prefer-todo.html) | jest | | 🛠️ | | [require-hook](/docs/guide/usage/linter/rules/jest/require-hook.html) | jest | | | | [require-top-level-describe](/docs/guide/usage/linter/rules/jest/require-top-level-describe.html) | jest | | | +| [no-exports-assign](/docs/guide/usage/linter/rules/node/no-exports-assign.html) | node | | 🛠️ | | [param-names](/docs/guide/usage/linter/rules/promise/param-names.html) | promise | | | | [prefer-await-to-then](/docs/guide/usage/linter/rules/promise/prefer-await-to-then.html) | promise | | | | [jsx-boolean-value](/docs/guide/usage/linter/rules/react/jsx-boolean-value.html) | react | | 🛠️ | | [jsx-curly-brace-presence](/docs/guide/usage/linter/rules/react/jsx-curly-brace-presence.html) | react | | | | [no-set-state](/docs/guide/usage/linter/rules/react/no-set-state.html) | react | | | | [prefer-es6-class](/docs/guide/usage/linter/rules/react/prefer-es6-class.html) | react | | | +| [self-closing-comp](/docs/guide/usage/linter/rules/react/self-closing-comp.html) | react | | 🚧 | | [adjacent-overload-signatures](/docs/guide/usage/linter/rules/typescript/adjacent-overload-signatures.html) | typescript | | | | [array-type](/docs/guide/usage/linter/rules/typescript/array-type.html) | typescript | | 🛠️ | | [ban-tslint-comment](/docs/guide/usage/linter/rules/typescript/ban-tslint-comment.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 | | 🛠️ | | [no-empty-interface](/docs/guide/usage/linter/rules/typescript/no-empty-interface.html) | typescript | | | -| [prefer-for-of](/docs/guide/usage/linter/rules/typescript/prefer-for-of.html) | typescript | | | +| [prefer-for-of](/docs/guide/usage/linter/rules/typescript/prefer-for-of.html) | typescript | | 🚧 | | [prefer-function-type](/docs/guide/usage/linter/rules/typescript/prefer-function-type.html) | typescript | | 🛠️ | | [prefer-namespace-keyword](/docs/guide/usage/linter/rules/typescript/prefer-namespace-keyword.html) | typescript | | 🛠️ | -| [catch-error-name](/docs/guide/usage/linter/rules/unicorn/catch-error-name.html) | unicorn | | | +| [catch-error-name](/docs/guide/usage/linter/rules/unicorn/catch-error-name.html) | unicorn | | 🚧 | | [empty-brace-spaces](/docs/guide/usage/linter/rules/unicorn/empty-brace-spaces.html) | unicorn | | 🛠️ | | [error-message](/docs/guide/usage/linter/rules/unicorn/error-message.html) | unicorn | | | | [filename-case](/docs/guide/usage/linter/rules/unicorn/filename-case.html) | unicorn | | | @@ -432,9 +440,9 @@ Code that should be written in a more idiomatic way. | [numeric-separators-style](/docs/guide/usage/linter/rules/unicorn/numeric-separators-style.html) | unicorn | | 🛠️ | | [prefer-array-flat-map](/docs/guide/usage/linter/rules/unicorn/prefer-array-flat-map.html) | unicorn | | 🛠️ | | [prefer-dom-node-text-content](/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-text-content.html) | unicorn | | 🛠️ | -| [prefer-includes](/docs/guide/usage/linter/rules/unicorn/prefer-includes.html) | unicorn | | | -| [prefer-logical-operator-over-ternary](/docs/guide/usage/linter/rules/unicorn/prefer-logical-operator-over-ternary.html) | unicorn | | | -| [prefer-modern-dom-apis](/docs/guide/usage/linter/rules/unicorn/prefer-modern-dom-apis.html) | unicorn | | | +| [prefer-includes](/docs/guide/usage/linter/rules/unicorn/prefer-includes.html) | unicorn | | 🚧 | +| [prefer-logical-operator-over-ternary](/docs/guide/usage/linter/rules/unicorn/prefer-logical-operator-over-ternary.html) | unicorn | | 🚧 | +| [prefer-modern-dom-apis](/docs/guide/usage/linter/rules/unicorn/prefer-modern-dom-apis.html) | unicorn | | 🚧 | | [prefer-optional-catch-binding](/docs/guide/usage/linter/rules/unicorn/prefer-optional-catch-binding.html) | unicorn | | 🛠️ | | [prefer-reflect-apply](/docs/guide/usage/linter/rules/unicorn/prefer-reflect-apply.html) | unicorn | | | | [prefer-spread](/docs/guide/usage/linter/rules/unicorn/prefer-spread.html) | unicorn | | 🛠️ | diff --git a/src/docs/guide/usage/linter/rules/eslint/no-alert.md b/src/docs/guide/usage/linter/rules/eslint/no-alert.md new file mode 100644 index 00000000000..7561afcb2ab --- /dev/null +++ b/src/docs/guide/usage/linter/rules/eslint/no-alert.md @@ -0,0 +1,46 @@ + + +# eslint/no-alert + +
+
+ +### What it does + +Disallow the use of alert, confirm, and prompt + +### Why is this bad? + +JavaScript’s alert, confirm, and prompt functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation. +Furthermore, alert is often used while debugging code, which should be removed before deployment to production. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +alert("here!"); + +confirm("Are you sure?"); + +prompt("What's your name?", "John Doe"); +``` + +Examples of **correct** code for this rule: + +```js +customAlert("Something happened!"); + +customConfirm("Are you sure?"); + +customPrompt("Who are you?"); + +function foo() { + var alert = myCustomLib.customAlert; + alert(); +} +``` + +## References + +- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_alert.rs) diff --git a/src/docs/guide/usage/linter/rules/eslint/no-await-in-loop.md b/src/docs/guide/usage/linter/rules/eslint/no-await-in-loop.md index f68c8f15152..7696f07d874 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-await-in-loop.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-await-in-loop.md @@ -16,7 +16,7 @@ Instead, they are being run in series, which can lead to poorer performance. ### Example -Bad: +Examples of **incorrect** code for this rule: ```javascript async function bad() { @@ -26,7 +26,7 @@ async function bad() { } ``` -Good: +Examples of **correct** code for this rule: ```javascript async function good() { diff --git a/src/docs/guide/usage/linter/rules/eslint/no-constructor-return.md b/src/docs/guide/usage/linter/rules/eslint/no-constructor-return.md index cb9df0af434..ee3d16fc6e9 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-constructor-return.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-constructor-return.md @@ -16,7 +16,7 @@ Forbidding this pattern prevents mistakes resulting from unfamiliarity with the ### Example -Bad: +Examples of **incorrect** code for this rule: ```rust class C { @@ -24,7 +24,7 @@ class C { } ``` -Good: +Examples of **correct** code for this rule: ```rust class C { diff --git a/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md b/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md new file mode 100644 index 00000000000..f74008748a9 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/eslint/no-invalid-regexp.md @@ -0,0 +1,40 @@ + + +# eslint/no-invalid-regexp + +
+ + This rule is turned on by default. + +
+ +### What it does + +Disallow invalid regular expression strings in RegExp constructors. + +### Why is this bad? + +An invalid pattern in a regular expression literal is a SyntaxError when the code is parsed, +but an invalid string in RegExp constructors throws a SyntaxError only when the code is executed. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +RegExp("["); +RegExp(".", "z"); +new RegExp("\\"); +``` + +Examples of **correct** code for this rule: + +```js +RegExp("."); +new RegExp(); +this.RegExp("["); +``` + +## References + +- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_invalid_regexp.rs) diff --git a/src/docs/guide/usage/linter/rules/eslint/no-magic-numbers.md b/src/docs/guide/usage/linter/rules/eslint/no-magic-numbers.md new file mode 100644 index 00000000000..c705a4322b6 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/eslint/no-magic-numbers.md @@ -0,0 +1,137 @@ + + +# eslint/no-magic-numbers + +
+ +🚧 An auto-fix is still under development. + +
+ +### What it does + +The no-magic-numbers rule aims to make code more readable and refactoring easier by ensuring that special numbers are declared as constants to make their meaning explicit. +The current implementation does not support BigInt numbers inside array indexes. + +### Why is this bad? + +‘Magic numbers’ are numbers that occur multiple times in code without an explicit meaning. They should preferably be replaced by named constants. + +### Examples + +Examples of **incorrect** code for this rule: + +```javascript +var dutyFreePrice = 100; +var finalPrice = dutyFreePrice + dutyFreePrice * 0.25; +``` + +Examples of **correct** code for this rule with option "ignore": + +```javascript +/*typescript no-magic-numbers: ["error", { "ignore": [1] }]*/ +var data = ["foo", "bar", "baz"]; +var dataLast = data.length && data[data.length - 1]; +``` + +Examples of **correct** code for this rule with option "ignoreArrayIndexes": + +```javascript +/*typescript no-magic-numbers: ["error", { "ignoreArrayIndexes": true }]*/ +var item = data[2]; +data[100] = a; +f(data[0]); +a = data[-0]; // same as data[0], -0 will be coerced to "0" +a = data[0xab]; +a = data[5.6e1]; +a = data[4294967294]; // max array index +``` + +Examples of **correct** code for this rule with option "ignoreDefaultValues": + +```javascript +/*typescript no-magic-numbers: ["error", { "ignoreDefaultValues": true }]*/ +const { tax = 0.25 } = accountancy; +function mapParallel(concurrency = 3) { + /***/ +} +``` + +Examples of **correct** code for this rule with option "ignoreClassFieldInitialValues": + +```javascript +/*typescript no-magic-numbers: ["error", { "ignoreClassFieldInitialValues": true }]*/ +class C { + foo = 2; + bar = -3; + #baz = 4; + static qux = 5; +} +``` + +Examples of **incorrect** code for this rule with option "enforceConst": + +```javascript +/*typescript no-magic-numbers: ["error", { "enforceConst": true }]*/ +var TAX = 0.25; +``` + +Examples of **incorrect** code for this rule with option "detectObjects": + +```javascript +/*typescript no-magic-numbers: ["error", { "detectObjects": true }]*/ +var magic = { + tax: 0.25, +}; +``` + +Examples of **correct** code for this rule with option "detectObjects": + +```javascript +/*typescript no-magic-numbers: ["error", { "detectObjects": true }]*/ +var TAX = 0.25; + +var magic = { + tax: TAX, +}; +``` + +Examples of **correct** code for this rule with option "ignoreEnums": + +```typescript +/*typescript no-magic-numbers: ["error", { "ignoreEnums": true }]*/ +enum foo { + SECOND = 1000, +} +``` + +Examples of **correct** code for this rule with option "ignoreNumericLiteralTypes": + +```typescript +/*typescript no-magic-numbers: ["error", { "ignoreNumericLiteralTypes": true }]*/ +type SmallPrimes = 2 | 3 | 5 | 7 | 11; +``` + +Examples of **correct** code for this rule with option "ignoreReadonlyClassProperties": + +```typescript +/*typescript no-magic-numbers: ["error", { "ignoreReadonlyClassProperties": true }]*/ +class Foo { + readonly A = 1; + readonly B = 2; + public static readonly C = 1; + static readonly D = 1; +} +``` + +Examples of **correct** code for this rule with option "ignoreTypeIndexes": + +```typescript +/*typescript no-magic-numbers: ["error", { "ignoreTypeIndexes": true }]*/ +type Foo = Bar[0]; +type Baz = Parameters[2]; +``` + +## References + +- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_magic_numbers.rs) diff --git a/src/docs/guide/usage/linter/rules/eslint/no-nonoctal-decimal-escape.md b/src/docs/guide/usage/linter/rules/eslint/no-nonoctal-decimal-escape.md index 3f1e34c798d..44a085f7ee2 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-nonoctal-decimal-escape.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-nonoctal-decimal-escape.md @@ -6,6 +6,9 @@ This rule is turned on by default. + +🚧 An auto-fix is still under development. + ### What it does diff --git a/src/docs/guide/usage/linter/rules/eslint/no-obj-calls.md b/src/docs/guide/usage/linter/rules/eslint/no-obj-calls.md index b7a99ae2ca1..5a572aaae81 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-obj-calls.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-obj-calls.md @@ -19,8 +19,9 @@ Calling them as functions will usually result in a TypeError being thrown. ### Example +Examples of **incorrect** code for this rule: + ```javascript -// Bad let math = Math(); let newMath = new Math(); @@ -35,8 +36,11 @@ let newIntl = new Intl(); let reflect = Reflect(); let newReflect = new Reflect(); +``` -// Good +Examples of **correct** code for this rule: + +```javascript let area = (r) => 2 * Math.PI * r * r; let object = JSON.parse("{}"); let first = Atomics.load(sharedArray, 0); diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unused-private-class-members.md b/src/docs/guide/usage/linter/rules/eslint/no-unused-private-class-members.md index a1c4bb9a458..94a5399ab31 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-unused-private-class-members.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-unused-private-class-members.md @@ -16,10 +16,11 @@ Disallow unused private class members Private class members that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such class members take up space in the code and can lead to confusion by readers. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -/// bad class A { #unusedMember = 5; } @@ -46,14 +47,18 @@ class E { get #unusedAccessor() {} set #unusedAccessor(value) {} } +``` + +Examples of **correct** code for this rule: -/// Good +```javascript class A { #usedMember = 42; method() { return this.#usedMember; } } + class B { #usedMethod() { return 42; @@ -62,6 +67,7 @@ class B { return this.#usedMethod(); } } + class C { get #usedAccessor() {} set #usedAccessor(value) {} diff --git a/src/docs/guide/usage/linter/rules/eslint/no-useless-rename.md b/src/docs/guide/usage/linter/rules/eslint/no-useless-rename.md index f8893f971dd..7ea550c0a85 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-useless-rename.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-useless-rename.md @@ -18,13 +18,17 @@ It is unnecessary to rename a variable to the same name. ### Example +Examples of **incorrect** code for this rule: + ```javascript -// Bad import { foo as foo } from "foo"; const { bar: bar } = obj; export { baz as baz }; +``` -// Good +Examples of **correct** code for this rule: + +```javascript import { foo } from "foo"; const { bar: renamed } = obj; export { baz }; diff --git a/src/docs/guide/usage/linter/rules/eslint/sort-keys.md b/src/docs/guide/usage/linter/rules/eslint/sort-keys.md new file mode 100644 index 00000000000..ed2211dce75 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/eslint/sort-keys.md @@ -0,0 +1,42 @@ + + +# eslint/sort-keys + +
+ +🚧 An auto-fix is still under development. + +
+ +### What it does + +When declaring multiple properties, sorting property names alphabetically makes it easier +to find and/or diff necessary properties at a later time. + +### Why is this bad? + +Unsorted property keys can make the code harder to read and maintain. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +let myObj = { + c: 1, + a: 2, +}; +``` + +Examples of **correct** code for this rule: + +```js +let myObj = { + a: 2, + c: 1, +}; +``` + +## References + +- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/sort_keys.rs) diff --git a/src/docs/guide/usage/linter/rules/eslint/sort-vars.md b/src/docs/guide/usage/linter/rules/eslint/sort-vars.md new file mode 100644 index 00000000000..01f3824c13e --- /dev/null +++ b/src/docs/guide/usage/linter/rules/eslint/sort-vars.md @@ -0,0 +1,38 @@ + + +# eslint/sort-vars + +
+ +🚧 An auto-fix is still under development. + +
+ +### What it does + +When declaring multiple variables within the same block, sorting variable names make it +easier to find necessary variable easier at a later time. + +### Why is this bad? + +Unsorted variable declarations can make the code harder to read and maintain. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +var b, a; +var a, B, c; +``` + +Examples of **correct** code for this rule: + +```js +var a, b, c, d; +var B, a, c; +``` + +## References + +- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/sort_vars.rs) diff --git a/src/docs/guide/usage/linter/rules/import/no-amd.md b/src/docs/guide/usage/linter/rules/import/no-amd.md index 17826f982c2..97dd64919c6 100644 --- a/src/docs/guide/usage/linter/rules/import/no-amd.md +++ b/src/docs/guide/usage/linter/rules/import/no-amd.md @@ -9,12 +9,19 @@ Forbid AMD `require` and `define` calls. -### Example +### Why is this bad? + +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// fail require([a, b], function () {}); -// pass +``` + +Examples of **correct** code for this rule: + +```javascript require("../name"); require(`../name`); ``` diff --git a/src/docs/guide/usage/linter/rules/import/no-default-export.md b/src/docs/guide/usage/linter/rules/import/no-default-export.md index 6ae3882a450..52414cd6abb 100644 --- a/src/docs/guide/usage/linter/rules/import/no-default-export.md +++ b/src/docs/guide/usage/linter/rules/import/no-default-export.md @@ -11,21 +11,20 @@ Forbid a module to have a default exports. This help your editor to provide bett ### Examples +Examples of **incorrect** code for this rule: + ```javascript -// bad1.js +export default 'bar'; -// There is a default export. -export const foo = "foo"; -const bar = "bar"; -export default "bar"; +const foo = 'foo'; +export { foo as default } ``` -```javascript -// bad2.js +Examples of **correct** code for this rule: -// There is a default export. -const foo = "foo"; -export { foo as default }; +```javascript +export const foo = "foo"; +export const bar = "bar"; ``` ## References diff --git a/src/docs/guide/usage/linter/rules/import/no-dynamic-require.md b/src/docs/guide/usage/linter/rules/import/no-dynamic-require.md new file mode 100644 index 00000000000..15c99e2738f --- /dev/null +++ b/src/docs/guide/usage/linter/rules/import/no-dynamic-require.md @@ -0,0 +1,35 @@ + + +# import/no-dynamic-require + +
+
+ +### What it does + +Forbid imports which use an expression for the module argument. + +### Why is this bad? + +Import statements which use an expression resolved at runtime makes it to find where the +import comes from and some static code analysis tools might not be able to resolve them. + +### Examples + +Examples of **incorrect** code for this rule: + +```javascript +require(name); +require(`../${name}`); +``` + +Examples of **correct** code for this rule: + +```javascript +require("../name"); +require(`../name`); +``` + +## References + +- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/import/no_dynamic_require.rs) diff --git a/src/docs/guide/usage/linter/rules/jsdoc/check-access.md b/src/docs/guide/usage/linter/rules/jsdoc/check-access.md index f4fe1523c01..b696125d4d1 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/check-access.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/check-access.md @@ -20,20 +20,24 @@ Also reports: It is important to have a consistent way of specifying access levels. -### Example +### Examples -```javascript -// Passing -/** @access private */ - -/** @private */ +Examples of **incorrect** code for this rule: -// Failing +```javascript /** @access private @public */ /** @access invalidlevel */ ``` +Examples of **correct** code for this rule: + +```javascript +/** @access private */ + +/** @private */ +``` + ## References - [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsdoc/check_access.rs) diff --git a/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md b/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md index cf496a70e60..b7cad91f237 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/check-property-names.md @@ -13,29 +13,34 @@ Ensures that property names in JSDoc are not duplicated on the same block and th `@property` tags with the same name can be confusing and may indicate a mistake. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing /** * @typedef {object} state * @property {number} foo + * @property {string} foo */ + /** * @typedef {object} state - * @property {object} foo * @property {number} foo.bar */ +``` -// Failing +Examples of **correct** code for this rule: + +```javascript /** * @typedef {object} state * @property {number} foo - * @property {string} foo */ /** * @typedef {object} state + * @property {object} foo * @property {number} foo.bar */ ``` diff --git a/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md b/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md index f383dfaef20..a04f3fbd103 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/check-tag-names.md @@ -14,13 +14,11 @@ Additionally checks for tag names that are redundant when using a type checker s Using invalid tags can lead to confusion and make the documentation harder to read. -### Example +### Examples -```javascript -// Passing -/** @param */ +Examples of **incorrect** code for this rule: -// Failing +```javascript /** @Param */ /** @foo */ @@ -30,6 +28,12 @@ Using invalid tags can lead to confusion and make the documentation harder to re */ ``` +Examples of **correct** code for this rule: + +```javascript +/** @param */ +``` + ## References - [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs) diff --git a/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md b/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md index 90bd9f18add..a25db3cf525 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/empty-tags.md @@ -32,20 +32,24 @@ Expects the following tags to be empty of any content: The void tags should be empty. -### Example +### Examples -```javascript -// Passing -/** @async */ - -/** @private */ +Examples of **incorrect** code for this rule: -// Failing +```javascript /** @async foo */ /** @private bar */ ``` +Examples of **correct** code for this rule: + +```javascript +/** @async */ + +/** @private */ +``` + ## References - [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsdoc/empty_tags.rs) diff --git a/src/docs/guide/usage/linter/rules/jsdoc/implements-on-classes.md b/src/docs/guide/usage/linter/rules/jsdoc/implements-on-classes.md index 9a2f492695d..43354ad03ca 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/implements-on-classes.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/implements-on-classes.md @@ -14,10 +14,20 @@ Reports an issue with any non-constructor function using `@implements`. Constructor functions should be whether marked with `@class`, `@constructs`, or being an ES6 class constructor. -### Example +### Examples + +Examples of **incorrect** code for this rule: + +```javascript +/** + * @implements {SomeClass} + */ +function quux() {} +``` + +Examples of **correct** code for this rule: ```javascript -// Passing class Foo { /** * @implements {SomeClass} @@ -29,12 +39,6 @@ class Foo { * @class */ function quux() {} - -// Failing -/** - * @implements {SomeClass} - */ -function quux() {} ``` ## References diff --git a/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md b/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md index 634798b2574..16ef181be35 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/no-defaults.md @@ -15,17 +15,22 @@ It also optionally reports the presence of the square-bracketed optional argumen The rule is intended to prevent the indication of defaults on tags where this would be redundant with ES6 default parameters. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing -/** @param {number} foo */ +/** @param {number} [foo="7"] */ function quux(foo) {} -/** @param foo */ +``` + +Examples of **correct** code for this rule: + +```javascript +/** @param {number} foo */ function quux(foo) {} -// Failing -/** @param {number} [foo="7"] */ +/** @param foo */ function quux(foo) {} ``` diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md b/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md index af0e3084ddd..11017726526 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-param-description.md @@ -13,15 +13,19 @@ Requires that each `@param` tag has a description value. The description of a param should be documented. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing -/** @param foo Foo. */ +/** @param foo */ function quux(foo) {} +``` -// Failing -/** @param foo */ +Examples of **correct** code for this rule: + +```javascript +/** @param foo Foo. */ function quux(foo) {} ``` diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-param-name.md b/src/docs/guide/usage/linter/rules/jsdoc/require-param-name.md index bc8ba5eaf80..2b7b3ee0dcb 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-param-name.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-param-name.md @@ -13,15 +13,19 @@ Requires that all `@param` tags have names. The name of a param should be documented. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing -/** @param {SomeType} foo */ +/** @param {SomeType} */ function quux(foo) {} +``` -// Failing -/** @param {SomeType} */ +Examples of **correct** code for this rule: + +```javascript +/** @param {SomeType} foo */ function quux(foo) {} ``` diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md b/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md index 39e0c99679a..1c235f685d6 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-param-type.md @@ -13,15 +13,19 @@ Requires that each `@param` tag has a type value (within curly brackets). The type of a parameter should be documented. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing -/** @param {SomeType} foo */ +/** @param foo */ function quux(foo) {} +``` -// Failing -/** @param foo */ +Examples of **correct** code for this rule: + +```javascript +/** @param {SomeType} foo */ function quux(foo) {} ``` diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-param.md b/src/docs/guide/usage/linter/rules/jsdoc/require-param.md index 5b0008d5713..9ebb828bff8 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-param.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-param.md @@ -13,16 +13,20 @@ Requires that all function parameters are documented with JSDoc `@param` tags. The rule is aimed at enforcing code quality and maintainability by requiring that all function parameters are documented. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing /** @param foo */ -function quux(foo) {} +function quux(foo, bar) {} +``` -// Failing +Examples of **correct** code for this rule: + +```javascript /** @param foo */ -function quux(foo, bar) {} +function quux(foo) {} ``` ## References diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-property-description.md b/src/docs/guide/usage/linter/rules/jsdoc/require-property-description.md index cbc6725bcaf..83d71a5927a 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-property-description.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-property-description.md @@ -13,19 +13,23 @@ Requires that all `@property` tags have descriptions. The description of a property should be documented. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing /** * @typedef {SomeType} SomeTypedef - * @property {number} foo Foo. + * @property {number} foo */ +``` -// Failing +Examples of **correct** code for this rule: + +```javascript /** * @typedef {SomeType} SomeTypedef - * @property {number} foo + * @property {number} foo Foo. */ ``` diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-property-name.md b/src/docs/guide/usage/linter/rules/jsdoc/require-property-name.md index a38a3da0fcb..e32df50387c 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-property-name.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-property-name.md @@ -13,19 +13,23 @@ Requires that all `@property` tags have names. The name of a property type should be documented. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing /** * @typedef {SomeType} SomeTypedef - * @property {number} foo + * @property {number} */ +``` -// Failing +Examples of **correct** code for this rule: + +```javascript /** * @typedef {SomeType} SomeTypedef - * @property {number} + * @property {number} foo */ ``` diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-property-type.md b/src/docs/guide/usage/linter/rules/jsdoc/require-property-type.md index 403f0e51620..2fc820b5f1a 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-property-type.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-property-type.md @@ -13,19 +13,23 @@ Requires that each `@property` tag has a type value (within curly brackets). The type of a property should be documented. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing /** * @typedef {SomeType} SomeTypedef - * @property {number} foo + * @property foo */ +``` -// Failing +Examples of **correct** code for this rule: + +```javascript /** * @typedef {SomeType} SomeTypedef - * @property foo + * @property {number} foo */ ``` diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-property.md b/src/docs/guide/usage/linter/rules/jsdoc/require-property.md index 5eced21203f..3212aa80306 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-property.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-property.md @@ -14,25 +14,31 @@ when their type is a plain `object`, `Object`, or `PlainObject`. Object type should have properties defined. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing /** * @typedef {Object} SomeTypedef - * @property {SomeType} propName Prop description */ + /** - * @typedef {object} Foo - * @property someProp + * @namespace {Object} SomeNamesoace */ +``` -// Failing +Examples of **correct** code for this rule: + +```javascript /** * @typedef {Object} SomeTypedef + * @property {SomeType} propName Prop description */ + /** - * @namespace {Object} SomeNamesoace + * @typedef {object} Foo + * @property someProp */ ``` diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-returns-description.md b/src/docs/guide/usage/linter/rules/jsdoc/require-returns-description.md index c35d0b08cc8..26447efcca1 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-returns-description.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-returns-description.md @@ -14,15 +14,19 @@ The error will not be reported if the return value is `void `or `undefined` or i A `@returns` tag should have a description value. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing -/** @returns Foo. */ +/** @returns */ function quux(foo) {} +``` -// Failing -/** @returns */ +Examples of **correct** code for this rule: + +```javascript +/** @returns Foo. */ function quux(foo) {} ``` diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-returns-type.md b/src/docs/guide/usage/linter/rules/jsdoc/require-returns-type.md index f4b94f1a4a2..9abb5ba0435 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-returns-type.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-returns-type.md @@ -13,15 +13,19 @@ Requires that `@returns` tag has a type value (in curly brackets). A `@returns` tag should have a type value. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing -/** @returns {string} */ +/** @returns */ function quux(foo) {} +``` -// Failing -/** @returns */ +Examples of **correct** code for this rule: + +```javascript +/** @returns {string} */ function quux(foo) {} ``` diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md b/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md index 839fa0fa3fc..a6b1a7050d7 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-returns.md @@ -14,20 +14,16 @@ Will also report if multiple `@returns` tags are present. The rule is intended to prevent the omission of `@returns` tag when necessary. -### Example +### Examples -```javascript -// Passing -/** @returns Foo. */ -function quux() { - return foo; -} +Examples of **incorrect** code for this rule: -// Failing +```javascript /** Foo. */ function quux() { return foo; } + /** * @returns Foo! * @returns Foo? @@ -37,6 +33,15 @@ function quux() { } ``` +Examples of **correct** code for this rule: + +```javascript +/** @returns Foo. */ +function quux() { + return foo; +} +``` + ## References - [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsdoc/require_returns.rs) diff --git a/src/docs/guide/usage/linter/rules/jsdoc/require-yields.md b/src/docs/guide/usage/linter/rules/jsdoc/require-yields.md index 5ed4920d22d..cbc9fe864b2 100644 --- a/src/docs/guide/usage/linter/rules/jsdoc/require-yields.md +++ b/src/docs/guide/usage/linter/rules/jsdoc/require-yields.md @@ -14,19 +14,15 @@ Will also report if multiple `@yields` tags are present. The rule is intended to prevent the omission of `@yields` tags when they are necessary. -### Example +### Examples + +Examples of **incorrect** code for this rule: ```javascript -// Passing -/** * @yields Foo */ function* quux(foo) { yield foo; } -// Failing -function* quux(foo) { - yield foo; -} /** * @yields {undefined} * @yields {void} @@ -34,6 +30,15 @@ function* quux(foo) { function* quux(foo) {} ``` +Examples of **correct** code for this rule: + +```javascript +/** * @yields Foo */ +function* quux(foo) { + yield foo; +} +``` + ## References - [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsdoc/require_yields.rs) diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/aria-unsupported-elements.md b/src/docs/guide/usage/linter/rules/jsx_a11y/aria-unsupported-elements.md index cb002854348..f5da218273a 100644 --- a/src/docs/guide/usage/linter/rules/jsx_a11y/aria-unsupported-elements.md +++ b/src/docs/guide/usage/linter/rules/jsx_a11y/aria-unsupported-elements.md @@ -17,14 +17,18 @@ elements do not contain the `role` and/or `aria-*` props. ### Example -```jsx -// Good - +Examples of **incorrect** code for this rule: -// Bad +```jsx ``` +Examples of **correct** code for this rule: + +```jsx + +``` + ## References - [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsx_a11y/aria_unsupported_elements.rs) diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/autocomplete-valid.md b/src/docs/guide/usage/linter/rules/jsx_a11y/autocomplete-valid.md index 90a77c0966f..b2a31bed038 100644 --- a/src/docs/guide/usage/linter/rules/jsx_a11y/autocomplete-valid.md +++ b/src/docs/guide/usage/linter/rules/jsx_a11y/autocomplete-valid.md @@ -15,11 +15,15 @@ Incorrectly using the autocomplete attribute may decrease the accessibility of t ### Example +Examples of **incorrect** code for this rule: + ```jsx -// Bad +``` -// Good +Examples of **correct** code for this rule: + +```jsx ``` diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/click-events-have-key-events.md b/src/docs/guide/usage/linter/rules/jsx_a11y/click-events-have-key-events.md index a3974b75401..daff7b76a03 100644 --- a/src/docs/guide/usage/linter/rules/jsx_a11y/click-events-have-key-events.md +++ b/src/docs/guide/usage/linter/rules/jsx_a11y/click-events-have-key-events.md @@ -16,14 +16,18 @@ This does not apply for interactive or hidden elements. ### Example -```jsx -// Good -
void 0} onKeyDown={() => void 0} /> +Examples of **incorrect** code for this rule: -// Bad +```jsx
void 0} /> ``` +Examples of **correct** code for this rule: + +```jsx +
void 0} onKeyDown={() => void 0} /> +``` + ## References - [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsx_a11y/click_events_have_key_events.rs) diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/heading-has-content.md b/src/docs/guide/usage/linter/rules/jsx_a11y/heading-has-content.md index ffaed33864e..920dd44a97b 100644 --- a/src/docs/guide/usage/linter/rules/jsx_a11y/heading-has-content.md +++ b/src/docs/guide/usage/linter/rules/jsx_a11y/heading-has-content.md @@ -20,11 +20,15 @@ from accessing information on the page's structure. ### Example +Examples of **incorrect** code for this rule: + ```jsx -// Bad

+``` -// Good +Examples of **correct** code for this rule: + +```jsx

Foo

``` diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/html-has-lang.md b/src/docs/guide/usage/linter/rules/jsx_a11y/html-has-lang.md index da7363d9e16..27dca79e55f 100644 --- a/src/docs/guide/usage/linter/rules/jsx_a11y/html-has-lang.md +++ b/src/docs/guide/usage/linter/rules/jsx_a11y/html-has-lang.md @@ -18,11 +18,15 @@ and access website in more than one language. ### Example +Examples of **incorrect** code for this rule: + ```jsx -// Bad +``` -// Good +Examples of **correct** code for this rule: + +```jsx ``` diff --git a/src/docs/guide/usage/linter/rules/jsx_a11y/iframe-has-title.md b/src/docs/guide/usage/linter/rules/jsx_a11y/iframe-has-title.md index 1082c841219..282d40c1c80 100644 --- a/src/docs/guide/usage/linter/rules/jsx_a11y/iframe-has-title.md +++ b/src/docs/guide/usage/linter/rules/jsx_a11y/iframe-has-title.md @@ -20,8 +20,9 @@ This rule checks for title property on iframe element. ### Example +Examples of **incorrect** code for this rule: + ```jsx -// Bad