You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+79-84
Original file line number
Diff line number
Diff line change
@@ -25,19 +25,26 @@ Please also make sure that you have `typescript` and `eslint` installed.
25
25
26
26
## Usage
27
27
28
-
Because of the complexity of this config, it is exported as a factory function that takes an options object and returns an ESLint configuration object.
28
+
Because of the complexity of the configurations, this package exports several utilities:
29
+
30
+
-`defineConfigWithVueTs`, a utility function whose type signature is the same as the [`config` function from `typescript-eslint`](https://typescript-eslint.io/packages/typescript-eslint#config), but will modify the given ESLint config to work with Vue.js + TypeScript.
31
+
-`vueTsConfigs`, contains all the [shared configruations from `typescript-eslint`](https://typescript-eslint.io/users/configs) (in camelCase, e.g. `vueTsConfigs.recommendedTypeChecked`), and applies to `.vue` files in addition to TypeScript files.
32
+
- a Vue-specific config factory: `configureVueProject({ scriptLangs, rootDir })`. More info below.
The above configuration enables [the essential rules for Vue 3](https://eslint.vuejs.org/rules/#priority-a-essential-error-prevention) and [the recommended rules for TypeScript](https://typescript-eslint.io/rules/?=recommended).
@@ -48,58 +55,54 @@ All the `<script>` blocks in `.vue` files *MUST* be written in TypeScript (shoul
// Optional: the root directory to resolve the `.vue` files, defaults to `process.cwd()`.
91
+
// You may need to set this to the root directory of your project if you have a monorepo.
92
+
// This is useful when you allow any other languages than `ts` in `.vue` files.
93
+
// Our config helper would resolve and parse all the `.vue` files under `rootDir`,
94
+
// and only apply the loosened rules to the files that do need them.
95
+
rootDir:import.meta.dirname,
96
+
})
97
+
98
+
exportdefaultdefineConfigWithVueTs(
99
+
pluginVue.configs["flat/essential"],
100
+
101
+
// We STRONGLY RECOMMEND you to start with `recommended` or `recommendedTypeChecked`.
102
+
// But if you are determined to configure all rules by yourself,
103
+
// you can start with `base`, and then turn on/off the rules you need.
104
+
vueTsConfigs.base,
105
+
)
103
106
```
104
107
105
108
### Linting with Type Information
@@ -111,34 +114,26 @@ It is not always easy to set up the type-checking environment for ESLint without
111
114
So we don't recommend you to configure individual type-aware rules and the corresponding language options all by yourself.
112
115
Instead, you can start by extending from the `recommendedTypeChecked` configuration and then turn on/off the rules you need.
113
116
114
-
As of now, all the rules you need to turn on must appear *before* calling `...vueTsEslintConfig({ extends: ['recommendedTypeChecked'] })`, and all the rules you need to turn off must appear *after* calling it.
## Use As a Normal Shared ESLint Config (Not Recommended)
132
+
133
+
You can use this package as a normal ESLint config, without the `defineConfigWithVueTs` helper. But in this case, overriding the rules for `.vue` files would be more difficult and comes with many nuances. Please be cautious.
134
+
135
+
You can check [the documentation for 14.1 and earlier versions](https://github.com/vuejs/eslint-config-typescript/tree/v14.1.4#usage) for more information.
136
+
142
137
## Further Reading
143
138
144
139
-[All the extendable configurations from `typescript-eslint`](https://typescript-eslint.io/users/configs).
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
12
+
13
+
## Customize configuration
14
+
15
+
See [Vite Configuration Reference](https://vite.dev/config/).
16
+
17
+
## Project Setup
18
+
19
+
```sh
20
+
npm install
21
+
```
22
+
23
+
### Compile and Hot-Reload for Development
24
+
25
+
```sh
26
+
npm run dev
27
+
```
28
+
29
+
### Type-Check, Compile and Minify for Production
30
+
31
+
```sh
32
+
npm run build
33
+
```
34
+
35
+
### Run Unit Tests with [Vitest](https://vitest.dev/)
36
+
37
+
```sh
38
+
npm run test:unit
39
+
```
40
+
41
+
### Run End-to-End Tests with [Cypress](https://www.cypress.io/)
42
+
43
+
```sh
44
+
npm run test:e2e:dev
45
+
```
46
+
47
+
This runs the end-to-end tests against the Vite development server.
48
+
It is much faster than the production build.
49
+
50
+
But it's still recommended to test the production build with `test:e2e` before deploying (e.g. in CI environments):
0 commit comments