-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathts.js
74 lines (69 loc) · 3.8 KB
/
ts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const jsConfig = require('./index.js');
const typescriptEslint = require('typescript-eslint');
// Configuration that extends the JavaScript config with TypeScript rules.
module.exports = [
// Include our base JavaScript config.
...jsConfig,
// Use the recommended TypeScript configs as a base, follow up with our overrides.
...typescriptEslint.configs.recommended.map((conf) => ({
...conf,
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
})),
{
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
plugins: {
'@typescript-eslint': typescriptEslint.plugin,
},
languageOptions: {
parser: typescriptEslint.parser,
ecmaVersion: 2022,
},
rules: {
// Note: you must disable the base rule as it can report incorrect errors.
'no-shadow': 'off',
// This rule extends the base eslint/no-shadow rule. It adds support for TypeScript's this parameters and global augmentation, and adds options for TypeScript features.
'@typescript-eslint/no-shadow': ['error'],
// Not allowing non-null assertions is overly strict.
'@typescript-eslint/no-non-null-assertion': 'off',
// Note: you must disable the base rule as it can report incorrect errors.
'no-useless-constructor': 'off',
// This rule extends the base eslint/no-useless-constructor rule for TypeScript.
'@typescript-eslint/no-useless-constructor': 'error',
// Note: you must disable the base rule as it can report incorrect errors.
'default-param-last': 'off',
// This rule extends the base eslint/default-param-last rule for TypeScript.
'@typescript-eslint/default-param-last': 'error',
// Force promises to be awaited, returned, voided, .then()ed or .catch()ed.
'@typescript-eslint/no-floating-promises': 'error',
// Disallow the use of promises in places where they shouldn't be used.
'@typescript-eslint/await-thenable': 'error',
// Do not misuse promises in places like if conditions, or passing them to functions that don't handle promises.
'@typescript-eslint/no-misused-promises': ['error', {
checksVoidReturn: {
arguments: false,
attributes: false,
},
}],
// Require methods and functions to be marked async if they return a Promise.
'@typescript-eslint/promise-function-async': 'error',
// Force the usage of "import type" for type imports.
'@typescript-eslint/consistent-type-imports': 'error',
// Force consistent array type definitions.
'@typescript-eslint/array-type': 'error',
// Force better grouping of overloaded signatures.
'@typescript-eslint/adjacent-overload-signatures': 'error',
// Disallow "in" operator with arrays. It is better to use "of".
'@typescript-eslint/no-for-in-array': 'error',
// Avoid using eval().
'@typescript-eslint/no-implied-eval': 'error',
// Avoid type specifications that are not necessary.
'@typescript-eslint/no-inferrable-types': 'error',
// Disallow usage of non-null assertion "!" next to an assignment or equality check.
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
// Prefer "includes()" over "indexOf() !== -1" when checking for existence.
'@typescript-eslint/prefer-includes': 'error',
// Allow to use underscore as a way to ignore unused args.
'@typescript-eslint/no-unused-vars': ['error', { 'argsIgnorePattern': '^_', 'ignoreRestSiblings': true }],
},
},
];