eslint-config-entva-typescript-base 2.17.0 → 2.18.1

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 +180 -183
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1,18 +1,10 @@
1
- import baseConfig from 'eslint-config-entva-base';
1
+ import { ignoreRule, mainRule as baseMainRule, testRule as baseTestRule } from 'eslint-config-entva-base';
2
2
  import importPlugin from 'eslint-plugin-import';
3
3
  import globals from 'globals';
4
4
  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 baseConfigRules = baseConfig.reduce((acc, config) => {
9
- if (!config.files || !config.rules) return acc;
10
- const isTest = config.files.some((pattern) => pattern.includes('.test.'));
11
- const key = isTest ? 'test' : 'base';
12
- acc[key] = { ...acc[key], ...config.rules };
13
- return acc;
14
- }, { base: {}, test: {} });
15
-
16
8
  // Many TS rules mirror JS rules, we need to disable JS rule and apply config for the TS replacement
17
9
  const getOverrides = (base, rules, overridePrefix) => rules.reduce((acc, rule) => {
18
10
  acc[rule] = ['off'];
@@ -20,195 +12,200 @@ const getOverrides = (base, rules, overridePrefix) => rules.reduce((acc, rule) =
20
12
  return acc;
21
13
  }, {});
22
14
 
23
- export default [
24
- ...baseConfig,
25
- {
26
- files: ['**/*.{ts,tsx}'],
27
- plugins: {
28
- import: importPlugin,
29
- '@typescript-eslint': typescriptEslint,
30
- '@stylistic/ts': stylisticTs,
31
- },
15
+ export const mainRule = {
16
+ files: ['**/*.{ts,tsx}'],
17
+ plugins: {
18
+ import: importPlugin,
19
+ '@typescript-eslint': typescriptEslint,
20
+ '@stylistic/ts': stylisticTs,
21
+ },
32
22
 
33
- languageOptions: {
34
- globals: {
35
- ...globals.browser,
36
- ...globals.node,
37
- },
23
+ languageOptions: {
24
+ globals: {
25
+ ...globals.browser,
26
+ ...globals.node,
27
+ },
38
28
 
39
- parser: tsParser,
40
- ecmaVersion: 'latest',
41
- sourceType: 'module',
29
+ parser: tsParser,
30
+ ecmaVersion: 'latest',
31
+ sourceType: 'module',
42
32
 
43
- parserOptions: {
44
- parser: '@typescript-eslint/parser',
45
- project: './tsconfig.json',
33
+ parserOptions: {
34
+ parser: '@typescript-eslint/parser',
35
+ project: './tsconfig.json',
46
36
 
47
- ecmaFeatures: {
48
- generators: false,
49
- objectLiteralDuplicateProperties: false,
50
- jsx: true,
51
- },
37
+ ecmaFeatures: {
38
+ generators: false,
39
+ objectLiteralDuplicateProperties: false,
40
+ jsx: true,
52
41
  },
53
42
  },
43
+ },
54
44
 
55
- settings: {
56
- 'import/parsers': {
57
- '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
58
- },
45
+ settings: {
46
+ 'import/parsers': {
47
+ '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
48
+ },
59
49
 
60
- 'import/resolver': {
61
- node: {
62
- extensions: ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.d.ts', '.json'],
63
- },
50
+ 'import/resolver': {
51
+ node: {
52
+ extensions: ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.d.ts', '.json'],
64
53
  },
54
+ },
65
55
 
66
- 'import/extensions': ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.d.ts', '.json'],
67
- 'import/external-module-folders': ['node_modules', 'node_modules/@types'],
68
- 'import/core-modules': [],
69
- 'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$'],
70
-
71
- react: {
72
- pragma: 'React',
73
- version: 'detect',
74
- },
56
+ 'import/extensions': ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.d.ts', '.json'],
57
+ 'import/external-module-folders': ['node_modules', 'node_modules/@types'],
58
+ 'import/core-modules': [],
59
+ 'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$'],
75
60
 
76
- propWrapperFunctions: ['forbidExtraProps', 'exact', 'Object.freeze'],
61
+ react: {
62
+ pragma: 'React',
63
+ version: 'detect',
77
64
  },
78
65
 
79
- rules: {
80
- ...baseConfigRules.base,
81
- ...getOverrides(
82
- baseConfigRules.base,
83
- [
84
- 'no-array-constructor',
85
- 'no-useless-constructor',
86
- 'no-empty-function',
87
- 'no-dupe-class-members',
88
- 'default-param-last',
89
- 'dot-notation',
90
- 'naming-convention',
91
- 'no-shadow',
92
- 'no-unused-vars',
93
- ],
94
- '@typescript-eslint',
95
- ),
96
- ...getOverrides(
97
- baseConfigRules.base,
98
- [
99
- 'space-before-function-paren',
100
- 'lines-between-class-members',
101
- 'space-before-blocks',
102
- 'brace-style',
103
- 'indent',
104
- 'keyword-spacing',
105
- 'space-infix-ops',
106
- 'comma-spacing',
107
- 'comma-dangle',
108
- 'object-curly-spacing',
109
- 'quotes',
110
- ],
111
- '@stylistic/ts',
112
- ),
113
-
114
- '@typescript-eslint/no-implied-eval': ['error'],
115
- '@typescript-eslint/no-loss-of-precision': ['error'],
116
- '@typescript-eslint/no-loop-func': ['error'],
117
- '@typescript-eslint/no-magic-numbers': ['off', {
118
- ignore: [],
119
- ignoreArrayIndexes: true,
120
- enforceConst: true,
121
- detectObjects: false,
122
- }],
123
-
124
- '@typescript-eslint/no-redeclare': ['error'],
125
- '@typescript-eslint/no-unused-expressions': ['error', {
126
- allowShortCircuit: false,
127
- allowTernary: false,
128
- allowTaggedTemplates: false,
129
- enforceForJSX: false,
130
- }],
131
-
132
- '@typescript-eslint/no-use-before-define': ['error', {
133
- functions: true,
134
- classes: true,
135
- variables: true,
136
- }],
137
-
138
- '@typescript-eslint/require-await': ['off'],
139
- '@typescript-eslint/return-await': ['error', 'in-try-catch'],
140
-
141
- '@typescript-eslint/no-explicit-any': ['error', {
142
- ignoreRestArgs: true,
143
- }],
144
-
145
- '@typescript-eslint/naming-convention': ['error', {
146
- selector: 'variable',
147
- format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
148
- leadingUnderscore: 'allowSingleOrDouble',
149
- }, {
150
- selector: 'function',
151
- format: ['camelCase', 'PascalCase'],
152
- leadingUnderscore: 'allowSingleOrDouble',
153
- }, {
154
- selector: 'typeLike',
155
- format: ['PascalCase'],
156
- leadingUnderscore: 'allowSingleOrDouble',
157
- }],
158
-
159
- '@typescript-eslint/no-extra-parens': ['off', 'all', {
160
- conditionalAssign: true,
161
- nestedBinaryExpressions: false,
162
- returnAssign: false,
163
- ignoreJSX: 'all',
164
- enforceForArrowConditionals: false,
165
- }],
166
-
167
- '@stylistic/ts/member-delimiter-style': ['error', {
168
- multiline: {
169
- delimiter: 'comma',
170
- },
171
-
172
- singleline: {
173
- delimiter: 'comma',
174
- },
175
- }],
176
- '@stylistic/ts/func-call-spacing': ['error', 'never'],
177
- '@stylistic/ts/no-extra-semi': ['error'],
178
- '@stylistic/ts/comma-dangle': ['error', {
179
- arrays: 'always-multiline',
180
- objects: 'always-multiline',
181
- imports: 'always-multiline',
182
- exports: 'always-multiline',
183
- functions: 'always-multiline',
184
- enums: 'always-multiline',
185
- generics: 'always-multiline',
186
- tuples: 'always-multiline',
187
- }],
188
- },
66
+ propWrapperFunctions: ['forbidExtraProps', 'exact', 'Object.freeze'],
189
67
  },
190
- {
191
- files: [
192
- '**/*.test.ts',
193
- '**/*.test.tsx',
194
- '**/*.spec.ts',
195
- '**/*.spec.tsx',
196
- '**/__tests__/**',
197
- ],
198
- languageOptions: {
199
- globals: {
200
- ...globals.jest,
68
+
69
+ rules: {
70
+ ...baseMainRule.rules,
71
+ ...getOverrides(
72
+ baseMainRule.rules,
73
+ [
74
+ 'no-array-constructor',
75
+ 'no-useless-constructor',
76
+ 'no-empty-function',
77
+ 'no-dupe-class-members',
78
+ 'default-param-last',
79
+ 'dot-notation',
80
+ 'naming-convention',
81
+ 'no-shadow',
82
+ 'no-unused-vars',
83
+ ],
84
+ '@typescript-eslint',
85
+ ),
86
+ ...getOverrides(
87
+ baseMainRule.rules,
88
+ [
89
+ 'space-before-function-paren',
90
+ 'lines-between-class-members',
91
+ 'space-before-blocks',
92
+ 'brace-style',
93
+ 'indent',
94
+ 'keyword-spacing',
95
+ 'space-infix-ops',
96
+ 'comma-spacing',
97
+ 'comma-dangle',
98
+ 'object-curly-spacing',
99
+ 'quotes',
100
+ ],
101
+ '@stylistic/ts',
102
+ ),
103
+
104
+ '@typescript-eslint/no-implied-eval': ['error'],
105
+ '@typescript-eslint/no-loss-of-precision': ['error'],
106
+ '@typescript-eslint/no-loop-func': ['error'],
107
+ '@typescript-eslint/no-magic-numbers': ['off', {
108
+ ignore: [],
109
+ ignoreArrayIndexes: true,
110
+ enforceConst: true,
111
+ detectObjects: false,
112
+ }],
113
+
114
+ '@typescript-eslint/no-redeclare': ['error'],
115
+ '@typescript-eslint/no-unused-expressions': ['error', {
116
+ allowShortCircuit: false,
117
+ allowTernary: false,
118
+ allowTaggedTemplates: false,
119
+ enforceForJSX: false,
120
+ }],
121
+
122
+ '@typescript-eslint/no-use-before-define': ['error', {
123
+ functions: true,
124
+ classes: true,
125
+ variables: true,
126
+ }],
127
+
128
+ '@typescript-eslint/require-await': ['off'],
129
+ '@typescript-eslint/return-await': ['error', 'in-try-catch'],
130
+
131
+ '@typescript-eslint/no-explicit-any': ['error', {
132
+ ignoreRestArgs: true,
133
+ }],
134
+
135
+ '@typescript-eslint/naming-convention': ['error', {
136
+ selector: 'variable',
137
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
138
+ leadingUnderscore: 'allowSingleOrDouble',
139
+ }, {
140
+ selector: 'function',
141
+ format: ['camelCase', 'PascalCase'],
142
+ leadingUnderscore: 'allowSingleOrDouble',
143
+ }, {
144
+ selector: 'typeLike',
145
+ format: ['PascalCase'],
146
+ leadingUnderscore: 'allowSingleOrDouble',
147
+ }],
148
+
149
+ '@typescript-eslint/no-extra-parens': ['off', 'all', {
150
+ conditionalAssign: true,
151
+ nestedBinaryExpressions: false,
152
+ returnAssign: false,
153
+ ignoreJSX: 'all',
154
+ enforceForArrowConditionals: false,
155
+ }],
156
+
157
+ '@stylistic/ts/member-delimiter-style': ['error', {
158
+ multiline: {
159
+ delimiter: 'comma',
201
160
  },
161
+
162
+ singleline: {
163
+ delimiter: 'comma',
164
+ },
165
+ }],
166
+ '@stylistic/ts/func-call-spacing': ['error', 'never'],
167
+ '@stylistic/ts/no-extra-semi': ['error'],
168
+ '@stylistic/ts/comma-dangle': ['error', {
169
+ arrays: 'always-multiline',
170
+ objects: 'always-multiline',
171
+ imports: 'always-multiline',
172
+ exports: 'always-multiline',
173
+ functions: 'always-multiline',
174
+ enums: 'always-multiline',
175
+ generics: 'always-multiline',
176
+ tuples: 'always-multiline',
177
+ }],
178
+ },
179
+ };
180
+
181
+ export const testRule = {
182
+ files: [
183
+ '**/*.test.ts',
184
+ '**/*.test.tsx',
185
+ '**/*.spec.ts',
186
+ '**/*.spec.tsx',
187
+ '**/__tests__/**',
188
+ ],
189
+ languageOptions: {
190
+ globals: {
191
+ ...globals.jest,
202
192
  },
203
- rules: {
204
- ...baseConfigRules.test,
205
- ...getOverrides(
206
- baseConfigRules.test,
207
- [
208
- 'no-unused-vars',
209
- ],
210
- '@typescript-eslint',
211
- ),
212
- },
213
193
  },
194
+ rules: {
195
+ ...getOverrides(
196
+ baseTestRule.rules,
197
+ [
198
+ 'no-unused-vars',
199
+ ],
200
+ '@typescript-eslint',
201
+ ),
202
+ },
203
+ };
204
+
205
+ export default [
206
+ ignoreRule,
207
+ baseMainRule,
208
+ mainRule,
209
+ baseTestRule,
210
+ testRule,
214
211
  ];
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.17.0",
12
+ "version": "2.18.1",
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.19.0",
33
33
  "@typescript-eslint/parser": "^8.19.0",
34
- "eslint-config-entva-base": "^2.17.0",
34
+ "eslint-config-entva-base": "^2.18.0",
35
35
  "eslint-plugin-import": "^2.31.0",
36
36
  "globals": "^15.14.0"
37
37
  },