-
-
Notifications
You must be signed in to change notification settings - Fork 941
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db4f46f
commit 7ef362e
Showing
4 changed files
with
209 additions
and
213 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
// @ts-check | ||
import eslint from '@eslint/js'; | ||
import { readGitignoreFiles } from 'eslint-gitignore'; | ||
import eslintPluginJsdoc from 'eslint-plugin-jsdoc'; | ||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; | ||
import eslintPluginUnicorn from 'eslint-plugin-unicorn'; | ||
import tseslint from 'typescript-eslint'; | ||
|
||
export default tseslint.config( | ||
//#region global | ||
{ | ||
ignores: [ | ||
...readGitignoreFiles(), | ||
'eslint.config.js', // Skip self linting | ||
], | ||
linterOptions: { | ||
reportUnusedDisableDirectives: 'error', | ||
}, | ||
}, | ||
//#endregion | ||
|
||
//#region eslint (js) | ||
eslint.configs.recommended, | ||
{ | ||
rules: { | ||
eqeqeq: ['error', 'always', { null: 'ignore' }], | ||
'logical-assignment-operators': 'error', | ||
'no-else-return': 'error', | ||
'no-restricted-globals': ['error', 'Intl'], | ||
'prefer-exponentiation-operator': 'error', | ||
'prefer-template': 'error', | ||
}, | ||
}, | ||
//#endregion | ||
|
||
//#region typescript-eslint | ||
...tseslint.configs.strictTypeChecked, | ||
{ | ||
plugins: { | ||
'@typescript-eslint': tseslint.plugin, | ||
}, | ||
languageOptions: { | ||
parser: tseslint.parser, | ||
parserOptions: { | ||
project: true, | ||
warnOnUnsupportedTypeScriptVersion: false, | ||
}, | ||
}, | ||
rules: { | ||
'@typescript-eslint/array-type': [ | ||
'error', | ||
{ default: 'array-simple', readonly: 'generic' }, | ||
], | ||
'@typescript-eslint/consistent-type-exports': 'error', | ||
'@typescript-eslint/consistent-type-imports': 'error', | ||
'@typescript-eslint/explicit-module-boundary-types': 'error', | ||
'@typescript-eslint/naming-convention': [ | ||
'error', | ||
{ | ||
format: ['PascalCase'], | ||
selector: ['class', 'interface', 'typeAlias', 'enumMember'], | ||
leadingUnderscore: 'forbid', | ||
trailingUnderscore: 'forbid', | ||
}, | ||
{ | ||
format: ['PascalCase'], | ||
selector: ['typeParameter'], | ||
prefix: ['T'], | ||
leadingUnderscore: 'forbid', | ||
trailingUnderscore: 'forbid', | ||
}, | ||
], | ||
'@typescript-eslint/no-inferrable-types': [ | ||
'error', | ||
{ ignoreParameters: true }, | ||
], | ||
'@typescript-eslint/no-unnecessary-condition': 'off', // requires `strictNullChecks` to be enabled | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-unsafe-call': 'off', | ||
'@typescript-eslint/no-unsafe-member-access': 'off', | ||
'@typescript-eslint/padding-line-between-statements': [ | ||
'error', | ||
{ blankLine: 'always', prev: 'block-like', next: '*' }, | ||
], | ||
'@typescript-eslint/prefer-regexp-exec': 'error', | ||
'@typescript-eslint/restrict-plus-operands': [ | ||
'error', | ||
{ | ||
allowAny: false, | ||
allowBoolean: false, | ||
allowNullish: false, | ||
allowNumberAndString: true, | ||
allowRegExp: false, | ||
}, | ||
], | ||
'@typescript-eslint/restrict-template-expressions': [ | ||
'error', | ||
{ allowNumber: true, allowBoolean: true }, | ||
], | ||
'@typescript-eslint/switch-exhaustiveness-check': [ | ||
'error', | ||
{ requireDefaultForNonUnion: true }, | ||
], | ||
'@typescript-eslint/unbound-method': 'off', | ||
'@typescript-eslint/unified-signatures': 'off', // incompatible with our api docs generation | ||
|
||
// TODO @ST-DDT 2023-10-10: The following rules currently conflict with our code. | ||
// Each rule should be checked whether it should be enabled/configured and the problems fixed, or stay disabled permanently. | ||
'@typescript-eslint/no-confusing-void-expression': 'off', | ||
}, | ||
}, | ||
//#endregion | ||
|
||
// TODO @Shinigami92 2024-04-08: Add eslint-plugin-deprecation later | ||
|
||
//#region unicorn | ||
eslintPluginUnicorn.configs['flat/recommended'], | ||
{ | ||
rules: { | ||
'unicorn/no-array-callback-reference': 'off', // reduces readability | ||
'unicorn/no-nested-ternary': 'off', // incompatible with prettier | ||
'unicorn/no-null': 'off', // incompatible with TypeScript | ||
'unicorn/no-zero-fractions': 'off', // deactivated to raise awareness of floating operations | ||
'unicorn/number-literal-case': 'off', // incompatible with prettier | ||
'unicorn/prefer-ternary': 'off', // ternaries aren't always better | ||
|
||
// TODO @Shinigami92 2023-09-23: The following rules currently conflict with our code. | ||
// Each rule should be checked whether it should be enabled/configured and the problems fixed, or stay disabled permanently. | ||
'unicorn/better-regex': 'off', | ||
'unicorn/consistent-function-scoping': 'off', | ||
'unicorn/import-style': 'off', | ||
'unicorn/no-await-expression-member': 'off', | ||
'unicorn/no-object-as-default-parameter': 'off', | ||
'unicorn/numeric-separators-style': 'off', | ||
'unicorn/prefer-export-from': 'off', | ||
'unicorn/prefer-string-slice': 'off', | ||
'unicorn/prevent-abbreviations': 'off', | ||
'unicorn/require-array-join-separator': 'off', | ||
}, | ||
}, | ||
//#endregion | ||
|
||
//#region jsdoc | ||
eslintPluginJsdoc.configs['flat/recommended-typescript-error'], | ||
{ | ||
rules: { | ||
'jsdoc/require-jsdoc': 'off', // Enabled only for src/**/*.ts | ||
'jsdoc/require-returns': 'off', | ||
'jsdoc/sort-tags': [ | ||
'error', | ||
{ | ||
tagSequence: [ | ||
{ tags: ['template'] }, | ||
{ tags: ['internal'] }, | ||
{ tags: ['param'] }, | ||
{ tags: ['returns'] }, | ||
{ tags: ['throws'] }, | ||
{ tags: ['see'] }, | ||
{ tags: ['example'] }, | ||
{ tags: ['since'] }, | ||
{ tags: ['default'] }, | ||
{ tags: ['deprecated'] }, | ||
], | ||
}, | ||
], | ||
'jsdoc/tag-lines': 'off', | ||
}, | ||
settings: { | ||
jsdoc: { | ||
mode: 'typescript', | ||
}, | ||
}, | ||
}, | ||
//#endregion | ||
|
||
//#region prettier | ||
eslintPluginPrettierRecommended | ||
//#endregion | ||
); |
Oops, something went wrong.