Skip to content

Commit

Permalink
Add eslint-plugin-jest-dom and testing-library (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous authored Jan 29, 2024
1 parent ea2c4c5 commit efa71f4
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
"concurrently": "^8.2.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest-dom": "^5.1.0",
"eslint-plugin-sonarjs": "^0.23.0",
"eslint-plugin-svelte": "^2.35.1",
"eslint-plugin-tailwindcss": "^3.14.0",
"eslint-plugin-testing-library": "^6.2.0",
"eslint-plugin-unicorn": "^50.0.1",
"eslint-plugin-vitest": "^0.3.20",
"prettier": "^3.2.4",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ pnpm add --save-dev \
@typescript-eslint/eslint-plugin \
eslint \
eslint-config-prettier \
eslint-plugin-jest-dom \
eslint-plugin-sonarjs \
eslint-plugin-svelte \
eslint-plugin-tailwindcss \
eslint-plugin-testing-library \
eslint-plugin-unicorn \
eslint-plugin-vitest
```
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config/base.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ module.exports = {
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'sonarjs/no-duplicate-string': 'off',
'unicorn/consistent-function-scoping': 'off',
'vitest/consistent-test-filename': [
'error',
{
Expand Down
10 changes: 9 additions & 1 deletion 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 @@ -45,19 +45,27 @@
"@typescript-eslint/parser": ">=6 <7",
"eslint": ">=8 <9",
"eslint-config-prettier": ">=9 <10",
"eslint-plugin-jest-dom": ">=5 <6",
"eslint-plugin-sonarjs": ">=0.19 <0.24",
"eslint-plugin-svelte": ">=2 <3",
"eslint-plugin-tailwindcss": ">=3 <4",
"eslint-plugin-testing-library": ">=6 <7",
"eslint-plugin-unicorn": ">=47 <51",
"eslint-plugin-vitest": ">=0.3 <0.4"
},
"peerDependenciesMeta": {
"eslint-plugin-jest-dom": {
"optional": true
},
"eslint-plugin-svelte": {
"optional": true
},
"eslint-plugin-tailwindcss": {
"optional": true
},
"eslint-plugin-testing-library": {
"optional": true
},
"eslint-plugin-vitest": {
"optional": true
}
Expand Down
25 changes: 25 additions & 0 deletions packages/eslint-config/svelte.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,30 @@ module.exports = {
'no-undef-init': 'off',
},
},
// Rules for tests
{
files: ['**/__tests__/**', '**/*.test.ts', '**/*.spec.ts'],
extends: [
'plugin:vitest/recommended',
'plugin:jest-dom/recommended',
'plugin:testing-library/dom',
],
rules: {
'testing-library/await-async-events': [
'error',
{ eventModule: ['fireEvent', 'userEvent'] },
],
'testing-library/no-await-sync-events': 'off',
'testing-library/no-node-access': [
'error',
{ allowContainerFirstChild: true },
],
'testing-library/prefer-explicit-assert': [
'error',
{ assertion: 'toBeInTheDocument' },
],
'testing-library/prefer-user-event': 'error',
},
},
],
};
128 changes: 128 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit efa71f4

Please sign in to comment.