eslint-config-entva-typescript-base 2.5.0 → 2.8.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 +91 -181
  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,13 +30,7 @@ export default [
19
30
  },
20
31
  },
21
32
  {
22
- files: ['**/*.{js,mjs,cjs,ts}'],
23
- ignores: [
24
- '**/node_modules/',
25
- '**/public/',
26
- '**/coverage/',
27
- '**/.*',
28
- ],
33
+ files: ['**/*.{ts,tsx}'],
29
34
  plugins: {
30
35
  import: importPlugin,
31
36
  '@typescript-eslint': typescriptEslint,
@@ -49,180 +54,64 @@ export default [
49
54
  ecmaFeatures: {
50
55
  generators: false,
51
56
  objectLiteralDuplicateProperties: false,
57
+ jsx: true,
52
58
  },
53
59
  },
54
60
  },
55
61
 
56
62
  settings: {
57
63
  'import/parsers': {
58
- '@typescript-eslint/parser': ['.ts', '.d.ts'],
64
+ '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
59
65
  },
60
66
 
61
67
  'import/resolver': {
62
68
  node: {
63
- extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
69
+ extensions: ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.d.ts', '.json'],
64
70
  },
65
71
  },
66
72
 
67
- 'import/extensions': ['.mjs', '.js', '.json', '.ts', '.d.ts'],
73
+ 'import/extensions': ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.d.ts', '.json'],
68
74
  'import/external-module-folders': ['node_modules', 'node_modules/@types'],
69
75
  'import/core-modules': [],
70
76
  'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$'],
71
77
  },
72
78
 
