Skip to content

Commit 017c855

Browse files
liangmiQwQfengmk2
andauthored
docs: fix overrides behavior mismatch (#1942)
Should mark it as close. #1769? #1769 (comment) Runtime behavior: https://github.com/liang-demos/vite-plus-lint-extend-override-semantic.git oxc-project/oxc#7379 --------- Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>
1 parent f957a57 commit 017c855

7 files changed

Lines changed: 101 additions & 4 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "lint-override-semantic",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module"
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[[case]]
2+
name = "lint_override_semantic"
3+
vp = "local"
4+
steps = [
5+
{ argv = ["vp", "lint", "src/example.js"], comment = "base lint rules apply to JavaScript", continue-on-failure = true },
6+
{ argv = ["vp", "lint", "src/example.vue"], comment = "base lint rules are preserved when a file override adds Vue rules", continue-on-failure = true },
7+
]
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# lint_override_semantic
2+
3+
## `vp lint src/example.js`
4+
5+
base lint rules apply to JavaScript
6+
7+
**Exit code:** 1
8+
9+
```
10+
11+
× eslint(no-console): Unexpected console statement.
12+
╭─[src/example.js:1:1]
13+
1 │ console.log();
14+
· ───────────
15+
╰────
16+
help: Delete this console statement.
17+
18+
Found 0 warnings and 1 error.
19+
Finished in <duration> on 1 file with <n> rules using <n> threads.
20+
```
21+
22+
## `vp lint src/example.vue`
23+
24+
base lint rules are preserved when a file override adds Vue rules
25+
26+
**Exit code:** 1
27+
28+
```
29+
30+
× vue(no-export-in-script-setup): <script setup>` cannot contain ES module exports.
31+
╭─[src/example.vue:8:16]
32+
7 │
33+
8 │ export default {};
34+
· ──
35+
9 │ </script>
36+
╰────
37+
38+
× vue(no-export-in-script-setup): <script setup>` cannot contain ES module exports.
39+
╭─[src/example.vue:8:8]
40+
7 │
41+
8 │ export default {};
42+
· ───────
43+
9 │ </script>
44+
╰────
45+
46+
× eslint(no-console): Unexpected console statement.
47+
╭─[src/example.vue:6:1]
48+
5 │ <script lang="ts" setup>
49+
6 │ console.log();
50+
· ───────────
51+
7 │
52+
╰────
53+
help: Delete this console statement.
54+
55+
Found 0 warnings and 3 errors.
56+
Finished in <duration> on 1 file with <n> rules using <n> threads.
57+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<div></div>
3+
</template>
4+
5+
<script lang="ts" setup>
6+
console.log();
7+
8+
export default {};
9+
</script>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { defineConfig } from 'vite-plus';
2+
3+
export default defineConfig({
4+
lint: {
5+
rules: { 'no-console': 'error' },
6+
plugins: ['unicorn', 'eslint'],
7+
overrides: [
8+
{
9+
files: ['**/*.vue'],
10+
plugins: ['vue'],
11+
rules: {
12+
'vue/no-export-in-script-setup': 'error',
13+
},
14+
},
15+
],
16+
},
17+
});

‎docs/guide/monorepo.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default defineConfig({
2424
overrides: [
2525
{
2626
files: ['apps/web/**', 'packages/ui/**'],
27-
plugins: ['typescript', 'react'],
27+
plugins: ['react'],
2828
rules: {
2929
'react/self-closing-comp': 'error',
3030
},
@@ -40,9 +40,9 @@ export default defineConfig({
4040
},
4141
{
4242
files: ['**/*.test.ts', '**/*.spec.ts'],
43-
plugins: ['typescript', 'vitest'],
43+
plugins: ['vitest'],
4444
rules: {
45-
'@typescript-eslint/no-explicit-any': 'off',
45+
'typescript/no-explicit-any': 'off',
4646
'vitest/no-disabled-tests': 'error',
4747
},
4848
},
@@ -54,7 +54,7 @@ export default defineConfig({
5454
Globs are resolved from the root `vite.config.ts`, so use workspace paths such as `apps/web/**`, `apps/api/**`, and `packages/ui/**`.
5555

5656
::: tip
57-
When a `lint.overrides` entry sets `plugins`, that list replaces the base `lint.plugins` list for matched files. Include every plugin needed by that file group, such as `['typescript', 'react']`. Omit `plugins` only when the override should inherit the base list unchanged.
57+
When a `lint.overrides` entry sets `plugins`, that list will be merged with the base `lint.plugins` list for matched files. Omit `plugins` only when the override should inherit the base list unchanged.
5858
:::
5959

6060
## Format Overrides

0 commit comments

Comments
 (0)