@generatech/eslint-config-base 1.0.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.
package/.eslintrc ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./index.js",
3
+ "rules": {
4
+ // disable requiring trailing commas because it might be nice to revert to
5
+ // being JSON at some point, and I don't want to make big changes now.
6
+ "comma-dangle": 0,
7
+
8
+ "max-len": 0
9
+ }
10
+ }
package/index.js ADDED
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ extends: [
3
+ "./rules/best-practices",
4
+ "./rules/errors",
5
+ "./rules/node",
6
+ "./rules/style",
7
+ "./rules/variables",
8
+ "./rules/es",
9
+ "./rules/imports",
10
+ ].map(require.resolve),
11
+ parserOptions: {
12
+ ecmaVersion: 2018,
13
+ sourceType: "module",
14
+ },
15
+ root: true
16
+ };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@generatech/eslint-config-base",
3
+ "version": "1.0.0",
4
+ "description": "Eslint base config for javascript/typescript generatech projects",
5
+ "main": "index.js",
6
+ "exports": {
7
+ ".": "./index.js",
8
+ "./legacy": "./legacy.js",
9
+ "./whitespace": "./whitespace.js",
10
+ "./rules/best-practices": "./rules/best-practices.js",
11
+ "./rules/es": "./rules/es.js",
12
+ "./rules/node": "./rules/node.js",
13
+ "./rules/style": "./rules/style.js",
14
+ "./rules/errors": "./rules/errors.js",
15
+ "./rules/imports": "./rules/imports.js",
16
+ "./rules/variables": "./rules/variables.js",
17
+ "./package.json": "./package.json"
18
+ },
19
+ "scripts": {
20
+ "test": "echo \"Error: no test specified\" && exit 1"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://mperez_generatech@bitbucket.org/generatech-devs/eslint-config-base.git"
25
+ },
26
+ "author": "Michael Pérez",
27
+ "license": "ISC",
28
+ "bugs": {
29
+ "url": "https://bitbucket.org/generatech-devs/eslint-config-base/issues"
30
+ },
31
+ "homepage": "https://bitbucket.org/generatech-devs/eslint-config-base#readme",
32
+ "peerDependencies": {
33
+ "eslint": "^9.0.0",
34
+ "eslint-plugin-import": "^2.32.0"
35
+ },
36
+ "devDependencies": {
37
+ "eslint": "^9.30.1",
38
+ "eslint-plugin-import": "^2.32.0",
39
+ "typescript": "^5.8.3"
40
+ },
41
+ "dependencies": {
42
+ "confusing-browser-globals": "^1.0.11"
43
+ }
44
+ }
@@ -0,0 +1,462 @@
1
+ module.exports = {
2
+ rules: {
3
+ // enforces getter/setter pairs in objects
4
+ // https://eslint.org/docs/rules/accessor-pairs
5
+ "accessor-pairs": "off",
6
+
7
+ // enforces return statements in callbacks of array's methods
8
+ // https://eslint.org/docs/rules/array-callback-return
9
+ "array-callback-return": ["error", { allowImplicit: true }],
10
+
11
+ // treat var statements as if they were block scoped
12
+ // https://eslint.org/docs/rules/block-scoped-var
13
+ "block-scoped-var": "error",
14
+
15
+ // specify the maximum cyclomatic complexity allowed in a program
16
+ // https://eslint.org/docs/rules/complexity
17
+ complexity: ["off", 20],
18
+
19
+ // enforce that class methods use "this"
20
+ // https://eslint.org/docs/rules/class-methods-use-this
21
+ "class-methods-use-this": [
22
+ "error",
23
+ {
24
+ exceptMethods: [],
25
+ },
26
+ ],
27
+
28
+ // require return statements to either always or never specify values
29
+ // https://eslint.org/docs/rules/consistent-return
30
+ "consistent-return": "error",
31
+
32
+ // specify curly brace conventions for all control statements
33
+ // https://eslint.org/docs/rules/curly
34
+ curly: ["error", "multi-line"], // multiline
35
+
36
+ // require default case in switch statements
37
+ // https://eslint.org/docs/rules/default-case
38
+ "default-case": ["error", { commentPattern: "^no default$" }],
39
+
40
+ // Enforce default clauses in switch statements to be last
41
+ // https://eslint.org/docs/rules/default-case-last
42
+ "default-case-last": "error",
43
+
44
+ // https://eslint.org/docs/rules/default-param-last
45
+ "default-param-last": "error",
46
+
47
+ // encourages use of dot notation whenever possible
48
+ // https://eslint.org/docs/rules/dot-notation
49
+ "dot-notation": ["error", { allowKeywords: true }],
50
+
51
+ // enforces consistent newlines before or after dots
52
+ // https://eslint.org/docs/rules/dot-location
53
+ "dot-location": ["error", "property"],
54
+
55
+ // require the use of === and !==
56
+ // https://eslint.org/docs/rules/eqeqeq
57
+ eqeqeq: ["error", "always", { null: "ignore" }],
58
+
59
+ // Require grouped accessor pairs in object literals and classes
60
+ // https://eslint.org/docs/rules/grouped-accessor-pairs
61
+ "grouped-accessor-pairs": "error",
62
+
63
+ // make sure for-in loops have an if statement
64
+ // https://eslint.org/docs/rules/guard-for-in
65
+ "guard-for-in": "error",
66
+
67
+ // enforce a maximum number of classes per file
68
+ // https://eslint.org/docs/rules/max-classes-per-file
69
+ "max-classes-per-file": ["error", 1],
70
+
71
+ // disallow the use of alert, confirm, and prompt
72
+ // https://eslint.org/docs/rules/no-alert
73
+ // TODO: enable, semver-major
74
+ "no-alert": "warn",
75
+
76
+ // disallow use of arguments.caller or arguments.callee
77
+ // https://eslint.org/docs/rules/no-caller
78
+ "no-caller": "error",
79
+
80
+ // disallow lexical declarations in case/default clauses
81
+ // https://eslint.org/docs/rules/no-case-declarations
82
+ "no-case-declarations": "error",
83
+
84
+ // Disallow returning value in constructor
85
+ // https://eslint.org/docs/rules/no-constructor-return
86
+ "no-constructor-return": "error",
87
+
88
+ // disallow division operators explicitly at beginning of regular expression
89
+ // https://eslint.org/docs/rules/no-div-regex
90
+ "no-div-regex": "off",
91
+
92
+ // disallow else after a return in an if
93
+ // https://eslint.org/docs/rules/no-else-return
94
+ "no-else-return": ["error", { allowElseIf: false }],
95
+
96
+ // disallow empty functions, except for standalone funcs/arrows
97
+ // https://eslint.org/docs/rules/no-empty-function
98
+ "no-empty-function": [
99
+ "error",
100
+ {
101
+ allow: ["arrowFunctions", "functions", "methods"],
102
+ },
103
+ ],
104
+
105
+ // disallow empty destructuring patterns
106
+ // https://eslint.org/docs/rules/no-empty-pattern
107
+ "no-empty-pattern": "error",
108
+
109
+ // Disallow empty static blocks
110
+ // https://eslint.org/docs/latest/rules/no-empty-static-block
111
+ // TODO: semver-major, enable
112
+ "no-empty-static-block": "off",
113
+
114
+ // disallow comparisons to null without a type-checking operator
115
+ // https://eslint.org/docs/rules/no-eq-null
116
+ "no-eq-null": "off",
117
+
118
+ // disallow use of eval()
119
+ // https://eslint.org/docs/rules/no-eval
120
+ "no-eval": "error",
121
+
122
+ // disallow adding to native types
123
+ // https://eslint.org/docs/rules/no-extend-native
124
+ "no-extend-native": "error",
125
+
126
+ // disallow unnecessary function binding
127
+ // https://eslint.org/docs/rules/no-extra-bind
128
+ "no-extra-bind": "error",
129
+
130
+ // disallow Unnecessary Labels
131
+ // https://eslint.org/docs/rules/no-extra-label
132
+ "no-extra-label": "error",
133
+
134
+ // disallow fallthrough of case statements
135
+ // https://eslint.org/docs/rules/no-fallthrough
136
+ "no-fallthrough": "error",
137
+
138
+ // disallow the use of leading or trailing decimal points in numeric literals
139
+ // https://eslint.org/docs/rules/no-floating-decimal
140
+ "no-floating-decimal": "error",
141
+
142
+ // disallow reassignments of native objects or read-only globals
143
+ // https://eslint.org/docs/rules/no-global-assign
144
+ "no-global-assign": ["error", { exceptions: [] }],
145
+
146
+ // deprecated in favor of no-global-assign
147
+ // https://eslint.org/docs/rules/no-native-reassign
148
+ "no-native-reassign": "off",
149
+
150
+ // disallow implicit type conversions
151
+ // https://eslint.org/docs/rules/no-implicit-coercion
152
+ "no-implicit-coercion": [
153
+ "off",
154
+ {
155
+ boolean: false,
156
+ number: true,
157
+ string: true,
158
+ allow: [],
159
+ },
160
+ ],
161
+
162
+ // disallow var and named functions in global scope
163
+ // https://eslint.org/docs/rules/no-implicit-globals
164
+ "no-implicit-globals": "off",
165
+
166
+ // disallow use of eval()-like methods
167
+ // https://eslint.org/docs/rules/no-implied-eval
168
+ "no-implied-eval": "error",
169
+
170
+ // disallow this keywords outside of classes or class-like objects
171
+ // https://eslint.org/docs/rules/no-invalid-this
172
+ "no-invalid-this": "off",
173
+
174
+ // disallow usage of __iterator__ property
175
+ // https://eslint.org/docs/rules/no-iterator
176
+ "no-iterator": "error",
177
+
178
+ // disallow use of labels for anything other than loops and switches
179
+ // https://eslint.org/docs/rules/no-labels
180
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
181
+
182
+ // disallow unnecessary nested blocks
183
+ // https://eslint.org/docs/rules/no-lone-blocks
184
+ "no-lone-blocks": "error",
185
+
186
+ // disallow creation of functions within loops
187
+ // https://eslint.org/docs/rules/no-loop-func
188
+ "no-loop-func": "error",
189
+
190
+ // disallow magic numbers
191
+ // https://eslint.org/docs/rules/no-magic-numbers
192
+ "no-magic-numbers": [
193
+ "off",
194
+ {
195
+ ignore: [],
196
+ ignoreArrayIndexes: true,
197
+ enforceConst: true,
198
+ detectObjects: false,
199
+ },
200
+ ],
201
+
202
+ // disallow use of multiple spaces
203
+ // https://eslint.org/docs/rules/no-multi-spaces
204
+ "no-multi-spaces": [
205
+ "error",
206
+ {
207
+ ignoreEOLComments: false,
208
+ },
209
+ ],
210
+
211
+ // disallow use of multiline strings
212
+ // https://eslint.org/docs/rules/no-multi-str
213
+ "no-multi-str": "error",
214
+
215
+ // disallow use of new operator when not part of the assignment or comparison
216
+ // https://eslint.org/docs/rules/no-new
217
+ "no-new": "error",
218
+
219
+ // disallow use of new operator for Function object
220
+ // https://eslint.org/docs/rules/no-new-func
221
+ "no-new-func": "error",
222
+
223
+ // disallows creating new instances of String, Number, and Boolean
224
+ // https://eslint.org/docs/rules/no-new-wrappers
225
+ "no-new-wrappers": "error",
226
+
227
+ // Disallow \8 and \9 escape sequences in string literals
228
+ // https://eslint.org/docs/rules/no-nonoctal-decimal-escape
229
+ "no-nonoctal-decimal-escape": "error",
230
+
231
+ // Disallow calls to the Object constructor without an argument
232
+ // https://eslint.org/docs/latest/rules/no-object-constructor
233
+ // TODO: enable, semver-major
234
+ "no-object-constructor": "off",
235
+
236
+ // disallow use of (old style) octal literals
237
+ // https://eslint.org/docs/rules/no-octal
238
+ "no-octal": "error",
239
+
240
+ // disallow use of octal escape sequences in string literals, such as
241
+ // var foo = 'Copyright \251';
242
+ // https://eslint.org/docs/rules/no-octal-escape
243
+ "no-octal-escape": "error",
244
+
245
+ // disallow reassignment of function parameters
246
+ // disallow parameter object manipulation except for specific exclusions
247
+ // rule: https://eslint.org/docs/rules/no-param-reassign.html
248
+ "no-param-reassign": [
249
+ "error",
250
+ {
251
+ props: true,
252
+ ignorePropertyModificationsFor: [
253
+ "acc", // for reduce accumulators
254
+ "accumulator", // for reduce accumulators
255
+ "e", // for e.returnvalue
256
+ "ctx", // for Koa routing
257
+ "context", // for Koa routing
258
+ "req", // for Express requests
259
+ "request", // for Express requests
260
+ "res", // for Express responses
261
+ "response", // for Express responses
262
+ "$scope", // for Angular 1 scopes
263
+ "staticContext", // for ReactRouter context
264
+ ],
265
+ },
266
+ ],
267
+
268
+ // disallow usage of __proto__ property
269
+ // https://eslint.org/docs/rules/no-proto
270
+ "no-proto": "error",
271
+
272
+ // disallow declaring the same variable more than once
273
+ // https://eslint.org/docs/rules/no-redeclare
274
+ "no-redeclare": "error",
275
+
276
+ // disallow certain object properties
277
+ // https://eslint.org/docs/rules/no-restricted-properties
278
+ "no-restricted-properties": [
279
+ "error",
280
+ {
281
+ object: "arguments",
282
+ property: "callee",
283
+ message: "arguments.callee is deprecated",
284
+ },
285
+ {
286
+ object: "global",
287
+ property: "isFinite",
288
+ message: "Please use Number.isFinite instead",
289
+ },
290
+ {
291
+ object: "self",
292
+ property: "isFinite",
293
+ message: "Please use Number.isFinite instead",
294
+ },
295
+ {
296
+ object: "window",
297
+ property: "isFinite",
298
+ message: "Please use Number.isFinite instead",
299
+ },
300
+ {
301
+ object: "global",
302
+ property: "isNaN",
303
+ message: "Please use Number.isNaN instead",
304
+ },
305
+ {
306
+ object: "self",
307
+ property: "isNaN",
308
+ message: "Please use Number.isNaN instead",
309
+ },
310
+ {
311
+ object: "window",
312
+ property: "isNaN",
313
+ message: "Please use Number.isNaN instead",
314
+ },
315
+ {
316
+ property: "__defineGetter__",
317
+ message: "Please use Object.defineProperty instead.",
318
+ },
319
+ {
320
+ property: "__defineSetter__",
321
+ message: "Please use Object.defineProperty instead.",
322
+ },
323
+ {
324
+ object: "Math",
325
+ property: "pow",
326
+ message: "Use the exponentiation operator (**) instead.",
327
+ },
328
+ ],
329
+
330
+ // disallow use of assignment in return statement
331
+ // https://eslint.org/docs/rules/no-return-assign
332
+ "no-return-assign": ["error", "always"],
333
+
334
+ // disallow redundant `return await`
335
+ // https://eslint.org/docs/rules/no-return-await
336
+ "no-return-await": "error",
337
+
338
+ // disallow use of `javascript:` urls.
339
+ // https://eslint.org/docs/rules/no-script-url
340
+ "no-script-url": "error",
341
+
342
+ // disallow self assignment
343
+ // https://eslint.org/docs/rules/no-self-assign
344
+ "no-self-assign": [
345
+ "error",
346
+ {
347
+ props: true,
348
+ },
349
+ ],
350
+
351
+ // disallow comparisons where both sides are exactly the same
352
+ // https://eslint.org/docs/rules/no-self-compare
353
+ "no-self-compare": "error",
354
+
355
+ // disallow use of comma operator
356
+ // https://eslint.org/docs/rules/no-sequences
357
+ "no-sequences": "error",
358
+
359
+ // restrict what can be thrown as an exception
360
+ // https://eslint.org/docs/rules/no-throw-literal
361
+ "no-throw-literal": "error",
362
+
363
+ // disallow unmodified conditions of loops
364
+ // https://eslint.org/docs/rules/no-unmodified-loop-condition
365
+ "no-unmodified-loop-condition": "off",
366
+
367
+ // disallow usage of expressions in statement position
368
+ // https://eslint.org/docs/rules/no-unused-expressions
369
+ "no-unused-expressions": [
370
+ "error",
371
+ {
372
+ allowShortCircuit: false,
373
+ allowTernary: false,
374
+ allowTaggedTemplates: false,
375
+ },
376
+ ],
377
+
378
+ // disallow unused labels
379
+ // https://eslint.org/docs/rules/no-unused-labels
380
+ "no-unused-labels": "error",
381
+
382
+ // disallow unnecessary .call() and .apply()
383
+ // https://eslint.org/docs/rules/no-useless-call
384
+ "no-useless-call": "off",
385
+
386
+ // Disallow unnecessary catch clauses
387
+ // https://eslint.org/docs/rules/no-useless-catch
388
+ "no-useless-catch": "error",
389
+
390
+ // disallow useless string concatenation
391
+ // https://eslint.org/docs/rules/no-useless-concat
392
+ "no-useless-concat": "error",
393
+
394
+ // disallow unnecessary string escaping
395
+ // https://eslint.org/docs/rules/no-useless-escape
396
+ "no-useless-escape": "error",
397
+
398
+ // disallow redundant return; keywords
399
+ // https://eslint.org/docs/rules/no-useless-return
400
+ "no-useless-return": "error",
401
+
402
+ // disallow use of void operator
403
+ // https://eslint.org/docs/rules/no-void
404
+ "no-void": "error",
405
+
406
+ // disallow usage of configurable warning terms in comments: e.g. todo
407
+ // https://eslint.org/docs/rules/no-warning-comments
408
+ "no-warning-comments": [
409
+ "off",
410
+ { terms: ["todo", "fixme", "xxx"], location: "start" },
411
+ ],
412
+
413
+ // disallow use of the with statement
414
+ // https://eslint.org/docs/rules/no-with
415
+ "no-with": "error",
416
+
417
+ // require using Error objects as Promise rejection reasons
418
+ // https://eslint.org/docs/rules/prefer-promise-reject-errors
419
+ "prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
420
+
421
+ // Suggest using named capture group in regular expression
422
+ // https://eslint.org/docs/rules/prefer-named-capture-group
423
+ "prefer-named-capture-group": "off",
424
+
425
+ // Prefer Object.hasOwn() over Object.prototype.hasOwnProperty.call()
426
+ // https://eslint.org/docs/rules/prefer-object-has-own
427
+ // TODO: semver-major: enable thus rule, once eslint v8.5.0 is required
428
+ "prefer-object-has-own": "off",
429
+
430
+ // https://eslint.org/docs/rules/prefer-regex-literals
431
+ "prefer-regex-literals": [
432
+ "error",
433
+ {
434
+ disallowRedundantWrapping: true,
435
+ },
436
+ ],
437
+
438
+ // require use of the second argument for parseInt()
439
+ // https://eslint.org/docs/rules/radix
440
+ radix: "error",
441
+
442
+ // require `await` in `async function` (note: this is a horrible rule that should never be used)
443
+ // https://eslint.org/docs/rules/require-await
444
+ "require-await": "off",
445
+
446
+ // Enforce the use of u flag on RegExp
447
+ // https://eslint.org/docs/rules/require-unicode-regexp
448
+ "require-unicode-regexp": "off",
449
+
450
+ // requires to declare all vars on top of their containing scope
451
+ // https://eslint.org/docs/rules/vars-on-top
452
+ "vars-on-top": "error",
453
+
454
+ // require immediate function invocation to be wrapped in parentheses
455
+ // https://eslint.org/docs/rules/wrap-iife.html
456
+ "wrap-iife": ["error", "outside", { functionPrototypeMethods: false }],
457
+
458
+ // require or disallow Yoda conditions
459
+ // https://eslint.org/docs/rules/yoda
460
+ yoda: "error",
461
+ },
462
+ };