Skip to content

Commit 9d68d0c

Browse files
committed
Enable type-aware linting for TS, specifically
no-unnecessary-type-assertions. This required reorganizing the eslint config and adjusting tsconfig to keep the typeaware linting overhead minimal.
1 parent 9326bf1 commit 9d68d0c

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

.eslintrc.yml

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@ env:
44
node: true
55
plugins:
66
- prettier
7-
- '@typescript-eslint'
7+
parser: '@typescript-eslint/parser'
88
extends:
99
- 'eslint:recommended'
1010
- 'plugin:prettier/recommended'
11-
- 'plugin:@typescript-eslint/recommended'
12-
parser: '@typescript-eslint/parser' # for index.d.ts
11+
parserOptions:
12+
ecmaVersion: 2020
13+
sourceType: module
1314
globals:
1415
Atomics: readonly
1516
BigInt: readonly
1617
SharedArrayBuffer: readonly
1718
globalThis: readonly
18-
parserOptions:
19-
ecmaVersion: 2020
20-
sourceType: module
2119
ignorePatterns:
2220
- node_modules/
2321
- /dist/
@@ -38,7 +36,6 @@ rules:
3836
- error
3937
- multi-line
4038
func-call-spacing: off
41-
'@typescript-eslint/func-call-spacing': error
4239
function-call-argument-newline:
4340
- error
4441
- consistent
@@ -78,14 +75,6 @@ rules:
7875
- avoidEscape: true
7976
semi: error
8077
space-infix-ops: error
81-
'@typescript-eslint/explicit-module-boundary-types': off
82-
'@typescript-eslint/no-empty-function': off
83-
'@typescript-eslint/no-empty-interface':
84-
- error
85-
- allowSingleExtends: true
86-
'@typescript-eslint/no-var-requires': off
87-
'@typescript-eslint/ban-ts-comment': off
88-
'@typescript-eslint/no-explicit-any': off # TODO turn this back on
8978
overrides:
9079
- files:
9180
- lib/duration.ts
@@ -100,3 +89,28 @@ overrides:
10089
- test/**/*
10190
rules:
10291
no-param-reassign: off
92+
- files:
93+
- '**/*.ts'
94+
plugins:
95+
- '@typescript-eslint'
96+
parserOptions:
97+
ecmaVersion: 2020
98+
sourceType: module
99+
project:
100+
- './tsconfig.json'
101+
extends:
102+
- 'plugin:@typescript-eslint/recommended'
103+
# TODO turn this on - it catches lots of implicit 'any's
104+
# - 'plugin:@typescript-eslint/recommended-requiring-type-checking'
105+
rules:
106+
'@typescript-eslint/explicit-module-boundary-types': off
107+
'@typescript-eslint/no-empty-function': error
108+
'@typescript-eslint/no-empty-interface':
109+
- error
110+
- allowSingleExtends: true
111+
'@typescript-eslint/no-var-requires': off
112+
'@typescript-eslint/ban-ts-comment': off
113+
'@typescript-eslint/no-explicit-any': off # Todo re-enable this
114+
'@typescript-eslint/no-unnecessary-type-assertion': error
115+
'@typescript-eslint/func-call-spacing': error
116+
prefer-const: off

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"compileOnSave": false,
3+
"include": ["lib/*.ts"],
34
"compilerOptions": {
45
"allowUnreachableCode": false,
56
"downlevelIteration": true,

0 commit comments

Comments
 (0)