Skip to content

Commit

Permalink
Add specific configs for:
Browse files Browse the repository at this point in the history
* Unit tests
* Cypress
* Typescript definition files
* Node files
  • Loading branch information
osmestad committed Sep 7, 2023
1 parent 3a86faa commit 70a8f8d
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 2 deletions.
55 changes: 55 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import typedReduxSagaPlugin from '@jambit/eslint-plugin-typed-redux-saga';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import eslintConfigPrettier from 'eslint-config-prettier';
import cypress from 'eslint-plugin-cypress';
import importPlugin from 'eslint-plugin-import';
import istanbul from 'eslint-plugin-istanbul';
import noOnlyTestsPlugin from 'eslint-plugin-no-only-tests';
import prettier from 'eslint-plugin-prettier';
import sortDestructureKeysPlugin from 'eslint-plugin-sort-destructure-keys';
import sortKeysFixPlugin from 'eslint-plugin-sort-keys-fix';
import tsSortKeysPlugin from 'eslint-plugin-typescript-sort-keys';
import vitest from 'eslint-plugin-vitest';
import globals from 'globals';

// mimic CommonJS variables -- not needed if using CommonJS
Expand Down Expand Up @@ -329,4 +332,56 @@ export default [
},
},
},
// Cypress
{
files: ['**/*.cy.ts'],
languageOptions: {
globals: cypress.environments.globals.globals,
},
plugins: {
cypress,
'no-only-tests': noOnlyTestsPlugin,
},
rules: {
...cypress.configs.recommended.rules,
'cypress/no-force': 'error',
'cypress/unsafe-to-chain-command': 'warn',
'no-only-tests/no-only-tests': 'error',
},
},
// For unit tests
{
files: ['**/*.test.ts', '**/*.test.tsx', '__mocks__/**/*.ts'],
ignores: ['**/*.auto.test.tsx'],
languageOptions: {
// @ts-expect-error
globals: vitest.environments.env.globals,
},
plugins: { vitest },
rules: {
// @ts-expect-error
...vitest.configs.recommended.rules,
'vitest/prefer-to-be': 'off',
'vitest/prefer-todo': 'error',
},
},
// Typescript type definitions
{
files: ['**/*.d.ts'],
rules: {
'@typescript-eslint/consistent-type-definitions': 'off',
'no-var': 'off',
'one-var': 'off',
'vars-on-top': 'off',
},
},
// For Node.js scripts
{
files: ['**/scripts/*'],
languageOptions: {
globals: {
...globals.node,
},
},
},
];
111 changes: 109 additions & 2 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@
"eslint-config-xo": "0.43.1",
"eslint-config-xo-react": "0.27.0",
"eslint-config-xo-typescript": "1.0.1",
"eslint-plugin-cypress": "^2.14.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-istanbul": "0.1.2",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
Expand Down

0 comments on commit 70a8f8d

Please sign in to comment.