diff --git a/src/docs/guide/usage/linter/generated-rules.md b/src/docs/guide/usage/linter/generated-rules.md index 1ff06592b00..84ee289d2ca 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: 591 +- Total number of rules: 602 - Rules turned on by default: 103 **Legend for 'Fixable?' column:** @@ -13,7 +13,7 @@ The progress of all rule implementations is tracked [here](https://github.com/ox - ⚠️💡: a dangerous suggestion is available for this rule - 🚧: an auto-fix or suggestion is possible, but currently not implemented -## Correctness (195): +## Correctness (197): Code that is outright wrong or useless. @@ -212,6 +212,8 @@ Code that is outright wrong or useless. | [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 | | 🚧 | +| [no-export-in-script-setup](/docs/guide/usage/linter/rules/vue/no-export-in-script-setup.html) | vue | | | +| [prefer-import-from-vue](/docs/guide/usage/linter/rules/vue/prefer-import-from-vue.html) | vue | | 🛠️ | | [valid-define-emits](/docs/guide/usage/linter/rules/vue/valid-define-emits.html) | vue | | 🚧 | | [valid-define-props](/docs/guide/usage/linter/rules/vue/valid-define-props.html) | vue | | 🚧 | @@ -233,7 +235,7 @@ Code that can be written to run faster. | [prefer-array-flat-map](/docs/guide/usage/linter/rules/unicorn/prefer-array-flat-map.html) | unicorn | | 🛠️ | | [prefer-set-has](/docs/guide/usage/linter/rules/unicorn/prefer-set-has.html) | unicorn | | ⚠️🛠️️ | -## Restriction (72): +## Restriction (74): 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. @@ -249,6 +251,7 @@ Lints which prevent the use of language and library features. Must not be enable | [no-empty-function](/docs/guide/usage/linter/rules/eslint/no-empty-function.html) | eslint | | | | [no-eq-null](/docs/guide/usage/linter/rules/eslint/no-eq-null.html) | eslint | | ⚠️🛠️️ | | [no-iterator](/docs/guide/usage/linter/rules/eslint/no-iterator.html) | eslint | | 💡 | +| [no-param-reassign](/docs/guide/usage/linter/rules/eslint/no-param-reassign.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 | | 🚧 | @@ -306,13 +309,14 @@ Lints which prevent the use of language and library features. Must not be enable | [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 | | | | [no-process-exit](/docs/guide/usage/linter/rules/unicorn/no-process-exit.html) | unicorn | | 🚧 | +| [no-useless-error-capture-stack-trace](/docs/guide/usage/linter/rules/unicorn/no-useless-error-capture-stack-trace.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 | | ⚠️🛠️️ | | [max-props](/docs/guide/usage/linter/rules/vue/max-props.html) | vue | | | | [no-multiple-slot-args](/docs/guide/usage/linter/rules/vue/no-multiple-slot-args.html) | vue | | 🚧 | -## Suspicious (45): +## Suspicious (46): code that is most likely wrong or useless. @@ -361,10 +365,11 @@ code that is most likely wrong or useless. | [no-array-sort](/docs/guide/usage/linter/rules/unicorn/no-array-sort.html) | unicorn | | 🛠️ | | [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-module-specifiers](/docs/guide/usage/linter/rules/unicorn/require-module-specifiers.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 (98): +## Pedantic (101): Lints which are rather strict or have occasional false positives. @@ -444,6 +449,7 @@ Lints which are rather strict or have occasional false positives. | [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-unnecessary-array-flat-depth](/docs/guide/usage/linter/rules/unicorn/no-unnecessary-array-flat-depth.html) | unicorn | | 🚧 | +| [no-unnecessary-array-splice-count](/docs/guide/usage/linter/rules/unicorn/no-unnecessary-array-splice-count.html) | unicorn | | 🛠️ | | [no-unnecessary-slice-end](/docs/guide/usage/linter/rules/unicorn/no-unnecessary-slice-end.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 | | 🛠️ | @@ -451,6 +457,7 @@ Lints which are rather strict or have occasional false positives. | [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-at](/docs/guide/usage/linter/rules/unicorn/prefer-at.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 | | 🛠️ | @@ -466,10 +473,11 @@ Lints which are rather strict or have occasional false positives. | [prefer-regexp-test](/docs/guide/usage/linter/rules/unicorn/prefer-regexp-test.html) | unicorn | | 🛠️ | | [prefer-string-replace-all](/docs/guide/usage/linter/rules/unicorn/prefer-string-replace-all.html) | unicorn | | 🛠️ | | [prefer-string-slice](/docs/guide/usage/linter/rules/unicorn/prefer-string-slice.html) | unicorn | | 🛠️ | +| [prefer-top-level-await](/docs/guide/usage/linter/rules/unicorn/prefer-top-level-await.html) | unicorn | | | | [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 (161): +## Style (164): Code that should be written in a more idiomatic way. @@ -612,6 +620,8 @@ Code that should be written in a more idiomatic way. | [number-literal-case](/docs/guide/usage/linter/rules/unicorn/number-literal-case.html) | unicorn | | 🛠️ | | [numeric-separators-style](/docs/guide/usage/linter/rules/unicorn/numeric-separators-style.html) | unicorn | | 🛠️ | | [prefer-array-index-of](/docs/guide/usage/linter/rules/unicorn/prefer-array-index-of.html) | unicorn | | 🚧 | +| [prefer-class-fields](/docs/guide/usage/linter/rules/unicorn/prefer-class-fields.html) | unicorn | | 🛠️💡 | +| [prefer-classlist-toggle](/docs/guide/usage/linter/rules/unicorn/prefer-classlist-toggle.html) | unicorn | | 🛠️ | | [prefer-dom-node-text-content](/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-text-content.html) | unicorn | | 🛠️ | | [prefer-global-this](/docs/guide/usage/linter/rules/unicorn/prefer-global-this.html) | unicorn | | 🚧 | | [prefer-includes](/docs/guide/usage/linter/rules/unicorn/prefer-includes.html) | unicorn | | 🚧 | @@ -635,6 +645,7 @@ 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 | | | +| [define-props-destructuring](/docs/guide/usage/linter/rules/vue/define-props-destructuring.html) | vue | | | | [require-typed-ref](/docs/guide/usage/linter/rules/vue/require-typed-ref.html) | vue | | | ## Nursery (9): diff --git a/src/docs/guide/usage/linter/rules/eslint/no-param-reassign.md b/src/docs/guide/usage/linter/rules/eslint/no-param-reassign.md new file mode 100644 index 00000000000..bf37ac621fb --- /dev/null +++ b/src/docs/guide/usage/linter/rules/eslint/no-param-reassign.md @@ -0,0 +1,57 @@ + + + + +# eslint/no-param-reassign + +
+
+ +### What it does + +Disallow reassigning function parameters or, optionally, their properties. + +### Why is this bad? + +Reassigning parameters can lead to unexpected behavior, especially when relying on the +original arguments passed into the function. Mutating parameter properties can be similarly +surprising and harder to reason about. + +### Examples + +```javascript +function foo(bar) { + bar = 1; +} + +function baz(qux) { + qux.prop = 2; // when `props` option is enabled +} +``` + +## 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-param-reassign +``` + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "no-param-reassign": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-unnecessary-array-splice-count.md b/src/docs/guide/usage/linter/rules/unicorn/no-unnecessary-array-splice-count.md new file mode 100644 index 00000000000..86ad76fb7ae --- /dev/null +++ b/src/docs/guide/usage/linter/rules/unicorn/no-unnecessary-array-splice-count.md @@ -0,0 +1,66 @@ + + + + +# unicorn/no-unnecessary-array-splice-count + +
+ +🛠️ An auto-fix is available for this rule. + +
+ +### What it does + +Disallows passing `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#splice()` or `Array#toSpliced()`. + +### Why is this bad? + +When calling `Array#splice(start, deleteCount)` or `Array#toSpliced(start, skipCount)`, +omitting the `deleteCount` or `skipCount` argument will delete or skip all elements after `start`. +Using `.length` or `Infinity` is unnecessary and makes the code more verbose. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +array.splice(1, array.length); +array.splice(1, Infinity); +array.splice(1, Number.POSITIVE_INFINITY); +array.toSpliced(1, array.length); +``` + +Examples of **correct** code for this rule: + +```js +array.splice(1); +array.toSpliced(1); +``` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny unicorn/no-unnecessary-array-splice-count +``` + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "unicorn/no-unnecessary-array-splice-count": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/unicorn/no-useless-error-capture-stack-trace.md b/src/docs/guide/usage/linter/rules/unicorn/no-useless-error-capture-stack-trace.md new file mode 100644 index 00000000000..896f979f0a8 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/unicorn/no-useless-error-capture-stack-trace.md @@ -0,0 +1,69 @@ + + + + +# unicorn/no-useless-error-capture-stack-trace + +
+ +🚧 An auto-fix is still under development. + +
+ +### What it does + +Disallows unnecessary `Error.captureStackTrace(…)` in error constructors. + +### Why is this bad? + +Calling `Error.captureStackTrace(…)` inside the constructor of a built-in `Error` subclass +is unnecessary, since the `Error` constructor calls it automatically. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +class MyError extends Error { + constructor() { + Error.captureStackTrace(this, MyError); + } +} +``` + +Examples of **correct** code for this rule: + +```js +class MyError extends Error { + constructor() { + // No need to call Error.captureStackTrace + } +} +``` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny unicorn/no-useless-error-capture-stack-trace +``` + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "unicorn/no-useless-error-capture-stack-trace": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-at.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-at.md new file mode 100644 index 00000000000..63004be0df9 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-at.md @@ -0,0 +1,65 @@ + + + + +# unicorn/prefer-at + +
+ +⚠️🛠️️ A dangerous auto-fix is available for this rule. + +
+ +### What it does + +Prefer `.at()` method for index access and `String#charAt()`. + +### Why is this bad? + +The `.at()` method is more readable and consistent for accessing elements by index, +especially for negative indices which access elements from the end. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +const foo = array[array.length - 1]; +const foo = array.slice(-1)[0]; +const foo = string.charAt(string.length - 1); +``` + +Examples of **correct** code for this rule: + +```js +const foo = array.at(-1); +const foo = array.at(-5); +const foo = string.at(-1); +``` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny unicorn/prefer-at +``` + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "unicorn/prefer-at": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-class-fields.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-class-fields.md new file mode 100644 index 00000000000..0afe9406930 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-class-fields.md @@ -0,0 +1,68 @@ + + + + +# unicorn/prefer-class-fields + +
+ +🛠️💡 An auto-fix and a suggestion are available for this rule for some violations. + +
+ +### What it does + +Prefers class field declarations over `this` assignments in constructors for static values. + +### Why is this bad? + +Class field declarations are more readable and less error-prone than assigning static +values to `this` in the constructor. Using class fields keeps the constructor cleaner +and makes the intent clearer. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +class Foo { + constructor() { + this.bar = 1; + } +} +``` + +Examples of **correct** code for this rule: + +```js +class Foo { + bar = 1; +} +``` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny unicorn/prefer-class-fields +``` + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "unicorn/prefer-class-fields": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-classlist-toggle.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-classlist-toggle.md new file mode 100644 index 00000000000..e0bdb0434be --- /dev/null +++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-classlist-toggle.md @@ -0,0 +1,70 @@ + + + + +# unicorn/prefer-classlist-toggle + +
+ +🛠️ An auto-fix is available for this rule. + +
+ +### What it does + +Prefers the use of `element.classList.toggle(className, condition)` over +conditional add/remove patterns. + +### Why is this bad? + +The `toggle()` method is more concise and expressive than using conditional +logic to switch between `add()` and `remove()`. + +### Examples + +Examples of **incorrect** code for this rule: + +```javascript +if (condition) { + element.classList.add("className"); +} else { + element.classList.remove("className"); +} + +condition ? element.classList.add("className") : element.classList.remove("className"); + +element.classList[condition ? "add" : "remove"]("className"); +``` + +Examples of **correct** code for this rule: + +```javascript +element.classList.toggle("className", condition); +``` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny unicorn/prefer-classlist-toggle +``` + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "unicorn/prefer-classlist-toggle": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/unicorn/prefer-top-level-await.md b/src/docs/guide/usage/linter/rules/unicorn/prefer-top-level-await.md new file mode 100644 index 00000000000..302e3aef15d --- /dev/null +++ b/src/docs/guide/usage/linter/rules/unicorn/prefer-top-level-await.md @@ -0,0 +1,69 @@ + + + + +# unicorn/prefer-top-level-await + +
+
+ +### What it does + +Prefer top-level await over top-level promises and async function calls. + +### Why is this bad? + +Top-level await is more readable and can prevent unhandled rejections. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +(async () => { + await run(); +})(); + +run().catch(error => { + console.error(error); +}); +``` + +Examples of **correct** code for this rule: + +```js +await run(); + +try { + await run(); +} catch (error) { + console.error(error); +} +``` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny unicorn/prefer-top-level-await +``` + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "unicorn/prefer-top-level-await": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/unicorn/require-module-specifiers.md b/src/docs/guide/usage/linter/rules/unicorn/require-module-specifiers.md new file mode 100644 index 00000000000..7e9e690ac35 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/unicorn/require-module-specifiers.md @@ -0,0 +1,65 @@ + + + + +# unicorn/require-module-specifiers + +
+ +🛠️ An auto-fix is available for this rule. + +
+ +### What it does + +Enforce non-empty specifier list in `import` and `export` statements. + +### Why is this bad? + +Empty import/export specifiers add no value and can be confusing. +If you want to import a module for side effects, use `import 'module'` instead. + +### Examples + +Examples of **incorrect** code for this rule: + +```js +import {} from "foo"; +import foo, {} from "foo"; +export {} from "foo"; +export {}; +``` + +Examples of **correct** code for this rule: + +```js +import "foo"; +import foo from "foo"; +``` + +## How to use + +To **enable** this rule in the CLI or using the config file, you can use: + +::: code-group + +```bash [CLI] +oxlint --deny unicorn/require-module-specifiers +``` + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "unicorn/require-module-specifiers": "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 bba66674ec3..08be1ae4d24 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 "eb6345f0c2927517ad5eff19c54a5d636f17b106"; + return "d16df93cf48e1ed143f54797842f84116484b4ba"; }, }; diff --git a/src/docs/guide/usage/linter/rules/vue/define-props-destructuring.md b/src/docs/guide/usage/linter/rules/vue/define-props-destructuring.md new file mode 100644 index 00000000000..57576ccf0f6 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/vue/define-props-destructuring.md @@ -0,0 +1,92 @@ + + + + +# vue/define-props-destructuring + +
+
+ +### What it does + +This rule enforces a consistent style for handling Vue 3 Composition API props, +allowing you to choose between requiring destructuring or prohibiting it. + +### Why is this bad? + +By default, the rule requires you to use destructuring syntax when using `defineProps` +instead of storing props in a variable and warns against combining `withDefaults` with destructuring. + +### Examples + +Examples of **incorrect** code for this rule: + +```vue + +``` + +Examples of **correct** code for this rule: + +```vue + +``` + +### Options + +```json +{ + "vue/define-props-destructuring": ["error", { + "destructure": "always" | "never" + }] +} +``` + +`destructure` - Sets the destructuring preference for props + +- `"always"` (default) - Requires destructuring when using `defineProps` and warns against using `withDefaults` with destructuring +- `"never"` - Requires using a variable to store props and prohibits destructuring + +## Configuration + +This rule accepts a configuration object with the following properties: + +### destructure + +## 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/define-props-destructuring --vue-plugin +``` + +```json [Config (.oxlintrc.json)] +{ + "plugins": ["vue"], + "rules": { + "vue/define-props-destructuring": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/vue/no-export-in-script-setup.md b/src/docs/guide/usage/linter/rules/vue/no-export-in-script-setup.md new file mode 100644 index 00000000000..d1283f8edfa --- /dev/null +++ b/src/docs/guide/usage/linter/rules/vue/no-export-in-script-setup.md @@ -0,0 +1,64 @@ + + + + +# vue/no-export-in-script-setup + +
+
+ +### What it does + +Disallow `export` in ` +``` + +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-export-in-script-setup --vue-plugin +``` + +```json [Config (.oxlintrc.json)] +{ + "plugins": ["vue"], + "rules": { + "vue/no-export-in-script-setup": "error" + } +} +``` + +::: + +## References + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/vue/prefer-import-from-vue.md b/src/docs/guide/usage/linter/rules/vue/prefer-import-from-vue.md new file mode 100644 index 00000000000..666e4e71ad0 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/vue/prefer-import-from-vue.md @@ -0,0 +1,68 @@ + + + + +# vue/prefer-import-from-vue + +
+ +🛠️ An auto-fix is available for this rule. + +
+ +### What it does + +Enforce import from 'vue' instead of import from '@vue/*'. + +### Why is this bad? + +Imports from the following modules are almost always wrong. You should import from vue instead. + +- `@vue/runtime-dom` +- `@vue/runtime-core` +- `@vue/reactivity` +- `@vue/shared` + +### Examples + +Examples of **incorrect** code for this rule: + +```js +import { ref } from "@vue/reactivity"; +import { Component } from "@vue/runtime-core"; +import { createApp } from "@vue/runtime-dom"; +``` + +Examples of **correct** code for this rule: + +```js +import { Component, createApp, ref } from "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/prefer-import-from-vue --vue-plugin +``` + +```json [Config (.oxlintrc.json)] +{ + "plugins": ["vue"], + "rules": { + "vue/prefer-import-from-vue": "error" + } +} +``` + +::: + +## References + +- Rule Source