-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from alexrecuenco/feature/flat-config
Feature/flat config
- Loading branch information
Showing
6 changed files
with
289 additions
and
1,440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,6 @@ dist/ | |
.vscode/ | ||
node_modules/ | ||
coverage/ | ||
!.eslintrc.js | ||
!.prettierrc.js | ||
!*.js | ||
!*.ts | ||
!.vscode/*.json |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
const stylistic = require('@stylistic/eslint-plugin'); | ||
const js = require('@eslint/js'); | ||
const tseslint = require('typescript-eslint'); | ||
|
||
const ts = require('@typescript-eslint/eslint-plugin'); | ||
const tsParser = require('@typescript-eslint/parser'); | ||
// When it works again do `npm install --save-dev eslint-plugin-import` | ||
// const imprt = require('eslint-plugin-import'); | ||
// https://github.com/eslint/eslint/issues/18087 | ||
// https://github.com/import-js/eslint-plugin-import/pull/2829 | ||
const globals = require('globals'); | ||
const jest = require('eslint-plugin-jest'); | ||
const off = 'off'; | ||
|
||
const warn = 'warn'; | ||
|
||
const error = 'error'; | ||
|
||
// const TEST_ONLY_IMPORTS = ['fast-check', 'jest']; | ||
|
||
/** | ||
* set of typescript-eslint any rules | ||
* @param {'error' | 'warn' | 'off'} level | ||
* @returns | ||
*/ | ||
const any_rules = (level) => { | ||
return { | ||
'@typescript-eslint/no-unsafe-return': level, | ||
'@typescript-eslint/no-var-requires': level, | ||
'@typescript-eslint/no-unsafe-member-access': level, | ||
'@typescript-eslint/no-unsafe-assignment': level, | ||
'@typescript-eslint/no-unsafe-argument': level, | ||
'@typescript-eslint/no-unsafe-call': level, | ||
'@typescript-eslint/no-explicit-any': level, | ||
}; | ||
}; | ||
|
||
module.exports = [ | ||
js.configs.recommended, | ||
...tseslint.configs.recommended, | ||
{ | ||
languageOptions: { | ||
globals: globals.node, | ||
parser: tsParser, | ||
parserOptions: { | ||
ecmaVersion: 2022, | ||
sourceType: 'module', | ||
tsconfigRootDir: __dirname, | ||
project: [ | ||
'./tsconfig.eslint.json', | ||
'./tsconfig.json', | ||
'/tsconfig.prod.json', | ||
], | ||
}, | ||
}, | ||
}, | ||
stylistic.configs['recommended-flat'], | ||
stylistic.configs.customize({ | ||
// the following options are the default values | ||
semi: true, | ||
}), | ||
{ | ||
languageOptions: { parser: tsParser }, | ||
plugins: { | ||
// 'import': imprt, | ||
'@stylistic': stylistic, | ||
ts, | ||
}, | ||
}, | ||
{ | ||
ignores: [ | ||
'**/node_modules', | ||
'**/dist', | ||
'**/build', | ||
'**/__snapshots__', | ||
'**/mocks', | ||
'**/coverage', | ||
'**/report', | ||
], | ||
}, | ||
{ | ||
rules: { | ||
...ts.configs['eslint-recommended'].rules, | ||
...ts.configs['recommended'].rules, | ||
...ts.configs['recommended-requiring-type-checking'].rules, | ||
// ...imprt.configs['errors'].rules, | ||
// ...imprt.configs['warnings'].rules, | ||
// ...imprt.configs['typescript'].rules, | ||
// "import/no-extraneous-dependencies": error, | ||
'no-console': error, | ||
'@typescript-eslint/return-await': ['error', 'always'], | ||
'no-unused-vars': off, | ||
'@typescript-eslint/no-unused-vars': error, | ||
'eqeqeq': [error, 'smart'], | ||
'no-else-return': [ | ||
error, | ||
{ | ||
allowElseIf: true, | ||
}, | ||
], | ||
'@typescript-eslint/require-await': error, | ||
'@typescript-eslint/unbound-method': [ | ||
error, | ||
{ | ||
ignoreStatic: true, | ||
}, | ||
], | ||
// See https://github.com/orgs/react-hook-form/discussions/8622#discussioncomment-4060570 | ||
'@typescript-eslint/no-misused-promises': [ | ||
error, | ||
{ | ||
checksVoidReturn: { | ||
attributes: false, | ||
}, | ||
}, | ||
], | ||
// 'no-restricted-imports': [ | ||
// 'error', | ||
// { | ||
// paths: TEST_ONLY_IMPORTS.map((name) => { | ||
// return { name, | ||
// message: `${name} is only available during testing` }; | ||
// }), | ||
// patterns: TEST_ONLY_IMPORTS.map(dep => `${dep}/*`), | ||
// }, | ||
// ], | ||
'@typescript-eslint/explicit-member-accessibility': warn, | ||
'@typescript-eslint/no-explicit-any': warn, | ||
'@typescript-eslint/explicit-function-return-type': off, | ||
// '@typescript-eslint/no-var-requires': off, | ||
'@typescript-eslint/no-empty-function': off, | ||
'@typescript-eslint/no-floating-promises': error, | ||
}, | ||
}, | ||
{ | ||
files: ['.*.js', '.*.cjs', '*.config.cjs', '*.config.js', '*.config.ts'], | ||
rules: { | ||
'no-restricted-imports': off, | ||
// Consider if this is too leanient for tests | ||
...any_rules('off'), | ||
}, | ||
}, | ||
{ | ||
files: [ | ||
'**/*.test.js', | ||
'**/*.spec.js', | ||
'**/*.test.ts', | ||
'**/*.spec.ts', | ||
'tests/**/*.js', | ||
'tests/**/*.ts', | ||
'__tests__/**/*.js', | ||
'__tests__/**/*.ts', | ||
'jest.*.js', | ||
'jest.*.ts', | ||
], | ||
// https://eslint.org/docs/user-guide/configuring#specifying-environments | ||
languageOptions: { globals: globals.jest }, | ||
plugins: { jest }, | ||
rules: { | ||
...jest.configs['recommended'].rules, | ||
// 'no-restricted-imports': off, | ||
'jest/expect-expect': [ | ||
error, | ||
{ | ||
assertFunctionNames: ['expect', 'fc.assert'], | ||
}, | ||
], | ||
...any_rules('off'), | ||
}, | ||
}, | ||
]; |
Oops, something went wrong.