Skip to content

Commit

Permalink
feat: add eslint-plugin-vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
capitnflam committed Mar 17, 2024
1 parent 2505b0f commit c631db4
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"eslint-plugin-security": "2.1.1",
"eslint-plugin-sonarjs": "0.24.0",
"eslint-plugin-unicorn": "51.0.1",
"eslint-plugin-vitest": "0.3.26",
"eslint-plugin-xss": "0.1.12"
},
"devDependencies": {
Expand Down
40 changes: 40 additions & 0 deletions src/configs/vitest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { type ESLintConfig } from '../types'

export const vitest: ESLintConfig = {
plugins: ['@flaminc'],
overrides: [
{
files: ['**/*.spec.ts'],
plugins: ['vitest'],
extends: ['plugin:vitest/recommended'],
rules: {
'vitest/consistent-test-it': [
'error',
{ fn: 'it', withinDescribe: 'it' },
],
'vitest/no-alias-methods': 'error',
'vitest/no-conditional-expect': 'error',
'vitest/no-conditional-in-test': 'error',
'vitest/no-conditional-tests': 'error',
'vitest/no-disabled-tests': 'warn',
'vitest/no-focused-tests': 'error',
'vitest/no-hooks': 'off',
'vitest/no-standalone-expect': 'error',
'vitest/prefer-each': 'error',
'vitest/prefer-comparison-matcher': 'error',
'vitest/prefer-equality-matcher': 'error',
'vitest/prefer-expect-resolves': 'error',
'vitest/prefer-hooks-in-order': 'error',
'vitest/prefer-hooks-on-top': 'error',
'vitest/prefer-lowercase-title': 'error',
'vitest/prefer-mock-promise-shorthand': 'error',
'vitest/prefer-spy-on': 'error',
'vitest/prefer-strict-equal': 'error',
'vitest/prefer-to-have-length': 'error',
'vitest/prefer-todo': 'error',
'vitest/require-hook': 'error',
'vitest/require-top-level-describe': 'error',
},
},
],
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { name, version } from '../package.json'
import { node } from './configs/node'
import { react } from './configs/react'
import { recommended } from './configs/recommended'
import { vitest } from './configs/vitest'

const plugin: ESLint.Plugin = {
configs: {
node,
react,
recommended,
vitest,
},
meta: {
name,
Expand Down

0 comments on commit c631db4

Please sign in to comment.