73
79
  rules: {
74
- '@stylistic/ts/member-delimiter-style': ['error', {
75
- multiline: {
76
- delimiter: 'comma',
77
- },
78
-
79
- singleline: {
80
- delimiter: 'comma',
81
- },
82
- }],
83
-
84
- '@typescript-eslint/no-explicit-any': ['error', {
85
- ignoreRestArgs: true,
86
- }],
87
-
88
- '@typescript-eslint/naming-convention': ['error', {
89
- selector: 'variable',
90
- format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
91
- leadingUnderscore: 'allowSingleOrDouble',
92
- }, {
93
- selector: 'function',
94
- format: ['camelCase', 'PascalCase'],
95
- leadingUnderscore: 'allowSingleOrDouble',
96
- }, {
97
- selector: 'typeLike',
98
- format: ['PascalCase'],
99
- leadingUnderscore: 'allowSingleOrDouble',
100
- }],
101
-
102
- '@stylistic/ts/brace-style': ['error', '1tbs', {
103
- allowSingleLine: true,
104
- }],
105
-
106
- '@stylistic/ts/comma-dangle': ['error', {
107
- arrays: 'always-multiline',
108
- objects: 'always-multiline',
109
- imports: 'always-multiline',
110
- exports: 'always-multiline',
111
- functions: 'always-multiline',
112
- enums: 'always-multiline',
113
- generics: 'always-multiline',
114
- tuples: 'always-multiline',
115
- }],
116
-
117
- '@stylistic/ts/comma-spacing': ['error', {
118
- before: false,
119
- after: true,
120
- }],
121
-
122
- 'default-param-last': ['off'],
123
- '@typescript-eslint/default-param-last': ['error'],
124
-
125
- '@typescript-eslint/dot-notation': ['error', {
126
- allowKeywords: true,
127
- allowPattern: '',
128
- allowPrivateClassPropertyAccess: false,
129
- allowProtectedClassPropertyAccess: false,
130
- allowIndexSignaturePropertyAccess: false,
131
- }],
132
-
133
- '@stylistic/ts/func-call-spacing': ['error', 'never'],
134
-
135
- '@stylistic/ts/indent': ['error', 2, {
136
- SwitchCase: 1,
137
- VariableDeclarator: 1,
138
- outerIIFEBody: 1,
139
-
140
- FunctionDeclaration: {
141
- parameters: 1,
142
- body: 1,
143
- },
144
-
145
- FunctionExpression: {
146
- parameters: 1,
147
- body: 1,
148
- },
149
-
150
- CallExpression: {
151
- arguments: 1,
152
- },
153
-
154
- ArrayExpression: 1,
155
- ObjectExpression: 1,
156
- ImportDeclaration: 1,
157
- flatTernaryExpressions: false,
158
-
159
- ignoredNodes: [
160
- 'JSXElement',
161
- 'JSXElement > *',
162
- 'JSXAttribute',
163
- 'JSXIdentifier',
164
- 'JSXNamespacedName',
165
- 'JSXMemberExpression',
166
- 'JSXSpreadAttribute',
167
- 'JSXExpressionContainer',
168
- 'JSXOpeningElement',
169
- 'JSXClosingElement',
170
- 'JSXFragment',
171
- 'JSXOpeningFragment',
172
- 'JSXClosingFragment',
173
- 'JSXText',
174
- 'JSXEmptyExpression',
175
- 'JSXSpreadChild',
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',
176
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
+ ),
177
111
 
178
- ignoreComments: false,
179
- offsetTernaryExpressions: false,
180
- }],
181
-
182
- '@stylistic/ts/keyword-spacing': ['error', {
183
- before: true,
184
- after: true,
185
-
186
- overrides: {
187
- return: {
188
- after: true,
189
- },
190
-
191
- throw: {
192
- after: true,
193
- },
194
-
195
- case: {
196
- after: true,
197
- },
198
- },
199
- }],
200
-
201
- '@stylistic/ts/lines-between-class-members': ['error', 'always', {
202
- exceptAfterSingleLine: false,
203
- exceptAfterOverload: true,
204
- }],
205
-
206
- '@typescript-eslint/no-array-constructor': ['error'],
207
- '@typescript-eslint/no-dupe-class-members': ['error'],
208
-
209
- '@typescript-eslint/no-empty-function': ['error', {
210
- allow: ['arrowFunctions', 'functions', 'methods'],
211
- }],
212
-
213
- '@typescript-eslint/no-extra-parens': ['off', 'all', {
214
- conditionalAssign: true,
215
- nestedBinaryExpressions: false,
216
- returnAssign: false,
217
- ignoreJSX: 'all',
218
- enforceForArrowConditionals: false,
219
- }],
220
-
221
- '@stylistic/ts/no-extra-semi': ['error'],
222
112
  '@typescript-eslint/no-implied-eval': ['error'],
223
113
  '@typescript-eslint/no-loss-of-precision': ['error'],
224
114
  '@typescript-eslint/no-loop-func': ['error'],
225
-
226
115
  '@typescript-eslint/no-magic-numbers': ['off', {
227
116
  ignore: [],
228
117
  ignoreArrayIndexes: true,
@@ -231,11 +120,6 @@ export default [
231
120
  }],
232
121
 
233
122
  '@typescript-eslint/no-redeclare': ['error'],
234
- '@stylistic/ts/space-before-blocks': ['error'],
235
-
236
- 'no-shadow': ['off'],
237
- '@typescript-eslint/no-shadow': ['error'],
238
-
239
123
  '@typescript-eslint/no-unused-expressions': ['error', {
240
124
  allowShortCircuit: false,
241
125
  allowTernary: false,
@@ -243,36 +127,62 @@ export default [
243
127
  enforceForJSX: false,
244
128
  }],
245
129
 
246
- 'no-unused-vars': ['off'],
247
- '@typescript-eslint/no-unused-vars': ['error', {
248
- vars: 'all',
249
- args: 'after-used',
250
- ignoreRestSiblings: true,
251
- caughtErrors: 'none',
252
- }],
253
-
254
130
  '@typescript-eslint/no-use-before-define': ['error', {
255
131
  functions: true,
256
132
  classes: true,
257
133
  variables: true,
258
134
  }],
259
135
 
260
- '@typescript-eslint/no-useless-constructor': ['error'],
136
+ '@typescript-eslint/require-await': ['off'],
137
+ '@typescript-eslint/return-await': ['error', 'in-try-catch'],
261
138
 
262
- '@stylistic/ts/quotes': ['error', 'single', {
263
- avoidEscape: true,
139
+ '@typescript-eslint/no-explicit-any': ['error', {
140
+ ignoreRestArgs: true,
264
141
  }],
265
142
 
266
- '@stylistic/ts/space-before-function-paren': ['error', {
267
- anonymous: 'always',
268
- named: 'never',
269
- asyncArrow: 'always',
143
+ '@typescript-eslint/naming-convention': ['error', {
144
+ selector: 'variable',
145
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
146
+ leadingUnderscore: 'allowSingleOrDouble',
147
+ }, {
148
+ selector: 'function',
149
+ format: ['camelCase', 'PascalCase'],
150
+ leadingUnderscore: 'allowSingleOrDouble',
151
+ }, {
152
+ selector: 'typeLike',
153
+ format: ['PascalCase'],
154
+ leadingUnderscore: 'allowSingleOrDouble',
270
155
  }],
271
156
 
272
- '@typescript-eslint/require-await': ['off'],
273
- '@typescript-eslint/return-await': ['error', 'in-try-catch'],
274
- '@stylistic/ts/space-infix-ops': ['error'],
275
- '@stylistic/ts/object-curly-spacing': ['error', 'always'],
157
+ '@typescript-eslint/no-extra-parens': ['off', 'all', {
158
+ conditionalAssign: true,
159
+ nestedBinaryExpressions: false,
160
+ returnAssign: false,
161
+ ignoreJSX: 'all',
162
+ enforceForArrowConditionals: false,
163
+ }],
164
+
165
+ '@stylistic/ts/member-delimiter-style': ['error', {
166
+ multiline: {
167
+ delimiter: 'comma',
168
+ },
169
+
170
+ singleline: {
171
+ delimiter: 'comma',
172
+ },
173
+ }],
174
+ '@stylistic/ts/func-call-spacing': ['error', 'never'],
175
+ '@stylistic/ts/no-extra-semi': ['error'],
176
+ // '@stylistic/ts/comma-dangle': ['error', {
177
+ // arrays: 'always-multiline',
178
+ // objects: 'always-multiline',
179
+ // imports: 'always-multiline',
180
+ // exports: 'always-multiline',
181
+ // functions: 'always-multiline',
182
+ // enums: 'always-multiline',
183
+ // generics: 'always-multiline',
184
+ // tuples: 'always-multiline',
185
+ // }],
276
186
  },
277
187
  },
278
188
  ];
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.5.0",
12
+ "version": "2.8.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.5.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
  },