Skip to content

Commit 2eae8fd

Browse files
amir-rahmaniiASafaeirad
authored andcommitted
feat(typescript): add new rules
1 parent f9ca602 commit 2eae8fd

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/modules/typescript.mjs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { parser, plugin } from 'typescript-eslint';
22

3-
import { predicate } from '../utils/conditions.mjs';
3+
import { predicate, strict } from '../utils/conditions.mjs';
44
import { globs } from '../utils/globs.mjs';
55
import { namingConvention } from '../utils/naming-convention.mjs';
66

@@ -37,15 +37,15 @@ function typescript(options = {}) {
3737
'@typescript-eslint/camelcase': 'off',
3838
'@typescript-eslint/class-literal-property-style': ['error', 'getters'],
3939
'@typescript-eslint/consistent-generic-constructors': ['warn', 'constructor'],
40-
'@typescript-eslint/consistent-indexed-object-style': 'off',
40+
'@typescript-eslint/consistent-indexed-object-style': 'warn',
4141
'@typescript-eslint/consistent-type-assertions': 'error',
4242
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
4343
'@typescript-eslint/consistent-type-imports': [
4444
'warn',
4545
{ prefer: 'type-imports', disallowTypeAnnotations: false, fixStyle: 'separate-type-imports' },
4646
],
4747
'@typescript-eslint/default-param-last': 'warn',
48-
'@typescript-eslint/explicit-function-return-type': 'off',
48+
'@typescript-eslint/explicit-function-return-type': strict(options, 'warn'),
4949
'@typescript-eslint/explicit-member-accessibility': 'off',
5050
'@typescript-eslint/explicit-module-boundary-types': 'off',
5151
'@typescript-eslint/generic-type-naming': 'off',
@@ -74,7 +74,7 @@ function typescript(options = {}) {
7474
'@typescript-eslint/no-dynamic-delete': 'error',
7575
'@typescript-eslint/no-empty-function': 'error',
7676
'@typescript-eslint/no-empty-object-type': ['warn', { allowInterfaces: 'with-single-extends' }],
77-
'@typescript-eslint/no-explicit-any': 'off',
77+
'@typescript-eslint/no-explicit-any': strict(options, 'warn'),
7878
'@typescript-eslint/no-extra-non-null-assertion': 'error',
7979
'@typescript-eslint/no-extraneous-class': ['warn', { allowWithDecorator: true }],
8080
'@typescript-eslint/no-import-type-side-effects': 'warn',
@@ -96,12 +96,12 @@ function typescript(options = {}) {
9696
'@typescript-eslint/no-this-alias': 'error',
9797
'@typescript-eslint/no-type-alias': 'off',
9898
'@typescript-eslint/no-unnecessary-type-constraint': 'warn',
99-
'@typescript-eslint/no-unsafe-argument': 'off',
100-
'@typescript-eslint/no-unsafe-assignment': 'off',
101-
'@typescript-eslint/no-unsafe-call': 'off',
99+
'@typescript-eslint/no-unsafe-argument': strict(options, 'warn'),
100+
'@typescript-eslint/no-unsafe-assignment': strict(options, 'warn'),
101+
'@typescript-eslint/no-unsafe-call': strict(options, 'warn'),
102102
'@typescript-eslint/no-unsafe-declaration-merging': 'warn',
103-
'@typescript-eslint/no-unsafe-member-access': 'off',
104-
'@typescript-eslint/no-unsafe-return': 'off',
103+
'@typescript-eslint/no-unsafe-member-access': strict(options, ['warn', { allowOptionalChaining: true }]),
104+
'@typescript-eslint/no-unsafe-return': strict(options, 'warn'),
105105
'@typescript-eslint/no-untyped-public-signature': 'off',
106106
'@typescript-eslint/no-unused-expressions': 'error',
107107
'@typescript-eslint/no-unused-vars': [
@@ -171,6 +171,7 @@ function typescript(options = {}) {
171171
'@typescript-eslint/no-unnecessary-type-conversion': 'error',
172172
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
173173
'@typescript-eslint/no-unsafe-enum-comparison': 'warn',
174+
'@typescript-eslint/no-unsafe-function-type': 'warn',
174175
'@typescript-eslint/no-unnecessary-condition': [
175176
'warn',
176177
{
@@ -215,9 +216,6 @@ function typescript(options = {}) {
215216
'consistent-return': 'off',
216217
}),
217218

218-
// open issues
219-
'react/jsx-no-useless-fragment': 'off', // Need useless-fragment for JSX return type
220-
221219
// Conflicts with @typescript-eslint
222220
'no-empty-function': 'off',
223221
'default-case': 'off',

0 commit comments

Comments
 (0)