Skip to content

Commit cdae0a5

Browse files
committed
docs(vitest): add linting instructions
1 parent 6f477a5 commit cdae0a5

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

packages/unit-vitest/README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,46 @@
44
$ quasar ext add @quasar/testing-unit-vitest
55
```
66

7+
For ESLint < v9, add into your `.eslintrc.js` the following code:
8+
9+
```js
10+
{
11+
// ...
12+
overrides: [
13+
{
14+
files: [
15+
'src/**/*.vitest.{test,spec}.{js,jsx,ts,tsx}',
16+
'test/vitest/__tests__/**/*.{test,spec}.{js,jsx,ts,tsx}',
17+
],
18+
rules: {
19+
// Allow chai-style assertions, e.g. `expect(foo).to.be.true`
20+
'@typescript-eslint/no-unused-expressions': 'off',
21+
},
22+
},
23+
],
24+
}
25+
```
26+
27+
For ESLint v9 onwards, add into your `eslint.config.js` the following code:
28+
29+
```js
30+
export default [
31+
// ...
32+
{
33+
name: 'custom/vitest',
34+
35+
files: [
36+
'src/**/*.vitest.{test,spec}.{js,jsx,ts,tsx}',
37+
'test/vitest/__tests__/**/*.{test,spec}.{js,jsx,ts,tsx}',
38+
],
39+
rules: {
40+
// Allow chai-style assertions, e.g. `expect(foo).to.be.true`
41+
'@typescript-eslint/no-unused-expressions': 'off',
42+
},
43+
},
44+
];
45+
```
46+
747
This App Extension (AE) manages Quasar and Vitest integration for you, both for JavaScript and TypeScript.
848

949
What is included:
@@ -28,7 +68,7 @@ All changes are related to Vitest v1.0 breaking changes, Quasar first-party help
2868
- Upgrade all Vitest related dependencies, especially `@vue/test-utils`, `vitest` and `@vitest/ui`, which minimum peer dependencies versions has been bumped. If you don't want to upgrade these dependencies manually, you can just re-install the AE and it will update all dependencies for you;
2969
- (**optional**) Upgrade `vue` and `quasar` dependencies to the latest version;
3070
- Rename `vitest.config.[js|ts]` to `vitest.config.[mjs|mts]` or switch your project to "ESM by default" adding `"type": "module"` option in `package.json`. Check out [here](https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated) why CJS build and syntax are deprecated in Vite 5;
31-
- Vitest 1.0 requires Vite 5, thus you'll need to upgrade `@quasar/app-vite` to v2 (currently in beta stage). If you can't migrate away from v1 yet, you can use this [workaround](https://github.com/quasarframework/quasar/issues/14077#issuecomment-1851463530) until you can migrate. We do test against the setup using that workaround, to ease the migration, but bear in mind that we don't consider it as "officially supported" and we will stop testing against it in the near future;
71+
- Vitest 1.0 requires Vite 5, thus you'll need to upgrade `@quasar/app-vite` to v2. If you can't migrate away from v1 yet, you can use this [workaround](https://github.com/quasarframework/quasar/issues/14077#issuecomment-1851463530) until you can migrate. We do test against the setup using that workaround, to ease the migration, but bear in mind that we don't consider it as "officially supported" and we will stop testing against it in the near future;
3272
- Follow Vitest [upgrade guide](https://vitest.dev/guide/migration.html#migrating-from-vitest-0-34-6) to upgrade from Vitest v34.6 to v1.0
3373

3474
### installQuasarPlugin(options)

test-vite-app-v1-vite4/.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,15 @@ module.exports = {
101101
'plugin:cypress/recommended',
102102
],
103103
},
104+
{
105+
files: [
106+
'src/**/*.vitest.{test,spec}.{js,jsx,ts,tsx}',
107+
'test/vitest/__tests__/**/*.{test,spec}.{js,jsx,ts,tsx}',
108+
],
109+
rules: {
110+
// Allow chai-style assertions, e.g. `expect(foo).to.be.true`
111+
'@typescript-eslint/no-unused-expressions': 'off',
112+
},
113+
},
104114
],
105115
};

test-vite-app-v1-vite5/.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,15 @@ module.exports = {
101101
'plugin:cypress/recommended',
102102
],
103103
},
104+
{
105+
files: [
106+
'src/**/*.vitest.{test,spec}.{js,jsx,ts,tsx}',
107+
'test/vitest/__tests__/**/*.{test,spec}.{js,jsx,ts,tsx}',
108+
],
109+
rules: {
110+
// Allow chai-style assertions, e.g. `expect(foo).to.be.true`
111+
'@typescript-eslint/no-unused-expressions': 'off',
112+
},
113+
},
104114
],
105115
};

test-vite-app-v2/eslint.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,17 @@ export default defineConfigWithVueTs(
102102
'@typescript-eslint/no-unused-expressions': 'off',
103103
},
104104
},
105+
106+
{
107+
name: 'custom/vitest',
108+
109+
files: [
110+
'src/**/*.vitest.{test,spec}.{js,jsx,ts,tsx}',
111+
'test/vitest/__tests__/**/*.{test,spec}.{js,jsx,ts,tsx}',
112+
],
113+
rules: {
114+
// Allow chai-style assertions, e.g. `expect(foo).to.be.true`
115+
'@typescript-eslint/no-unused-expressions': 'off',
116+
},
117+
},
105118
);

0 commit comments

Comments
 (0)