Skip to content

Commit

Permalink
Some jest-related changes to base config
Browse files Browse the repository at this point in the history
  • Loading branch information
burtek committed Apr 9, 2022
1 parent d7fc620 commit ca582b6
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 46 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ To use any of the configs put `@dtrw/eslint-config/<name>` in your eslint config
}
```

## Available configs

name | notes
----------------------------|-------------
`eslint-config-base` | Base config, using some `eslint` and [`typescript-eslint`](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) rules as well as rules from eslint plugins [`import`](https://www.npmjs.com/package/eslint-plugin-import), [`jest`](https://www.npmjs.com/package/eslint-plugin-jest), [`jest-formatting`](https://www.npmjs.com/package/eslint-plugin-jest-formatting), [`jsonc`](https://www.npmjs.com/package/eslint-plugin-jsonc) and [`promise`](https://www.npmjs.com/package/eslint-plugin-promise)
`eslint-config-react` | Config for reactJS and react-native projects, using rules from eslint plugins [`react`](https://www.npmjs.com/package/eslint-plugin-react) and [`react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks). **Extends eslint-config-base**
`eslint-config-react-a11y` | Config for reactJS projects, using rules from eslint plugin [`jsx-a11y`](https://www.npmjs.com/package/eslint-plugin-jsx-a11y). **Extends eslint-config-react**
`eslint-config-lodash` | Config for projects making use of `lodash` library, using rules from eslint [`lodash`](https://www.npmjs.com/package/eslint-plugin-lodash) plugin. This is an additional config, not extending any of the above ones
`eslint-config-node` | Config for `nodeJS` projects using rules from eslint [`n`](https://www.npmjs.com/package/eslint-plugin-n) and [`security-node`](https://www.npmjs.com/package/eslint-plugin-security-node) plugins. **Extends eslint-config-base**
## Available main configs

name | notes | extends | Rules sources
------|-------|---------|--------------
`eslint-config-base` | Base config for both JS and TS projects | <ul><li>`@typescript-eslint/eslint-recommended`</li><li>`import/typescript`</li></ul> | <ul><li>`eslint`</li><li>[`typescript-eslint`](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)</li><li>[`import`](https://www.npmjs.com/package/eslint-plugin-import)</li><li>[`jest`](https://www.npmjs.com/package/eslint-plugin-jest)</li><li>[`jest-formatting`](https://www.npmjs.com/package/eslint-plugin-jest-formatting)</li><li>[`jsonc`](https://www.npmjs.com/package/eslint-plugin-jsonc)</li><li>[`promise`](https://www.npmjs.com/package/eslint-plugin-promise)</li></ul>
`eslint-config-react` | Config for reactJS and react-native projects | <ul><li>`react-hooks/recommended`</li><li>`@dtrw/eslint-config/eslint-config-base`</li></ul> | <ul><li>All from `@dtrw/eslint-config/eslint-config-base`</li><li>[`react`](https://www.npmjs.com/package/eslint-plugin-react)</li><li>[`react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks)</li></ul>
`eslint-config-react-a11y` | Config for reactJS and react-native projects with additional `a11y` setup | <ul><li>`@dtrw/eslint-config/eslint-config-react`</li></ul> | <ul><li>All from `@dtrw/eslint-config/eslint-config-react`</li><li>[`jsx-a11y`](https://www.npmjs.com/package/eslint-plugin-jsx-a11y)</li></ul>
`eslint-config-node` | Config for `nodeJS` projects | <ul><li>`n/recommended`</li><li>`security-node/recommended`</li><li>`@dtrw/eslint-config/eslint-config-base`</li></ul> | <ul><li>All from `@dtrw/eslint-config/eslint-config-base`</li><li>[`n`](https://www.npmjs.com/package/eslint-plugin-n)</li><li>[`security-node`](https://www.npmjs.com/package/eslint-plugin-security-node)</li></ul>

### Addon configs
Those configs don't extend any of the above main configs

name | notes | extends | Rules sources
------|-------|---------|--------------
`eslint-config-lodash` | Config for projects making use of `lodash` library | _none_ | <ul><li>[`lodash`](https://www.npmjs.com/package/eslint-plugin-lodash)</li></ul>
83 changes: 46 additions & 37 deletions eslint-config-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,46 +239,55 @@ module.exports = {
rules: {
'no-console': 'off',
'no-magic-numbers': 'off',
'no-redeclare': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-magic-numbers': 'off',
'@typescript-eslint/no-redeclare': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off'
}
},
{
files: ['*.test.js', '*.test.jsx', '*.test.ts', '*.test.tsx'],
extends: [
'plugin:jest-formatting/strict',
'plugin:jest/recommended',
'plugin:jest/style'
],
rules: {
'jest/consistent-test-it': 'error',
'jest/no-conditional-in-test': 'error',
'jest/no-duplicate-hooks': 'error',
'jest/no-test-return-statement': 'error',
'jest/prefer-hooks-on-top': 'error',
'jest/prefer-strict-equal': 'error',
'jest/prefer-todo': 'error'
}
'no-redeclare': 'off'
},
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-magic-numbers': 'off',
'@typescript-eslint/no-redeclare': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off'
}
},
{
files: ['*.test.*'],
extends: [
'plugin:jest-formatting/strict',
'plugin:jest/recommended',
'plugin:jest/style'
],
rules: {
'jest/consistent-test-it': 'error',
'jest/no-conditional-in-test': 'error',
'jest/no-duplicate-hooks': 'error',
'jest/no-test-return-statement': 'error',
'jest/prefer-hooks-on-top': 'error',
'jest/prefer-strict-equal': 'error',
'jest/prefer-todo': 'error'
}
}
]
},
{
files: ['*.json', '*.json5', '*.jsonc'],
parser: 'jsonc-eslint-parser'
},
{
files: ['*.json'],
excludedFiles: ['tsconfig.json', 'jsconfig.json'],
extends: ['plugin:jsonc/recommended-with-json']
},
{
files: ['*.jsonc', 'tsconfig.json', 'jsconfig.json'],
extends: ['plugin:jsonc/recommended-with-jsonc']
},
{
files: ['*.json5'],
extends: ['plugin:jsonc/recommended-with-json5']
parser: 'jsonc-eslint-parser',
overrides: [
{
files: ['*.json'],
excludedFiles: ['tsconfig.json', 'jsconfig.json'],
extends: ['plugin:jsonc/recommended-with-json']
},
{
files: ['*.jsonc', 'tsconfig.json', 'jsconfig.json'],
extends: ['plugin:jsonc/recommended-with-jsonc']
},
{
files: ['*.json5'],
extends: ['plugin:jsonc/recommended-with-json5']
}
]
}
],
reportUnusedDisableDirectives: true,
Expand Down

0 comments on commit ca582b6

Please sign in to comment.