Skip to content

Commit

Permalink
Add eslint-plugin-vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous committed Jan 19, 2024
1 parent e16fb90 commit 9cd2c5e
Show file tree
Hide file tree
Showing 6 changed files with 315 additions and 175 deletions.
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,31 @@
"_prettier": "prettier \"**/*.{js,cjs,ts,json,yaml,md}\"",
"_eslint": "eslint \".*.cjs\" \"**/*.{js,cjs,ts}\""
},
"packageManager": "pnpm@8.13.1+sha256.9e5f62ce5f2b7d4ceb3c2848f41cf0b33032c24d683c7088b53f62b1885fb246",
"packageManager": "pnpm@8.14.1+sha256.2df78e65d433d7693b9d3fbdaf431b2d96bb4f96a2ffecd51a50efe16e50a6a8",
"dependencies": {
"@viamrobotics/eslint-config": "workspace:*",
"@viamrobotics/prettier-config": "workspace:*",
"@viamrobotics/typescript-config": "workspace:*"
},
"devDependencies": {
"@types/node": "^20.10.6",
"@types/node": "^20.11.5",
"@types/semver": "^7.5.6",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"concurrently": "^8.2.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-sonarjs": "^0.23.0",
"eslint-plugin-svelte": "^2.35.1",
"eslint-plugin-tailwindcss": "^3.13.1",
"eslint-plugin-tailwindcss": "^3.14.0",
"eslint-plugin-unicorn": "^50.0.1",
"prettier": "^3.1.1",
"eslint-plugin-vitest": "^0.3.20",
"prettier": "^3.2.4",
"prettier-plugin-svelte": "^3.1.2",
"prettier-plugin-tailwindcss": "^0.5.10",
"prettier-plugin-tailwindcss": "^0.5.11",
"semver": "^7.5.4",
"typescript": "^5.3.3",
"vitest": "^1.1.1"
"vitest": "^1.2.1"
},
"pnpm": {
"peerDependencyRules": {
Expand Down
6 changes: 4 additions & 2 deletions packages/eslint-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pnpm add --save-dev \
eslint \
eslint-config-prettier \
eslint-plugin-sonarjs \
eslint-plugin-unicorn
eslint-plugin-unicorn \
eslint-plugin-vitest
```

```js
Expand Down Expand Up @@ -47,7 +48,8 @@ pnpm add --save-dev \
eslint-plugin-sonarjs \
eslint-plugin-svelte \
eslint-plugin-tailwindcss \
eslint-plugin-unicorn
eslint-plugin-unicorn \
eslint-plugin-vitest
```

```js
Expand Down
31 changes: 29 additions & 2 deletions packages/eslint-config/base.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,40 @@ module.exports = {
'unicorn/prefer-module': 'off',
},
},
// Relax rules that don't make sense for testing
// Rules for tests
{
files: ['**/__tests__/**', '**/*.spec.ts'],
files: ['**/__tests__/**', '**/*.test.ts', '**/*.spec.ts'],
extends: ['plugin:vitest/recommended'],
rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'sonarjs/no-duplicate-string': 'off',
'vitest/consistent-test-filename': [
'error',
{
pattern: '.*\\.spec\\.(ts|svelte)$',
},
],
'vitest/consistent-test-it': ['error', { fn: 'it' }],
'vitest/no-conditional-expect': 'error',
'vitest/no-conditional-in-test': 'error',
'vitest/no-conditional-tests': 'error',
'vitest/no-restricted-matchers': [
'error',
{
toBeFalsey: 'Prefer `toBe` or `toEqual`',
toBeTruthy: 'Prefer `toBe` or `toEqual`',
},
],
'vitest/no-restricted-vi-methods': [
'error',
{
spyOn: 'Do not partially mock objects',
},
],
'vitest/prefer-each': 'error',
'vitest/require-top-level-describe': 'error',
'vitest/valid-expect': ['error', { maxArgs: 2 }],
},
},
// Rules that don't make sense for ambient type files
Expand Down
8 changes: 6 additions & 2 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "0.3.2",
"version": "0.4.0",
"description": "Common ESLint configuration for Viam projects.",
"files": [
"**/*",
Expand Down Expand Up @@ -48,14 +48,18 @@
"eslint-plugin-sonarjs": ">=0.19 <0.24",
"eslint-plugin-svelte": ">=2 <3",
"eslint-plugin-tailwindcss": ">=3 <4",
"eslint-plugin-unicorn": ">=47 <51"
"eslint-plugin-unicorn": ">=47 <51",
"eslint-plugin-vitest": ">=0.3 <0.4"
},
"peerDependenciesMeta": {
"eslint-plugin-svelte": {
"optional": true
},
"eslint-plugin-tailwindcss": {
"optional": true
},
"eslint-plugin-vitest": {
"optional": true
}
}
}
Loading

0 comments on commit 9cd2c5e

Please sign in to comment.