@allthings/eslint-config 0.0.5 → 0.0.7

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