chore: add @vitest/eslint-plugin (#630)

This commit is contained in:
Marco Pasqualetti
2025-03-08 21:11:28 +01:00
committed by GitHub
parent 81e7af6f5e
commit da194524ee
9 changed files with 69 additions and 11 deletions
+30 -2
View File
@@ -5,9 +5,19 @@ import eslintPluginImport from 'eslint-plugin-import'
import eslintPluginReact from 'eslint-plugin-react'
// @ts-expect-error no types are available for this plugin
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
import eslintPluginVitest from '@vitest/eslint-plugin'
const REACT_FILES_MATCH =
'packages/{tuono,tuono-router}/**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'
const JS_EXTENSIONS_MATCH = [
'js',
'mjs',
'cjs',
'jsx',
'mjsx',
'ts',
'tsx',
'mtsx',
].join(',')
const REACT_FILES_MATCH = `packages/{tuono,tuono-router}/**/*.{${JS_EXTENSIONS_MATCH}}`
/** @type import('typescript-eslint').ConfigArray */
const tuonoEslintConfig = tseslint.config(
@@ -172,6 +182,24 @@ const tuonoEslintConfig = tseslint.config(
// #endregion misc
},
},
{
files: [`packages/**/*.spec.{${JS_EXTENSIONS_MATCH}}`],
plugins: { vitest: eslintPluginVitest },
rules: {
...eslintPluginVitest.configs.recommended.rules,
'vitest/consistent-test-filename': [
'error',
{
pattern: '.*\\.spec\\.[tj]sx?$',
allTestPattern: '.*\\.(test|spec)\\.[tj]sx?$',
},
],
'vitest/consistent-test-it': 'error',
'vitest/max-expects': 'error',
'vitest/max-nested-describe': ['error', { max: 3 }],
},
},
)
export default tuonoEslintConfig