diff --git a/src/docs/guide/usage/linter/generated-cli.md b/src/docs/guide/usage/linter/generated-cli.md index 7fc783d570..dddefb237e 100644 --- a/src/docs/guide/usage/linter/generated-cli.md +++ b/src/docs/guide/usage/linter/generated-cli.md @@ -95,9 +95,6 @@ Arguments: - **`--no-ignore`** — Disables excluding of files from .eslintignore files, **`--ignore-path`** flags and **`--ignore-pattern`** flags -> [!NOTE] -> `.gitignore` is only respected inside a Git repository. - ## Handle Warnings - **`--quiet`** — diff --git a/src/docs/guide/usage/linter/generated-rules.md b/src/docs/guide/usage/linter/generated-rules.md index 31fe0e3c8c..6fcc728f1c 100644 --- a/src/docs/guide/usage/linter/generated-rules.md +++ b/src/docs/guide/usage/linter/generated-rules.md @@ -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: 582 +- Total number of rules: 585 - Rules turned on by default: 102 **Legend for 'Fixable?' column:** @@ -311,7 +311,7 @@ Lints which prevent the use of language and library features. Must not be enable | [prefer-number-properties](/docs/guide/usage/linter/rules/unicorn/prefer-number-properties.html) | unicorn | | βš οΈπŸ› οΈοΈ | | [no-multiple-slot-args](/docs/guide/usage/linter/rules/vue/no-multiple-slot-args.html) | vue | | 🚧 | -## Suspicious (42): +## Suspicious (43): code that is most likely wrong or useless. @@ -359,6 +359,7 @@ code that is most likely wrong or useless. | [no-instanceof-builtins](/docs/guide/usage/linter/rules/unicorn/no-instanceof-builtins.html) | unicorn | | 🚧 | | [prefer-add-event-listener](/docs/guide/usage/linter/rules/unicorn/prefer-add-event-listener.html) | unicorn | | 🚧 | | [require-post-message-target-origin](/docs/guide/usage/linter/rules/unicorn/require-post-message-target-origin.html) | unicorn | | πŸ’‘ | +| [no-required-prop-with-default](/docs/guide/usage/linter/rules/vue/no-required-prop-with-default.html) | vue | | 🚧 | ## Pedantic (97): @@ -464,7 +465,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 (158): +## Style (159): Code that should be written in a more idiomatic way. @@ -628,18 +629,20 @@ Code that should be written in a more idiomatic way. | [prefer-to-be-truthy](/docs/guide/usage/linter/rules/vitest/prefer-to-be-truthy.html) | vitest | | πŸ› οΈ | | [define-emits-declaration](/docs/guide/usage/linter/rules/vue/define-emits-declaration.html) | vue | | 🚧 | | [define-props-declaration](/docs/guide/usage/linter/rules/vue/define-props-declaration.html) | vue | | | +| [require-typed-ref](/docs/guide/usage/linter/rules/vue/require-typed-ref.html) | vue | | | -## Nursery (8): +## Nursery (9): New lints that are still under development. -| Rule name | Source | Default | Fixable? | -| ---------------------------------------------------------------------------------------- | ------- | ------- | -------- | -| [getter-return](/docs/guide/usage/linter/rules/eslint/getter-return.html) | eslint | | | -| [no-undef](/docs/guide/usage/linter/rules/eslint/no-undef.html) | eslint | | | -| [no-unreachable](/docs/guide/usage/linter/rules/eslint/no-unreachable.html) | eslint | | | -| [export](/docs/guide/usage/linter/rules/import/export.html) | import | | | -| [named](/docs/guide/usage/linter/rules/import/named.html) | import | | | -| [no-map-spread](/docs/guide/usage/linter/rules/oxc/no-map-spread.html) | oxc | | πŸ› οΈπŸ’‘ | -| [no-return-in-finally](/docs/guide/usage/linter/rules/promise/no-return-in-finally.html) | promise | | | -| [require-render-return](/docs/guide/usage/linter/rules/react/require-render-return.html) | react | | | +| Rule name | Source | Default | Fixable? | +| --------------------------------------------------------------------------------------------------------- | ------- | ------- | -------- | +| [getter-return](/docs/guide/usage/linter/rules/eslint/getter-return.html) | eslint | | | +| [no-misleading-character-class](/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.html) | eslint | | | +| [no-undef](/docs/guide/usage/linter/rules/eslint/no-undef.html) | eslint | | | +| [no-unreachable](/docs/guide/usage/linter/rules/eslint/no-unreachable.html) | eslint | | | +| [export](/docs/guide/usage/linter/rules/import/export.html) | import | | | +| [named](/docs/guide/usage/linter/rules/import/named.html) | import | | | +| [no-map-spread](/docs/guide/usage/linter/rules/oxc/no-map-spread.html) | oxc | | πŸ› οΈπŸ’‘ | +| [no-return-in-finally](/docs/guide/usage/linter/rules/promise/no-return-in-finally.html) | promise | | | +| [require-render-return](/docs/guide/usage/linter/rules/react/require-render-return.html) | react | | | diff --git a/src/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.md b/src/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.md new file mode 100644 index 0000000000..f78f4e73c0 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/eslint/no-misleading-character-class.md @@ -0,0 +1,106 @@ + + + + +# eslint/no-misleading-character-class + +
+
+ +### What it does + +This rule reports regular expressions which include multiple code point characters in character class syntax. This includes: + +- Characters with combining marks (e.g., `Á` where `A` is followed by a combining acute accent) +- Characters with emoji modifiers (e.g., `πŸ‘ΆπŸ»`) +- Pairs of regional indicator symbols (e.g., `πŸ‡―πŸ‡΅`) +- Characters joined by zero-width joiner (ZWJ) (e.g., `πŸ‘¨β€πŸ‘©β€πŸ‘¦`) +- Surrogate pairs without the Unicode flag (e.g., `/^[πŸ‘]$/`) + +### Why is this bad? + +Unicode includes characters which are made by multiple code points. +RegExp character class syntax (`/[abc]/`) cannot handle characters +which are made by multiple code points as a character; +those characters will be dissolved to each code point. +For example, `❇️` is made by `❇` (`U+2747`) and VARIATION SELECTOR-16 (`U+FE0F`). +If this character is in a RegExp character class, +it will match either `❇` (`U+2747`) or VARIATION SELECTOR-16 (`U+FE0F`) rather than `❇️`. + +This can lead to regular expressions that do not match what the author intended, +especially for emoji, regional indicators, and characters with combining marks. + +#### Examples + +Examples of **incorrect** code for this rule: + +```javascript +/^[Á]$/u; +/^[❇️]$/u; +/^[πŸ‘ΆπŸ»]$/u; +/^[πŸ‡―πŸ‡΅]$/u; +/^[πŸ‘¨β€πŸ‘©β€πŸ‘¦]$/u; +/^[πŸ‘]$/; +new RegExp("[🎡]"); +``` + +Examples of **correct** code for this rule: + +```javascript +/^[abc]$/; +/^[πŸ‘]$/u; +/[\u00B7\u0300-\u036F]/u; +new RegExp("^[\u{1F1EF}\u{1F1F5}]", "u"); +``` + +#### Options + +This rule has an object option: + +- `allowEscape`: When set to `true`, the rule allows any grouping of code points + inside a character class as long as they are written using escape sequences. + +Examples of **incorrect** code for this rule with `{ "allowEscape": true }`: + +```javascript +/[\uD83D]/; // backslash can be omitted +new RegExp("[\ud83d" + "\udc4d]"); +``` + +Examples of **correct** code for this rule with `{ "allowEscape": true }`: + +```javascript +/[\ud83d\udc4d]/; +/[\u00B7\u0300-\u036F]/u; +/[πŸ‘¨\u200dπŸ‘©]/u; +new RegExp("[\x41\u0301]"); +new RegExp(`[\u{1F1EF}\u{1F1F5}]`, "u"); +new RegExp("[\\u{1F1EF}\\u{1F1F5}]", "u"); +``` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny no-misleading-character-class +``` + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "no-misleading-character-class": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/version.data.js b/src/docs/guide/usage/linter/rules/version.data.js index 3c777689f1..11d14172fd 100644 --- a/src/docs/guide/usage/linter/rules/version.data.js +++ b/src/docs/guide/usage/linter/rules/version.data.js @@ -1,5 +1,5 @@ export default { load() { - return "a2c91cd5104af39a6b644e77879d3117c72b0ea6"; + return "cc0019fb0af60ea2566e4aca87656d0a9f573c1c"; }, }; diff --git a/src/docs/guide/usage/linter/rules/vue/no-required-prop-with-default.md b/src/docs/guide/usage/linter/rules/vue/no-required-prop-with-default.md new file mode 100644 index 0000000000..c56bdd478d --- /dev/null +++ b/src/docs/guide/usage/linter/rules/vue/no-required-prop-with-default.md @@ -0,0 +1,83 @@ + + + + +# vue/no-required-prop-with-default + +
+ +🚧 An auto-fix is still under development. + +
+ +### What it does + +Enforce props with default values to be optional. + +### Why is this bad? + +If a prop is declared with a default value, whether it is required or not, +we can always skip it in actual use. In that situation, the default value would be applied. +So, a required prop with a default value is essentially the same as an optional prop. + +### Examples + +Examples of **incorrect** code for this rule: + +```vue + +``` + +Examples of **correct** code for this rule: + +```vue + +``` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny vue/no-required-prop-with-default --vue-plugin +``` + +```json [Config (.oxlintrc.json)] +{ + "plugins": ["vue"], + "rules": { + "vue/no-required-prop-with-default": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/vue/require-typed-ref.md b/src/docs/guide/usage/linter/rules/vue/require-typed-ref.md new file mode 100644 index 0000000000..b23ceca16f --- /dev/null +++ b/src/docs/guide/usage/linter/rules/vue/require-typed-ref.md @@ -0,0 +1,62 @@ + + + + +# vue/require-typed-ref + +
+
+ +### What it does + +Require `ref` and `shallowRef` functions to be strongly typed. + +### Why is this bad? + +With TypeScript it is easy to prevent usage of `any` by using `noImplicitAny`. +Unfortunately this rule is easily bypassed with Vue `ref()` function. +Calling `ref()` function without a generic parameter or an initial value leads to ref having `Ref` type. + +### Examples + +Examples of **incorrect** code for this rule: + +```typescript +const count = ref(); +const name = shallowRef(); +``` + +Examples of **correct** code for this rule: + +```typescript +const count = ref(); +const a = ref(0); +``` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny vue/require-typed-ref --vue-plugin +``` + +```json [Config (.oxlintrc.json)] +{ + "plugins": ["vue"], + "rules": { + "vue/require-typed-ref": "error" + } +} +``` + +::: + +## References + +- Rule Source