@@ -7,9 +7,14 @@ const DEFAULT_OPTIONS = {
7
7
const DEFAULT_CONFIG = {
8
8
extends : [ 'uber-es2015' , 'prettier' , 'prettier/react' , 'plugin:import/errors' ] ,
9
9
plugins : [ 'import' ] ,
10
- parser : 'babel- eslint' ,
10
+ parser : '@ babel/ eslint-parser ' ,
11
11
parserOptions : {
12
- ecmaVersion : 2020
12
+ ecmaVersion : 2020 ,
13
+ // @babel /eslint-parser issues https://github.com/babel/babel/issues/11975
14
+ requireConfigFile : false ,
15
+ babelOptions : {
16
+ configFile : './babel.config.js'
17
+ }
13
18
} ,
14
19
env : {
15
20
// Note: also sets ecmaVersion
@@ -30,44 +35,93 @@ const DEFAULT_CONFIG = {
30
35
'import/no-unresolved' : [ 'error' ] ,
31
36
'import/no-extraneous-dependencies' : [ 'error' , { devDependencies : false , peerDependencies : true } ]
32
37
} ,
38
+ settings : {
39
+ // Ensure eslint finds typescript files
40
+ 'import/resolver' : {
41
+ node : {
42
+ extensions : [ '.js' , '.jsx' , '.mjs' , '.ts' , '.tsx' , '.d.ts' ]
43
+ }
44
+ }
45
+ } ,
33
46
ignorePatterns : [ 'node_modules' , '**/dist*/**/*.js' ] ,
34
47
overrides : [
35
48
{
36
49
// babel-eslint can process TS files, but it doesn't understand types
37
50
// typescript-eslint has some more advanced rules with type checking
38
- files : [ '**/*.ts' , '**/*.tsx' ] ,
51
+ files : [ '**/*.ts' , '**/*.tsx' , '**/*.d.ts' ] ,
39
52
parser : '@typescript-eslint/parser' ,
40
53
parserOptions : {
41
54
sourceType : 'module' , // we want to use ES modules
42
55
project : './tsconfig.json'
43
56
} ,
44
57
plugins : [ '@typescript-eslint' ] ,
45
58
rules : {
46
- ...typescriptConfigs [ 'eslint-recommended' ] . rules ,
47
- ...typescriptConfigs . recommended . rules ,
48
- ...typescriptConfigs [ 'recommended-requiring-type-checking' ] . rules ,
59
+ // Standard rules
60
+
61
+ // We still have some issues with import resolution
62
+ 'import/named' : 0 ,
63
+ 'import/no-extraneous-dependencies' : [ 'warn' ] ,
64
+ // Warn instead of error
65
+ 'max-params' : [ 'warn' ] ,
66
+ 'no-undef' : [ 'warn' ] ,
67
+ camelcase : [ 'warn' ] ,
49
68
indent : [ 'warn' , 2 , { SwitchCase : 1 } ] ,
50
69
quotes : [ 'warn' , 'single' ] ,
51
70
'no-process-env' : 'off' ,
52
- '@typescript-eslint/no-unused-vars' : [ 'warn' ] ,
53
- '@typescript-eslint/no-explicit-any' : 0 ,
54
- '@typescript-eslint/switch-exhaustiveness-check' : [ 'error' ] ,
71
+
72
+ // typescript rules
73
+
74
+ ...typescriptConfigs [ 'eslint-recommended' ] . rules ,
75
+ ...typescriptConfigs . recommended . rules ,
76
+ ...typescriptConfigs [ 'recommended-requiring-type-checking' ] . rules ,
77
+
55
78
// Some of JS rules don't always work correctly in TS and
56
79
// hence need to be reimported as TS rules
57
80
'no-redeclare' : 'off' ,
58
- '@typescript-eslint/no-redeclare' : [ 'warn' ] ,
59
81
'no-shadow' : 'off' ,
60
- '@typescript-eslint/no-shadow' : [ 'warn' ] ,
61
82
'no-use-before-define' : 'off' ,
62
- '@typescript-eslint/no-use-before-define' : [ 'error' ] ,
63
83
'no-dupe-class-members' : 'off' ,
64
- '@typescript-eslint/no-dupe-class-members' : [ 'error' ]
84
+
85
+ // TODO - These rules are sometimes not found?
86
+ // '@typescript-eslint/no-shadow': ['warn'],
87
+ // '@typescript-eslint/no-redeclare': ['warn'],
88
+
89
+ // We use function hoisting to put exports at top of file
90
+ '@typescript-eslint/no-use-before-define' : 'off' ,
91
+ '@typescript-eslint/no-dupe-class-members' : [ 'error' ] ,
92
+
93
+ // We encourage explicit typing, e.g `field: string = ''`
94
+ '@typescript-eslint/no-inferrable-types' : 'off' ,
95
+
96
+ '@typescript-eslint/no-empty-interface' : [ 'warn' ] ,
97
+ '@typescript-eslint/restrict-template-expressions' : [ 'warn' ] ,
98
+ '@typescript-eslint/explicit-module-boundary-types' : [ 'warn' ] ,
99
+ '@typescript-eslint/require-await' : [ 'warn' ] ,
100
+ '@typescript-eslint/no-unsafe-return' : [ 'warn' ] ,
101
+ '@typescript-eslint/no-unsafe-call' : [ 'warn' ] ,
102
+
103
+ // some day we will hopefully be able to enable this rule
104
+ '@typescript-eslint/no-explicit-any' : 'off' ,
105
+ '@typescript-eslint/ban-ts-comment' : [ 'warn' ] ,
106
+ '@typescript-eslint/ban-types' : [ 'warn' ] ,
107
+ '@typescript-eslint/no-unsafe-member-access' : [ 'warn' ] ,
108
+ '@typescript-eslint/no-unsafe-assignment' : [ 'warn' ] ,
109
+ '@typescript-eslint/no-var-requires' : [ 'warn' ] ,
110
+ '@typescript-eslint/no-unused-vars' : [ 'warn' ] ,
111
+ '@typescript-eslint/switch-exhaustiveness-check' : [ 'error' ] ,
112
+ '@typescript-eslint/no-floating-promises' : [ 'warn' ] ,
113
+ '@typescript-eslint/await-thenable' : [ 'warn' ] ,
114
+ '@typescript-eslint/no-misused-promises' : [ 'warn' ] ,
115
+ '@typescript-eslint/restrict-plus-operands' : [ 'warn' ] ,
116
+ '@typescript-eslint/no-empty-function' : [ 'warn' ]
65
117
}
66
118
} ,
67
119
{
68
120
// We can lint through code examples in Markdown as well,
69
121
// but we don't need to enable all of the rules there
70
122
files : [ '**/*.md' ] ,
123
+ plugins : [ 'markdown' ] ,
124
+ // extends: 'plugin:markdown/recommended',
71
125
rules : {
72
126
'no-undef' : 'off' ,
73
127
'no-unused-vars' : 'off' ,
0 commit comments