Skip to content

Commit 6001b7d

Browse files
committedDec 26, 2024
fix: fix remaining bugs & update examples
1 parent 3755a4c commit 6001b7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1128
-137
lines changed
 

‎README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -60,50 +60,50 @@ All the `<script>` blocks in `.vue` files *MUST* be written in TypeScript (shoul
6060
import pluginVue from 'eslint-plugin-vue'
6161
import {
6262
defineConfig,
63-
configs,
6463
configureVueProject,
64+
configs,
6565
} from '@vue/eslint-config-typescript'
6666

67-
export default [
68-
...pluginVue.configs["flat/essential"],
67+
configureVueProject({
68+
// Optional: specify the script langs in `.vue` files
69+
// Defaults to `{ ts: true, js: false, tsx: false, jsx: false }`
70+
supportedScriptLangs: {
71+
ts: true,
72+
73+
// [!DISCOURAGED]
74+
// Set to `true` to allow plain `<script>` or `<script setup>` blocks.
75+
// This might result-in false positive or negatives in some rules for `.vue` files.
76+
// Note you also need to configure `allowJs: true` and `checkJs: true`
77+
// in corresponding `tsconfig.json` files.
78+
js: false,
79+
80+
// [!STRONGLY DISCOURAGED]
81+
// Set to `true` to allow `<script lang="tsx">` blocks.
82+
// This would be in conflict with all type-aware rules.
83+
tsx: false,
84+
85+
// [!STRONGLY DISCOURAGED]
86+
// Set to `true` to allow `<script lang="jsx">` blocks.
87+
// This would be in conflict with all type-aware rules and may result in false positives.
88+
jsx: false,
89+
},
90+
91+
// <https://github.com/vuejs/eslint-plugin-vue/issues/1910#issuecomment-1819993961>
92+
// Optional: the root directory to resolve the `.vue` files, defaults to `process.cwd()`.
93+
// You may need to set this to the root directory of your project if you have a monorepo.
94+
// This is useful when you allow any other languages than `ts` in `.vue` files.
95+
// Our config helper would resolve and parse all the `.vue` files under `rootDir`,
96+
// and only apply the loosened rules to the files that do need them.
97+
rootDir: import.meta.dirname,
98+
})
99+
100+
export default defineConfig(
101+
pluginVue.configs["flat/essential"],
69102

70103
// We STRONGLY RECOMMEND you to start with `recommended` or `recommendedTypeChecked`.
71104
// But if you are determined to configure all rules by yourself,
72105
// you can start with `base`, and then turn on/off the rules you need.
73106
configs.base,
74-
75-
configureVueProject({
76-
// Optional: specify the script langs in `.vue` files
77-
// Defaults to `{ ts: true, js: false, tsx: false, jsx: false }`
78-
supportedScriptLangs: {
79-
ts: true,
80-
81-
// [!DISCOURAGED]
82-
// Set to `true` to allow plain `<script>` or `<script setup>` blocks.
83-
// This might result-in false positive or negatives in some rules for `.vue` files.
84-
// Note you also need to configure `allowJs: true` and `checkJs: true`
85-
// in corresponding `tsconfig.json` files.
86-
js: false,
87-
88-
// [!STRONGLY DISCOURAGED]
89-
// Set to `true` to allow `<script lang="tsx">` blocks.
90-
// This would be in conflict with all type-aware rules.
91-
tsx: false,
92-
93-
// [!STRONGLY DISCOURAGED]
94-
// Set to `true` to allow `<script lang="jsx">` blocks.
95-
// This would be in conflict with all type-aware rules and may result in false positives.
96-
jsx: false,
97-
},
98-
99-
// <https://github.com/vuejs/eslint-plugin-vue/issues/1910#issuecomment-1819993961>
100-
// Optional: the root directory to resolve the `.vue` files, defaults to `process.cwd()`.
101-
// You may need to set this to the root directory of your project if you have a monorepo.
102-
// This is useful when you allow any other languages than `ts` in `.vue` files.
103-
// Our config helper would resolve and parse all the `.vue` files under `rootDir`,
104-
// and only apply the loosened rules to the files that do need them.
105-
rootDir: import.meta.dirname,
106-
}),
107107
)
108108
```
109109

‎examples/allow-js/eslint.config.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import pluginVue from "eslint-plugin-vue";
2-
import vueTsEslintConfig from "@vue/eslint-config-typescript";
1+
import pluginVue from 'eslint-plugin-vue'
2+
import {
3+
defineConfig,
4+
configureVueProject,
5+
configs,
6+
} from '@vue/eslint-config-typescript'
37

4-
export default [
8+
configureVueProject({
9+
supportedScriptLangs: {
10+
js: true,
11+
ts: true,
12+
},
13+
})
14+
15+
export default defineConfig(
516
{
617
name: 'app/files-to-lint',
718
files: ['**/*.js', '**/*.mjs', '**/*.ts', '**/*.mts', '**/*.vue'],
@@ -12,11 +23,6 @@ export default [
1223
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
1324
},
1425

15-
...pluginVue.configs["flat/essential"],
16-
...vueTsEslintConfig({
17-
supportedScriptLangs: {
18-
ts: true,
19-
js: true
20-
}
21-
}),
22-
]
26+
pluginVue.configs['flat/essential'],
27+
configs.recommended,
28+
)

0 commit comments

Comments
 (0)