@allthings/eslint-config 0.0.4 → 0.0.6

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.
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # eslint-config-allthings
2
2
 
3
+ ESlint shareable config for Allthings style
3
4
 
4
5
  ## Setup
5
6
 
@@ -19,7 +20,7 @@ module.exports = {
19
20
  }
20
21
  ```
21
22
 
22
- ### Node.js projects (TODO)
23
+ ### Node.js projects
23
24
 
24
25
  ```js
25
26
  module.exports = {
package/index.js CHANGED
@@ -160,4 +160,5 @@ module.exports = {
160
160
  browser: true,
161
161
  node: true,
162
162
  },
163
+ root: true,
163
164
  }
package/node.js CHANGED
@@ -1,3 +1,324 @@
1
- module.export = {
2
- extends: ['@allthings/eslint-config/default'],
1
+ /*
2
+ * @rushstack/eslint-patch is used to include plugins as dev
3
+ * dependencies instead of imposing them as peer dependencies
4
+ *
5
+ * https://www.npmjs.com/package/@rushstack/eslint-patch
6
+ */
7
+ const keptPaths = []
8
+ const sortedPaths = []
9
+ const cwd = process.cwd().replace(/\\/g, '/')
10
+ const originalPaths = require.resolve.paths('eslint-plugin-import')
11
+
12
+ // eslint throws a conflict error when plugins resolve to different
13
+ // locations, since we want to lock our dependencies by default
14
+ // but also need to allow using user dependencies this updates
15
+ // our resolve paths to first check the cwd and iterate to
16
+ // eslint-config-next's dependencies if needed
17
+
18
+ for (const currentPath of originalPaths) {
19
+ if (currentPath.replace(/\\/g, '/').startsWith(cwd)) {
20
+ sortedPaths.push(currentPath)
21
+ } else {
22
+ keptPaths.unshift(currentPath)
23
+ }
24
+ }
25
+
26
+ // maintain order of node_modules outside cwd
27
+ sortedPaths.push(...keptPaths.reverse())
28
+
29
+ const hookPropertyMap = new Map(
30
+ [
31
+ ['eslint-plugin-import', 'eslint-plugin-import'],
32
+ ['eslint-plugin-ternary', 'eslint-plugin-ternary'],
33
+ [
34
+ 'eslint-plugin-typescript-sort-keys',
35
+ 'eslint-plugin-typescript-sort-keys',
36
+ ],
37
+ ['eslint-plugin-prefer-arrow', 'eslint-plugin-prefer-arrow'],
38
+ ['eslint-plugin-simple-import-sort', 'eslint-plugin-simple-import-sort'],
39
+ ].map(([request, replacement]) => [
40
+ request,
41
+ require.resolve(replacement, { paths: sortedPaths }),
42
+ ]),
43
+ )
44
+
45
+ const mod = require('module')
46
+ const resolveFilename = mod._resolveFilename
47
+ mod._resolveFilename = function (request, parent, isMain, options) {
48
+ const hookResolved = hookPropertyMap.get(request)
49
+ if (hookResolved) {
50
+ request = hookResolved
51
+ }
52
+ return resolveFilename.call(mod, request, parent, isMain, options)
53
+ }
54
+
55
+ require('@rushstack/eslint-patch/modern-module-resolution')
56
+
57
+ module.exports = {
58
+ extends: [
59
+ 'plugin:import/recommended',
60
+ 'plugin:import/typescript',
61
+ 'eslint:recommended',
62
+ 'plugin:ternary/recommended',
63
+ 'plugin:@typescript-eslint/eslint-recommended',
64
+ 'plugin:@typescript-eslint/recommended',
65
+ 'plugin:typescript-sort-keys/recommended',
66
+ 'plugin:prettier/recommended',
67
+ ],
68
+ plugins: [
69
+ 'import',
70
+ 'typescript-sort-keys',
71
+ 'prefer-arrow',
72
+ 'simple-import-sort',
73
+ 'ternary',
74
+ ],
75
+ rules: {
76
+ '@typescript-eslint/adjacent-overload-signatures': 'error',
77
+ '@typescript-eslint/array-type': [
78
+ 'error',
79
+ {
80
+ default: 'array',
81
+ },
82
+ ],
83
+ '@typescript-eslint/ban-types': [
84
+ 'error',
85
+ {
86
+ types: {
87
+ Object: {
88
+ message: 'Avoid using the `Object` type. Did you mean `object`?',
89
+ },
90
+ Function: {
91
+ message:
92
+ 'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.',
93
+ },
94
+ Boolean: {
95
+ message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
96
+ },
97
+ Number: {
98
+ message: 'Avoid using the `Number` type. Did you mean `number`?',
99
+ },
100
+ String: {
101
+ message: 'Avoid using the `String` type. Did you mean `string`?',
102
+ },
103
+ Symbol: {
104
+ message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
105
+ },
106
+ },
107
+ },
108
+ ],
109
+ '@typescript-eslint/consistent-type-assertions': 'error',
110
+ '@typescript-eslint/dot-notation': 'error',
111
+ '@typescript-eslint/explicit-function-return-type': [
112
+ 'warn', // TODO: strict later
113
+ {
114
+ allowExpressions: false,
115
+ allowTypedFunctionExpressions: false,
116
+ allowHigherOrderFunctions: false,
117
+ allowDirectConstAssertionInArrowFunctions: true,
118
+ allowConciseArrowFunctionExpressionsStartingWithVoid: true,
119
+ },
120
+ ],
121
+ '@typescript-eslint/explicit-module-boundary-types': [
122
+ 'warn', // TODO: strict later
123
+ {
124
+ allowArgumentsExplicitlyTypedAsAny: true,
125
+ allowDirectConstAssertionInArrowFunctions: true,
126
+ allowHigherOrderFunctions: false,
127
+ allowTypedFunctionExpressions: false,
128
+ },
129
+ ],
130
+ '@typescript-eslint/member-delimiter-style': [
131
+ 'error',
132
+ {
133
+ multiline: {
134
+ delimiter: 'none',
135
+ requireLast: true,
136
+ },
137
+ singleline: {
138
+ delimiter: 'semi',
139
+ requireLast: false,
140
+ },
141
+ },
142
+ ],
143
+ '@typescript-eslint/naming-convention': [
144
+ 'error',
145
+ {
146
+ custom: {
147
+ match: true,
148
+ regex: '^I[A-Z]',
149
+ },
150
+ format: ['PascalCase'],
151
+ selector: 'interface',
152
+ },
153
+ ],
154
+ '@typescript-eslint/no-empty-function': 'error',
155
+ '@typescript-eslint/no-empty-interface': 'error',
156
+ '@typescript-eslint/no-explicit-any': 'error',
157
+ '@typescript-eslint/no-for-in-array': 'error',
158
+ '@typescript-eslint/no-inferrable-types': 'error',
159
+ '@typescript-eslint/no-misused-new': 'error',
160
+ '@typescript-eslint/no-namespace': 'error',
161
+ '@typescript-eslint/no-shadow': [
162
+ 'error',
163
+ {
164
+ hoist: 'all',
165
+ },
166
+ ],
167
+ '@typescript-eslint/no-this-alias': 'error',
168
+ '@typescript-eslint/no-unused-expressions': 'error',
169
+ '@typescript-eslint/no-unused-vars': 'error',
170
+ '@typescript-eslint/no-use-before-define': 'error',
171
+ '@typescript-eslint/no-var-requires': 'error',
172
+ '@typescript-eslint/prefer-for-of': 'error',
173
+ '@typescript-eslint/prefer-function-type': 'error',
174
+ '@typescript-eslint/prefer-namespace-keyword': 'error',
175
+ '@typescript-eslint/quotes': [
176
+ 'error',
177
+ 'single',
178
+ {
179
+ avoidEscape: true,
180
+ },
181
+ ],
182
+ '@typescript-eslint/semi': ['error', 'never'],
183
+ '@typescript-eslint/triple-slash-reference': [
184
+ 'error',
185
+ {
186
+ path: 'always',
187
+ types: 'prefer-import',
188
+ lib: 'always',
189
+ },
190
+ ],
191
+ '@typescript-eslint/type-annotation-spacing': 'error',
192
+ '@typescript-eslint/typedef': 'error',
193
+ '@typescript-eslint/unified-signatures': 'error',
194
+ 'arrow-body-style': ['error', 'as-needed'],
195
+ complexity: [
196
+ 'error',
197
+ {
198
+ max: 15,
199
+ },
200
+ ],
201
+ 'constructor-super': 'error',
202
+ eqeqeq: ['error', 'smart'],
203
+ 'guard-for-in': 'error',
204
+ 'id-denylist': [
205
+ 'error',
206
+ 'any',
207
+ 'Number',
208
+ 'number',
209
+ 'String',
210
+ 'string',
211
+ 'Boolean',
212
+ 'boolean',
213
+ 'Undefined',
214
+ 'undefined',
215
+ ],
216
+ 'id-match': 'error',
217
+ 'import/no-anonymous-default-export': [
218
+ 'error',
219
+ {
220
+ allowAnonymousClass: false,
221
+ allowAnonymousFunction: false,
222
+ allowArray: false,
223
+ allowArrowFunction: true,
224
+ allowCallExpression: true,
225
+ // The true value here is for backward compatibility
226
+ allowLiteral: false,
227
+ allowObject: true,
228
+ },
229
+ ],
230
+ 'import/no-extraneous-dependencies': [
231
+ 'error',
232
+ {
233
+ devDependencies: true,
234
+ },
235
+ ],
236
+ 'max-classes-per-file': ['error', 1],
237
+ 'no-bitwise': 'error',
238
+ 'no-caller': 'error',
239
+ 'no-cond-assign': 'error',
240
+ 'no-console': 'error',
241
+ 'no-debugger': 'error',
242
+ 'no-duplicate-case': 'error',
243
+ 'no-duplicate-imports': 'error',
244
+ 'no-empty': 'error',
245
+ 'no-eval': 'error',
246
+ 'no-extra-bind': 'error',
247
+ 'no-multiple-empty-lines': 'error',
248
+ 'no-new-func': 'error',
249
+ 'no-new-wrappers': 'error',
250
+ 'no-param-reassign': 'error',
251
+ 'no-redeclare': 'error',
252
+ 'no-return-await': 'error',
253
+ 'no-sequences': 'error',
254
+ 'no-sparse-arrays': 'error',
255
+ 'no-template-curly-in-string': 'error',
256
+ 'no-throw-literal': 'error',
257
+ 'no-trailing-spaces': 'error',
258
+ 'no-undef-init': 'error',
259
+ 'no-unsafe-finally': 'error',
260
+ 'no-unused-labels': 'error',
261
+ 'no-var': 'error',
262
+ 'object-shorthand': 'error',
263
+ 'one-var': ['error', 'never'],
264
+ 'padding-line-between-statements': [
265
+ 'error',
266
+ {
267
+ blankLine: 'always',
268
+ prev: '*',
269
+ next: 'return',
270
+ },
271
+ ],
272
+ 'prefer-arrow/prefer-arrow-functions': 'error',
273
+ 'prefer-const': 'error',
274
+ 'prefer-object-spread': 'error',
275
+ 'prefer-template': 'error',
276
+ quotes: ['error', 'single', { avoidEscape: true }],
277
+ radix: 'error',
278
+ 'simple-import-sort/imports': 'error',
279
+ 'simple-import-sort/exports': 'error',
280
+ 'sort-keys': 'error',
281
+ 'spaced-comment': [
282
+ 'error',
283
+ 'always',
284
+ {
285
+ markers: ['/'],
286
+ },
287
+ ],
288
+ 'use-isnan': 'error',
289
+ },
290
+ parser: '@typescript-eslint/parser',
291
+ parserOptions: {
292
+ ecmaFeatures: {
293
+ jsx: true,
294
+ },
295
+ ecmaVersion: 2021,
296
+ project: 'tsconfig.json',
297
+ sourceType: 'module',
298
+ warnOnUnsupportedTypeScriptVersion: false,
299
+ },
300
+ settings: {
301
+ 'import/parsers': {
302
+ [require.resolve('@typescript-eslint/parser')]: [
303
+ '.ts',
304
+ '.mts',
305
+ '.cts',
306
+ '.tsx',
307
+ '.d.ts',
308
+ ],
309
+ },
310
+ 'import/resolver': {
311
+ [require.resolve('eslint-import-resolver-node')]: {
312
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
313
+ },
314
+ [require.resolve('eslint-import-resolver-typescript')]: {
315
+ alwaysTryTypes: true,
316
+ },
317
+ },
318
+ },
319
+ env: {
320
+ node: true,
321
+ es6: true,
322
+ },
323
+ root: true,
3
324
  }
package/package.json CHANGED
@@ -1,20 +1,18 @@
1
1
  {
2
2
  "name": "@allthings/eslint-config",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "ESlint shareable config for Allthings style",
5
5
  "main": "index.js",
6
6
  "files": [
7
7
  "index.js",
8
- "default.js",
9
- "node.js",
10
- "react.js"
8
+ "node.js"
11
9
  ],
12
10
  "scripts": {
13
- "lint": "prettier --write",
11
+ "lint": "prettier --check .",
14
12
  "test": "eslint test/",
15
13
  "predeploy": "yarn test",
16
14
  "deploy": "yarn publish --new-version $npm_package_version --tag latest --access public",
17
- "poatdeploy": "git push --tags origin HEAD"
15
+ "postdeploy": "git push --tags origin HEAD"
18
16
  },
19
17
  "dependencies": {
20
18
  "@rushstack/eslint-patch": "^1.2.0",
@@ -26,10 +24,12 @@
26
24
  "eslint-plugin-import": "^2.26.0",
27
25
  "eslint-plugin-jsx-a11y": "^6.6.1",
28
26
  "eslint-plugin-n": "^15.5.1",
27
+ "eslint-plugin-prefer-arrow": "^1.2.3",
29
28
  "eslint-plugin-prettier": "^4.2.1",
30
29
  "eslint-plugin-react": "^7.31.11",
31
30
  "eslint-plugin-react-hooks": "^4.6.0",
32
31
  "eslint-plugin-simple-import-sort": "^8.0.0",
32
+ "eslint-plugin-ternary": "^2.0.0",
33
33
  "eslint-plugin-typescript-sort-keys": "^2.1.0"
34
34
  },
35
35
  "peerDependencies": {
package/default.js DELETED
@@ -1,43 +0,0 @@
1
- module.export = {
2
- extends: [
3
- 'plugin:import/recommended',
4
- 'plugin:import/typescript',
5
- 'eslint:recommended',
6
- 'plugin:@typescript-eslint/eslint-recommended',
7
- 'plugin:@typescript-eslint/recommended',
8
- 'plugin:typescript-sort-keys/recommended',
9
- 'plugin:prettier/recommended',
10
- ],
11
- plugins: ['typescript-sort-keys', 'simple-import-sort'],
12
- rules: {
13
- '@typescript-eslint/naming-convention': [
14
- 'error',
15
- {
16
- custom: {
17
- match: true,
18
- regex: '^I[A-Z]',
19
- },
20
- format: ['PascalCase'],
21
- selector: 'interface',
22
- },
23
- ],
24
- 'import/no-anonymous-default-export': [
25
- 'error',
26
- {
27
- allowAnonymousClass: false,
28
- allowAnonymousFunction: false,
29
- allowArray: false,
30
- allowArrowFunction: true,
31
- allowCallExpression: true,
32
- // The true value here is for backward compatibility
33
- allowLiteral: false,
34
- allowObject: true,
35
- },
36
- ],
37
- 'no-console': 'error',
38
- quotes: ['error', 'single', { avoidEscape: true }],
39
- 'simple-import-sort/imports': 'error',
40
- 'simple-import-sort/exports': 'error',
41
- 'sort-keys': 'error',
42
- },
43
- }
package/react.js DELETED
@@ -1,24 +0,0 @@
1
- module.export = {
2
- extends: [
3
- '@allthings/eslint-config/default',
4
- 'plugin:react/recommended',
5
- 'plugin:react/jsx-runtime',
6
- 'plugin:react-hooks/recommended',
7
- ],
8
- rules: {
9
- 'react-hooks/exhaustive-deps': 'error',
10
- 'react/jsx-curly-brace-presence': [
11
- 'error',
12
- {
13
- children: 'never',
14
- props: 'never',
15
- },
16
- ],
17
- 'react/jsx-sort-props': [
18
- 2,
19
- {
20
- noSortAlphabetically: false,
21
- },
22
- ],
23
- },
24
- }