diff --git a/src/docs/guide/usage/linter/generated-config.md b/src/docs/guide/usage/linter/generated-config.md index bebdd85f894..51b446303da 100644 --- a/src/docs/guide/usage/linter/generated-config.md +++ b/src/docs/guide/usage/linter/generated-config.md @@ -12,7 +12,9 @@ Only the `.json` format is supported. You can use comments in configuration file Example -```json [.oxlintrc.json] +`.oxlintrc.json` + +```json { "env": { "browser": true @@ -28,17 +30,52 @@ Example } ``` -## env +## categories type: `object` +Configure an entire category of rules all at once. + +Rules enabled or disabled this way will be overwritten by individual rules in the `rules` field. + +# Example + +```json +{ + "categories": { + "correctness": "warn" + }, + "rules": { + "eslint/no-unused-vars": "error" + } +} +``` + +### categories.correctness + +### categories.nursery + +### categories.pedantic + +### categories.perf + +### categories.restriction + +### categories.style + +### categories.suspicious + +## env + +type: `Record` + Predefine global variables. Environments specify what global variables are predefined. See [ESLint's list of environments](https://eslint.org/docs/v8.x/use/configure/language-options#specifying-environments) for what environments are available and what each one provides. ## globals -type: `object` +type: `Record` Add or remove global variables. @@ -61,11 +98,9 @@ You may also use `"readable"` or `false` to represent `"readonly"`, and `"writea ## plugins -type: `array` - -### plugins[n] +type: `string[]` -type: `string` +default: `["react", "unicorn", "typescript", "oxc"]` ## rules @@ -87,55 +122,73 @@ type: `object` type: `boolean` +default: `false` + Only for `require-(yields|returns|description|example|param|throws)` rule #### settings.jsdoc.exemptDestructuredRootsFromChecks type: `boolean` +default: `false` + Only for `require-param-type` and `require-param-description` rule #### settings.jsdoc.ignoreInternal type: `boolean` +default: `false` + For all rules but NOT apply to `empty-tags` rule #### settings.jsdoc.ignorePrivate type: `boolean` +default: `false` + For all rules but NOT apply to `check-access` and `empty-tags` rule #### settings.jsdoc.ignoreReplacesDocs type: `boolean` +default: `true` + Only for `require-(yields|returns|description|example|param|throws)` rule #### settings.jsdoc.implementsReplacesDocs type: `boolean` +default: `false` + Only for `require-(yields|returns|description|example|param|throws)` rule #### settings.jsdoc.overrideReplacesDocs type: `boolean` +default: `true` + Only for `require-(yields|returns|description|example|param|throws)` rule #### settings.jsdoc.tagNamePreference type: `object` +default: `{}` + ### settings.jsx-a11y type: `object` #### settings.jsx-a11y.components -type: `object` +type: `Record` + +default: `{}` #### settings.jsx-a11y.polymorphicPropName @@ -158,10 +211,14 @@ type: `object` type: `array` +default: `[]` + ##### settings.react.formComponents[n] #### settings.react.linkComponents type: `array` +default: `[]` + ##### settings.react.linkComponents[n] diff --git a/src/docs/guide/usage/linter/generated-rules.md b/src/docs/guide/usage/linter/generated-rules.md index 50ed2cf49ba..420835b9140 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: 436 -- Rules turned on by default: 96 +- Total number of rules: 439 +- Rules turned on by default: 98 -## Correctness (170): +## Correctness (173): Code that is outright wrong or useless. | Rule name | Source | Default | Fixable? | @@ -47,6 +47,7 @@ Code that is outright wrong or useless. | [no-this-before-super](/docs/guide/usage/linter/rules/eslint/no-this-before-super.html) | eslint | ✅ | | | [no-unsafe-finally](/docs/guide/usage/linter/rules/eslint/no-unsafe-finally.html) | eslint | ✅ | | | [no-unsafe-negation](/docs/guide/usage/linter/rules/eslint/no-unsafe-negation.html) | eslint | ✅ | 🛠️ | +| [no-unsafe-optional-chaining](/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.html) | eslint | ✅ | | | [no-unused-labels](/docs/guide/usage/linter/rules/eslint/no-unused-labels.html) | eslint | ✅ | 🛠️ | | [no-unused-private-class-members](/docs/guide/usage/linter/rules/eslint/no-unused-private-class-members.html) | eslint | ✅ | | | [no-unused-vars](/docs/guide/usage/linter/rules/eslint/no-unused-vars.html) | eslint | ✅ | ⚠️💡 | @@ -139,8 +140,10 @@ Code that is outright wrong or useless. | [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 | ✅ | ⚠️🛠️️ | | [uninvoked-array-callback](/docs/guide/usage/linter/rules/oxc/uninvoked-array-callback.html) | oxc | ✅ | | +| [no-callback-in-promise](/docs/guide/usage/linter/rules/promise/no-callback-in-promise.html) | promise | | | | [no-new-statics](/docs/guide/usage/linter/rules/promise/no-new-statics.html) | promise | | 🛠️ | | [valid-params](/docs/guide/usage/linter/rules/promise/valid-params.html) | promise | | | +| [iframe-missing-sandbox](/docs/guide/usage/linter/rules/react/iframe-missing-sandbox.html) | react | ✅ | 🚧 | | [jsx-key](/docs/guide/usage/linter/rules/react/jsx-key.html) | react | ✅ | | | [jsx-no-duplicate-props](/docs/guide/usage/linter/rules/react/jsx-no-duplicate-props.html) | react | ✅ | | | [jsx-no-target-blank](/docs/guide/usage/linter/rules/react/jsx-no-target-blank.html) | react | ✅ | | @@ -208,12 +211,11 @@ Lints which prevent the use of language and library features. Must not be enable | [no-eq-null](/docs/guide/usage/linter/rules/eslint/no-eq-null.html) | eslint | | ⚠️🛠️️ | | [no-eval](/docs/guide/usage/linter/rules/eslint/no-eval.html) | eslint | | | | [no-iterator](/docs/guide/usage/linter/rules/eslint/no-iterator.html) | eslint | | 🚧 | -| [no-plusplus](/docs/guide/usage/linter/rules/eslint/no-plusplus.html) | eslint | | 🚧 | +| [no-plusplus](/docs/guide/usage/linter/rules/eslint/no-plusplus.html) | eslint | | 💡 | | [no-proto](/docs/guide/usage/linter/rules/eslint/no-proto.html) | eslint | | 🚧 | | [no-regex-spaces](/docs/guide/usage/linter/rules/eslint/no-regex-spaces.html) | eslint | | 🚧 | | [no-restricted-globals](/docs/guide/usage/linter/rules/eslint/no-restricted-globals.html) | eslint | | | | [no-undefined](/docs/guide/usage/linter/rules/eslint/no-undefined.html) | eslint | | | -| [no-unsafe-optional-chaining](/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.html) | eslint | | | | [no-var](/docs/guide/usage/linter/rules/eslint/no-var.html) | eslint | | 🛠️ | | [no-void](/docs/guide/usage/linter/rules/eslint/no-void.html) | eslint | | 🚧 | | [unicode-bom](/docs/guide/usage/linter/rules/eslint/unicode-bom.html) | eslint | | 🛠️ | @@ -224,6 +226,7 @@ Lints which prevent the use of language and library features. Must not be enable | [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 | | | +| [no-new-require](/docs/guide/usage/linter/rules/node/no-new-require.html) | node | | | | [bad-bitwise-operator](/docs/guide/usage/linter/rules/oxc/bad-bitwise-operator.html) | oxc | | | | [no-async-await](/docs/guide/usage/linter/rules/oxc/no-async-await.html) | oxc | | | | [no-barrel-file](/docs/guide/usage/linter/rules/oxc/no-barrel-file.html) | oxc | | | @@ -282,7 +285,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 (71): +## Pedantic (70): Lints which are rather strict or have occasional false positives. | Rule name | Source | Default | Fixable? | @@ -304,7 +307,6 @@ Lints which are rather strict or have occasional false positives. | [no-throw-literal](/docs/guide/usage/linter/rules/eslint/no-throw-literal.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 | | | @@ -359,7 +361,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 (102): +## Style (103): Code that should be written in a more idiomatic way. | Rule name | Source | Default | Fixable? | @@ -381,6 +383,7 @@ Code that should be written in a more idiomatic way. | [prefer-exponentiation-operator](/docs/guide/usage/linter/rules/eslint/prefer-exponentiation-operator.html) | eslint | | | | [prefer-numeric-literals](/docs/guide/usage/linter/rules/eslint/prefer-numeric-literals.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 | | 🚧 | | [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 | | | diff --git a/src/docs/guide/usage/linter/rules/eslint/no-else-return.md b/src/docs/guide/usage/linter/rules/eslint/no-else-return.md index 4c12b964437..23dc5b5629f 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-else-return.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-else-return.md @@ -4,7 +4,7 @@
-🛠️ An auto-fix is available for this rule. +🛠️ An auto-fix is available for this rule for some violations.
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md b/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md index 28fcc93c10f..a2d05a14436 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-plusplus.md @@ -4,7 +4,7 @@
-🚧 An auto-fix is still under development. +💡 A suggestion is available for this rule for some violations.
diff --git a/src/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.md b/src/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.md index db64f671d13..233e73cc29a 100644 --- a/src/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.md +++ b/src/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.md @@ -1,8 +1,11 @@ -# eslint/no-unsafe-optional-chaining +# eslint/no-unsafe-optional-chaining
+ + This rule is turned on by default. +
### What it does diff --git a/src/docs/guide/usage/linter/rules/eslint/sort-keys.md b/src/docs/guide/usage/linter/rules/eslint/sort-keys.md index ed2211dce75..1722e558ba1 100644 --- a/src/docs/guide/usage/linter/rules/eslint/sort-keys.md +++ b/src/docs/guide/usage/linter/rules/eslint/sort-keys.md @@ -1,6 +1,6 @@ -# eslint/sort-keys +# eslint/sort-keys
diff --git a/src/docs/guide/usage/linter/rules/node/no-new-require.md b/src/docs/guide/usage/linter/rules/node/no-new-require.md new file mode 100644 index 00000000000..765cba007f0 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/node/no-new-require.md @@ -0,0 +1,34 @@ + + +# node/no-new-require + +
+
+ +### What it does + +Warn about calling `new` on `require`. + +### Why is this bad? + +The `require` function is used to include modules and might return a constructor. As this +is not always the case this can be confusing. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +var appHeader = new require("app-header"); +``` + +Examples of **correct** code for this rule: + +```js +var AppHeader = require("app-header"); +var appHeader = new AppHeader(); +``` + +## References + +- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/node/no_new_require.rs) diff --git a/src/docs/guide/usage/linter/rules/promise/no-callback-in-promise.md b/src/docs/guide/usage/linter/rules/promise/no-callback-in-promise.md new file mode 100644 index 00000000000..82ffb9df8a2 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/promise/no-callback-in-promise.md @@ -0,0 +1,49 @@ + + +# promise/no-callback-in-promise + +
+
+ +### What it does + +Disallows calling a callback function (`cb()`) inside a `Promise.prototype.then()` +or `Promise.prototype.catch()`. + +### Why is this bad? + +Directly invoking a callback inside a `then()` or `catch()` method can lead to +unexpected behavior, such as the callback being called multiple times. Additionally, +mixing the callback and promise paradigms in this way can make the code confusing +and harder to maintain. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +function callback(err, data) { + console.log("Callback got called with:", err, data); + throw new Error("My error"); +} + +Promise.resolve() + .then(() => callback(null, "data")) + .catch((err) => callback(err.message, null)); +``` + +Examples of **correct** code for this rule: + +```js +Promise.resolve() + .then((data) => { + console.log(data); + }) + .catch((err) => { + console.error(err); + }); +``` + +## References + +- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/promise/no_callback_in_promise.rs) diff --git a/src/docs/guide/usage/linter/rules/react/iframe-missing-sandbox.md b/src/docs/guide/usage/linter/rules/react/iframe-missing-sandbox.md new file mode 100644 index 00000000000..85724036f64 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/react/iframe-missing-sandbox.md @@ -0,0 +1,44 @@ + + +# react/iframe-missing-sandbox + +
+ + This rule is turned on by default. + + +🚧 An auto-fix is still under development. + +
+ +### What it does + +Enforce sandbox attribute on iframe elements + +### Why is this bad? + +The sandbox attribute enables an extra set of restrictions for the content in the iframe. Using sandbox attribute is considered a good security practice. +To learn more about sandboxing, see [MDN's documentation on the `sandbox` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox). + +This rule checks all React `