eslint-config-entva-typescript-base 2.7.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 -175
  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,180 +54,64 @@ 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
- },
72
-
73
- singleline: {
74
- delimiter: 'comma',
75
- },
76
- }],
77
-
78
- '@typescript-eslint/no-explicit-any': ['error', {
79
- ignoreRestArgs: true,
80
- }],
81
-
82
- '@typescript-eslint/naming-convention': ['error', {
83
- selector: 'variable',
84
- format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
85
- leadingUnderscore: 'allowSingleOrDouble',
86
- }, {
87
- selector: 'function',
88
- format: ['camelCase', 'PascalCase'],
89
- leadingUnderscore: 'allowSingleOrDouble',
90
- }, {
91
- selector: 'typeLike',
92
- format: ['PascalCase'],
93
- leadingUnderscore: 'allowSingleOrDouble',
94
- }],
95
-
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',
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',
170
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
+ ),
171
111
 
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
- '@typescript-eslint/no-extra-parens': ['off', 'all', {
208
- conditionalAssign: true,
209
- nestedBinaryExpressions: false,
210
- returnAssign: false,
211
- ignoreJSX: 'all',
212
- enforceForArrowConditionals: false,
213
- }],
214
-
215
- '@stylistic/ts/no-extra-semi': ['error'],
216
112
  '@typescript-eslint/no-implied-eval': ['error'],
217
113
  '@typescript-eslint/no-loss-of-precision': ['error'],
218
114
  '@typescript-eslint/no-loop-func': ['error'],
219
-
220
115
  '@typescript-eslint/no-magic-numbers': ['off', {
221
116
  ignore: [],
222
117
  ignoreArrayIndexes: true,
@@ -225,11 +120,6 @@ export default [
225
120
  }],
226
121
 
227
122
  '@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
123
  '@typescript-eslint/no-unused-expressions': ['error', {
234
124
  allowShortCircuit: false,
235
125
  allowTernary: false,
@@ -237,36 +127,62 @@ export default [
237
127
  enforceForJSX: false,
238
128
  }],
239
129
 
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
130
  '@typescript-eslint/no-use-before-define': ['error', {
249
131
  functions: true,
250
132
  classes: true,
251
133
  variables: true,
252
134
  }],
253
135
 
254
- '@typescript-eslint/no-useless-constructor': ['error'],
136
+ '@typescript-eslint/require-await': ['off'],
137
+ '@typescript-eslint/return-await': ['error', 'in-try-catch'],
255
138
 
256
- '@stylistic/ts/quotes': ['error', 'single', {
257
- avoidEscape: true,
139
+ '@typescript-eslint/no-explicit-any': ['error', {
140
+ ignoreRestArgs: true,
258
141
  }],
259
142
 
260
- '@stylistic/ts/space-before-function-paren': ['error', {
261
- anonymous: 'always',
262
- named: 'never',
263
- 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',
264
155
  }],
265
156
 
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'],
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
+ // }],
270
186
  },
271
187
  },
272
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.7.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.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
  },