eslint-config-entva-typescript-base 2.7.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +93 -172
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -5,12 +5,23 @@ import typescriptEslint from '@typescript-eslint/eslint-plugin';
5
5
  import tsParser from '@typescript-eslint/parser';
6
6
  import stylisticTs from '@stylistic/eslint-plugin-ts';
7
7
 
8
+ const baseRules = baseConfig.reduce((acc, config) => ({ ...acc, ...config.rules }), {});
9
+
10
+ // Many TS rules mirror JS rules, we need to disable JS rule and apply config for the TS replacement
11
+ const getOverrides = (rules, overridePrefix) => rules.reduce((acc, rule) => {
12
+ acc[rule] = ['off'];
13
+ acc[`${overridePrefix}/${rule}`] = baseRules[rule];
14
+ return acc;
15
+ }, {});
16
+
8
17
  export default [
9
18
  ...baseConfig,
10
19
  {
11
20
  files: [
12
21
  '**/*.test.ts',
22
+ '**/*.test.tsx',
13
23
  '**/*.spec.ts',
24
+ '**/*.spec.tsx',
14
25
  ],
15
26
  languageOptions: {
16
27
  globals: {
@@ -19,7 +30,7 @@ export default [
19
30
  },
20
31
  },
21
32
  {
22
- files: ['**/*.ts'],
33
+ files: ['**/*.{ts,tsx}'],
23
34
  plugins: {
24
35
  import: importPlugin,
25
36
  '@typescript-eslint': typescriptEslint,
@@ -43,38 +54,88 @@ export default [
43
54
  ecmaFeatures: {
44
55
  generators: false,
45
56
  objectLiteralDuplicateProperties: false,
57
+ jsx: true,
46
58
  },
47
59
  },
48
60
  },
49
61
 
50
62
  settings: {
51
63
  'import/parsers': {
52
- '@typescript-eslint/parser': ['.ts', '.d.ts'],
64
+ '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
53
65
  },
54
66
 
55
67
  'import/resolver': {
56
68
  node: {
57
- extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
69
+ extensions: ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.d.ts', '.json'],
58
70
  },
59
71
  },
60
72
 
61
- 'import/extensions': ['.mjs', '.js', '.json', '.ts', '.d.ts'],
73
+ 'import/extensions': ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.d.ts', '.json'],
62
74
  'import/external-module-folders': ['node_modules', 'node_modules/@types'],
63
75
  'import/core-modules': [],
64
76
  'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$'],
65
77
  },
66
78
 
67
79
  rules: {
68
- '@stylistic/ts/member-delimiter-style': ['error', {
69
- multiline: {
70
- delimiter: 'comma',
71
- },
80
+ ...baseRules,
81
+ ...getOverrides(
82
+ [
83
+ 'no-array-constructor',
84
+ 'no-useless-constructor',
85
+ 'no-empty-function',
86
+ 'no-dupe-class-members',
87
+ 'default-param-last',
88
+ 'dot-notation',
89
+ 'naming-convention',
90
+ 'no-unused-vars',
91
+ 'no-shadow',
92
+ ],
93
+ '@typescript-eslint',
94
+ ),
95
+ ...getOverrides(
96
+ [
97
+ 'space-before-function-paren',
98
+ 'lines-between-class-members',
99
+ 'space-before-blocks',
100
+ 'brace-style',
101
+ 'indent',
102
+ 'keyword-spacing',
103
+ 'space-infix-ops',
104
+ 'comma-spacing',
105
+ 'comma-dangle',
106
+ 'object-curly-spacing',
107
+ 'quotes',
108
+ ],
109
+ '@stylistic/ts',
110
+ ),
72
111
 
73
- singleline: {
74
- delimiter: 'comma',
75
- },
112
+ '@typescript-eslint/no-implied-eval': ['error'],
113
+ '@typescript-eslint/no-loss-of-precision': ['error'],
114
+ '@typescript-eslint/no-loop-func': ['error'],
115
+ '@typescript-eslint/no-magic-numbers': ['off', {
116
+ ignore: [],
117
+ ignoreArrayIndexes: true,
118
+ enforceConst: true,
119
+ detectObjects: false,
76
120
  }],
77
121
 
122
+ '@typescript-eslint/no-redeclare': ['error'],
123
+ '@typescript-eslint/no-unused-expressions': ['error', {
124
+ allowShortCircuit: false,
125
+ allowTernary: false,
126
+ allowTaggedTemplates: false,
127
+ enforceForJSX: false,
128
+ }],
129
+
130
+ '@typescript-eslint/no-use-before-define': ['error', {
131
+ functions: true,
132
+ classes: true,
133
+ variables: true,
134
+ }],
135
+
136
+ '@typescript-eslint/require-await': ['off'],
137
+ '@typescript-eslint/return-await': ['error', 'in-try-catch'],
138
+
78
139
  '@typescript-eslint/no-explicit-any': ['error', {
79
140
  ignoreRestArgs: true,
80
141
  }],
@@ -93,117 +154,6 @@ export default [
93
154
  leadingUnderscore: 'allowSingleOrDouble',
94
155
  }],
95
156
 
96
- '@stylistic/ts/brace-style': ['error', '1tbs', {
97
- allowSingleLine: true,
98
- }],
99
-
100
- '@stylistic/ts/comma-dangle': ['error', {
101
- arrays: 'always-multiline',
102
- objects: 'always-multiline',
103
- imports: 'always-multiline',
104
- exports: 'always-multiline',
105
- functions: 'always-multiline',
106
- enums: 'always-multiline',
107
- generics: 'always-multiline',
108
- tuples: 'always-multiline',
109
- }],
110
-
111
- '@stylistic/ts/comma-spacing': ['error', {
112
- before: false,
113
- after: true,
114
- }],
115
-
116
- 'default-param-last': ['off'],
117
- '@typescript-eslint/default-param-last': ['error'],
118
-
119
- '@typescript-eslint/dot-notation': ['error', {
120
- allowKeywords: true,
121
- allowPattern: '',
122
- allowPrivateClassPropertyAccess: false,
123
- allowProtectedClassPropertyAccess: false,
124
- allowIndexSignaturePropertyAccess: false,
125
- }],
126
-
127
- '@stylistic/ts/func-call-spacing': ['error', 'never'],
128
-
129
- '@stylistic/ts/indent': ['error', 2, {
130
- SwitchCase: 1,
131
- VariableDeclarator: 1,
132
- outerIIFEBody: 1,
133
-
134
- FunctionDeclaration: {
135
- parameters: 1,
136
- body: 1,
137
- },
138
-
139
- FunctionExpression: {
140
- parameters: 1,
141
- body: 1,
142
- },
143
-
144
- CallExpression: {
145
- arguments: 1,
146
- },
147
-
148
- ArrayExpression: 1,
149
- ObjectExpression: 1,
150
- ImportDeclaration: 1,
151
- flatTernaryExpressions: false,
152
-
153
- ignoredNodes: [
154
- 'JSXElement',
155
- 'JSXElement > *',
156
- 'JSXAttribute',
157
- 'JSXIdentifier',
158
- 'JSXNamespacedName',
159
- 'JSXMemberExpression',
160
- 'JSXSpreadAttribute',
161
- 'JSXExpressionContainer',
162
- 'JSXOpeningElement',
163
- 'JSXClosingElement',
164
- 'JSXFragment',
165
- 'JSXOpeningFragment',
166
- 'JSXClosingFragment',
167
- 'JSXText',
168
- 'JSXEmptyExpression',
169
- 'JSXSpreadChild',
170
- ],
171
-
172
- ignoreComments: false,
173
- offsetTernaryExpressions: false,
174
- }],
175
-
176
- '@stylistic/ts/keyword-spacing': ['error', {
177
- before: true,
178
- after: true,
179
-
180
- overrides: {
181
- return: {
182
- after: true,
183
- },
184
-
185
- throw: {
186
- after: true,
187
- },
188
-
189
- case: {
190
- after: true,
191
- },
192
- },
193
- }],
194
-
195
- '@stylistic/ts/lines-between-class-members': ['error', 'always', {
196
- exceptAfterSingleLine: false,
197
- exceptAfterOverload: true,
198
- }],
199
-
200
- '@typescript-eslint/no-array-constructor': ['error'],
201
- '@typescript-eslint/no-dupe-class-members': ['error'],
202
-
203
- '@typescript-eslint/no-empty-function': ['error', {
204
- allow: ['arrowFunctions', 'functions', 'methods'],
205
- }],
206
-
207
157
  '@typescript-eslint/no-extra-parens': ['off', 'all', {
208
158
  conditionalAssign: true,
209
159
  nestedBinaryExpressions: false,
@@ -212,61 +162,32 @@ export default [
212
162
  enforceForArrowConditionals: false,
213
163
  }],
214
164
 
215
- '@stylistic/ts/no-extra-semi': ['error'],
216
- '@typescript-eslint/no-implied-eval': ['error'],
217
- '@typescript-eslint/no-loss-of-precision': ['error'],
218
- '@typescript-eslint/no-loop-func': ['error'],
219
-
220
- '@typescript-eslint/no-magic-numbers': ['off', {
221
- ignore: [],
222
- ignoreArrayIndexes: true,
223
- enforceConst: true,
224
- detectObjects: false,
225
- }],
226
-
227
- '@typescript-eslint/no-redeclare': ['error'],
228
- '@stylistic/ts/space-before-blocks': ['error'],
229
-
230
- 'no-shadow': ['off'],
231
- '@typescript-eslint/no-shadow': ['error'],
232
-
233
- '@typescript-eslint/no-unused-expressions': ['error', {
234
- allowShortCircuit: false,
235
- allowTernary: false,
236
- allowTaggedTemplates: false,
237
- enforceForJSX: false,
238
- }],
239
-
240
- 'no-unused-vars': ['off'],
241
- '@typescript-eslint/no-unused-vars': ['error', {
242
- vars: 'all',
243
- args: 'after-used',
244
- ignoreRestSiblings: true,
245
- caughtErrors: 'none',
246
- }],
247
-
248
- '@typescript-eslint/no-use-before-define': ['error', {
249
- functions: true,
250
- classes: true,
251
- variables: true,
165
+ '@stylistic/ts/type-annotation-spacing': ['error', {
166
+ before: false,
167
+ after: true,
252
168
  }],
253
169
 
254
- '@typescript-eslint/no-useless-constructor': ['error'],
170
+ '@stylistic/ts/member-delimiter-style': ['error', {
171
+ multiline: {
172
+ delimiter: 'comma',
173
+ },
255
174
 
256
- '@stylistic/ts/quotes': ['error', 'single', {
257
- avoidEscape: true,
175
+ singleline: {
176
+ delimiter: 'comma',
177
+ },
258
178
  }],
259
-
260
- '@stylistic/ts/space-before-function-paren': ['error', {
261
- anonymous: 'always',
262
- named: 'never',
263
- asyncArrow: 'always',
179
+ '@stylistic/ts/func-call-spacing': ['error', 'never'],
180
+ '@stylistic/ts/no-extra-semi': ['error'],
181
+ '@stylistic/ts/comma-dangle': ['error', {
182
+ arrays: 'always-multiline',
183
+ objects: 'always-multiline',
184
+ imports: 'always-multiline',
185
+ exports: 'always-multiline',
186
+ functions: 'always-multiline',
187
+ enums: 'always-multiline',
188
+ generics: 'always-multiline',
189
+ tuples: 'always-multiline',
264
190
  }],
265
-
266
- '@typescript-eslint/require-await': ['off'],
267
- '@typescript-eslint/return-await': ['error', 'in-try-catch'],
268
- '@stylistic/ts/space-infix-ops': ['error'],
269
- '@stylistic/ts/object-curly-spacing': ['error', 'always'],
270
191
  },
271
192
  },
272
193
  ];
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "url": "https://github.com/entva/styleguide"
10
10
  },
11
11
  "bugs": "https://github.com/entva/styleguide/issues",
12
- "version": "2.7.0",
12
+ "version": "2.9.0",
13
13
  "keywords": [
14
14
  "linter",
15
15
  "config",
@@ -31,7 +31,7 @@
31
31
  "@stylistic/eslint-plugin-ts": "^2.12.1",
32
32
  "@typescript-eslint/eslint-plugin": "^8.18.0",
33
33
  "@typescript-eslint/parser": "^8.18.0",
34
- "eslint-config-entva-base": "^2.7.0",
34
+ "eslint-config-entva-base": "^2.8.0",
35
35
  "eslint-plugin-import": "^2.31.0",
36
36
  "globals": "^15.13.0"
37
37
  },