5etools-utils 0.16.42 → 0.17.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/bin/lint-js.js ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {Command} from "commander";
4
+ import {ESLint} from "eslint";
5
+
6
+ const program = new Command()
7
+ .name("vet-eslint")
8
+ .argument("[files...]", "Files or directories to lint")
9
+ .option("--fix", "Automatically fix problems")
10
+ ;
11
+
12
+ program.parse(process.argv);
13
+
14
+ const opts = program.opts();
15
+ const eslint = new ESLint({fix: opts.fix});
16
+ const results = await eslint.lintFiles(program.args.length ? program.args : ["."]);
17
+
18
+ if (opts.fix) await ESLint.outputFixes(results);
19
+
20
+ const formatter = await eslint.loadFormatter("stylish");
21
+ const resultText = formatter.format(results);
22
+ if (resultText) console.log(resultText);
23
+
24
+ const cntErrors = results.reduce((cnt, result) => cnt + result.errorCount, 0);
25
+
26
+ if (cntErrors) process.exitCode = 1;
@@ -0,0 +1,401 @@
1
+ export const ESLINT_RULES_BASE = {
2
+ "accessor-pairs": "off",
3
+ "arrow-spacing": [
4
+ "error",
5
+ {
6
+ "before": true,
7
+ "after": true,
8
+ },
9
+ ],
10
+ "block-spacing": [
11
+ "error",
12
+ "always",
13
+ ],
14
+ "brace-style": [
15
+ "error",
16
+ "1tbs",
17
+ {
18
+ "allowSingleLine": true,
19
+ },
20
+ ],
21
+ "comma-dangle": [
22
+ "error",
23
+ {
24
+ "arrays": "always-multiline",
25
+ "objects": "always-multiline",
26
+ "imports": "always-multiline",
27
+ "exports": "always-multiline",
28
+ "functions": "always-multiline",
29
+ },
30
+ ],
31
+ "comma-spacing": [
32
+ "error",
33
+ {
34
+ "before": false,
35
+ "after": true,
36
+ },
37
+ ],
38
+ "comma-style": [
39
+ "error",
40
+ "last",
41
+ ],
42
+ "constructor-super": "error",
43
+ "curly": [
44
+ "error",
45
+ "multi-line",
46
+ ],
47
+ "dot-location": [
48
+ "error",
49
+ "property",
50
+ ],
51
+ "eqeqeq": [
52
+ "error",
53
+ "always",
54
+ {
55
+ "null": "ignore",
56
+ },
57
+ ],
58
+ "func-call-spacing": [
59
+ "error",
60
+ "never",
61
+ ],
62
+ "generator-star-spacing": [
63
+ "error",
64
+ {
65
+ "before": false,
66
+ "after": true,
67
+ },
68
+ ],
69
+ "handle-callback-err": [
70
+ "error",
71
+ "^(err|error)$",
72
+ ],
73
+ "indent": [
74
+ "error",
75
+ "tab",
76
+ {
77
+ "SwitchCase": 1,
78
+ },
79
+ ],
80
+ "key-spacing": [
81
+ "error",
82
+ {
83
+ "beforeColon": false,
84
+ "afterColon": true,
85
+ },
86
+ ],
87
+ "keyword-spacing": [
88
+ "error",
89
+ {
90
+ "before": true,
91
+ "after": true,
92
+ },
93
+ ],
94
+ "new-cap": [
95
+ "error",
96
+ {
97
+ "newIsCap": true,
98
+ "newIsCapExceptions": ["constructor"],
99
+ "capIsNew": false,
100
+ },
101
+ ],
102
+ "new-parens": "error",
103
+ "no-array-constructor": "error",
104
+ "no-caller": "error",
105
+ "no-class-assign": "error",
106
+ "no-compare-neg-zero": "error",
107
+ "no-cond-assign": "error",
108
+ "no-const-assign": "error",
109
+ "no-constant-binary-expression": "error",
110
+ "no-constant-condition": [
111
+ "error",
112
+ {
113
+ "checkLoops": false,
114
+ },
115
+ ],
116
+ "no-control-regex": "error",
117
+ "no-debugger": "error",
118
+ "no-delete-var": "error",
119
+ "no-dupe-args": "error",
120
+ "no-dupe-class-members": "error",
121
+ "no-dupe-keys": "error",
122
+ "no-duplicate-case": "error",
123
+ "no-empty-character-class": "error",
124
+ "no-empty-pattern": "error",
125
+ "no-eval": "error",
126
+ "no-ex-assign": "error",
127
+ "no-extra-bind": "error",
128
+ "no-extra-boolean-cast": "error",
129
+ "no-extra-parens": [
130
+ "error",
131
+ "functions",
132
+ ],
133
+ "no-fallthrough": "error",
134
+ "no-floating-decimal": "error",
135
+ "no-func-assign": "error",
136
+ "no-global-assign": "error",
137
+ "no-implied-eval": "error",
138
+ "no-inner-declarations": [
139
+ "error",
140
+ "functions",
141
+ ],
142
+ "no-invalid-regexp": "error",
143
+ "no-irregular-whitespace": "error",
144
+ "no-iterator": "error",
145
+ "no-label-var": "error",
146
+ "no-labels": [
147
+ "error",
148
+ {
149
+ "allowLoop": true,
150
+ "allowSwitch": false,
151
+ },
152
+ ],
153
+ "no-lone-blocks": "error",
154
+ "no-mixed-operators": [
155
+ "error",
156
+ {
157
+ "groups": [
158
+ [
159
+ "==",
160
+ "!=",
161
+ "===",
162
+ "!==",
163
+ ">",
164
+ ">=",
165
+ "<",
166
+ "<=",
167
+ ],
168
+ [
169
+ "&&",
170
+ "||",
171
+ ],
172
+ [
173
+ "in",
174
+ "instanceof",
175
+ ],
176
+ ],
177
+ "allowSamePrecedence": true,
178
+ },
179
+ ],
180
+ "no-mixed-spaces-and-tabs": "error",
181
+ "no-multi-spaces": "error",
182
+ "no-multi-str": "error",
183
+ "no-multiple-empty-lines": [
184
+ "error",
185
+ {
186
+ "max": 1,
187
+ "maxEOF": 0,
188
+ },
189
+ ],
190
+ "no-negated-in-lhs": "error",
191
+ "no-new": "error",
192
+ "no-new-func": "error",
193
+ "no-new-object": "error",
194
+ "no-new-require": "error",
195
+ "no-new-symbol": "error",
196
+ "no-new-wrappers": "error",
197
+ "no-obj-calls": "error",
198
+ "no-octal": "error",
199
+ "no-octal-escape": "error",
200
+ "no-path-concat": "error",
201
+ "no-proto": "error",
202
+ "no-redeclare": "error",
203
+ "no-regex-spaces": "error",
204
+ "no-return-await": "error",
205
+ "no-self-assign": "error",
206
+ "no-self-compare": "error",
207
+ "no-sequences": "error",
208
+ "no-shadow-restricted-names": "error",
209
+ "no-sparse-arrays": "error",
210
+ "no-template-curly-in-string": "error",
211
+ "no-this-before-super": "error",
212
+ "no-throw-literal": "error",
213
+ "no-trailing-spaces": "error",
214
+ "no-undef": "error",
215
+ "no-undef-init": "error",
216
+ "no-unexpected-multiline": "error",
217
+ "no-unmodified-loop-condition": "error",
218
+ "no-unneeded-ternary": [
219
+ "error",
220
+ {
221
+ "defaultAssignment": false,
222
+ },
223
+ ],
224
+ "no-unreachable": "error",
225
+ "no-unsafe-finally": "error",
226
+ "no-unsafe-negation": "error",
227
+ "no-unused-expressions": [
228
+ "error",
229
+ {
230
+ "allowShortCircuit": true,
231
+ "allowTernary": true,
232
+ "allowTaggedTemplates": true,
233
+ },
234
+ ],
235
+ "no-unused-vars": "off",
236
+ "no-use-before-define": [
237
+ "error",
238
+ {
239
+ "functions": false,
240
+ "classes": false,
241
+ "variables": false,
242
+ },
243
+ ],
244
+ "no-useless-assignment": "error",
245
+ "no-useless-call": "error",
246
+ "no-useless-computed-key": "error",
247
+ "no-useless-constructor": "error",
248
+ "no-useless-escape": "error",
249
+ "no-useless-rename": "error",
250
+ "no-useless-return": "error",
251
+ "no-whitespace-before-property": "error",
252
+ "no-with": "error",
253
+ "object-property-newline": [
254
+ "error",
255
+ {
256
+ "allowMultiplePropertiesPerLine": true,
257
+ },
258
+ ],
259
+ "one-var": [
260
+ "error",
261
+ {
262
+ "initialized": "never",
263
+ },
264
+ ],
265
+ "operator-linebreak": [
266
+ "error",
267
+ "after",
268
+ {
269
+ "overrides": {
270
+ "?": "before",
271
+ ":": "before",
272
+ "+": "before",
273
+ "-": "before",
274
+ "*": "before",
275
+ "/": "before",
276
+ "||": "before",
277
+ "&&": "before",
278
+ },
279
+ },
280
+ ],
281
+ "padded-blocks": [
282
+ "error",
283
+ {
284
+ "blocks": "never",
285
+ "switches": "never",
286
+ "classes": "never",
287
+ },
288
+ ],
289
+ "prefer-promise-reject-errors": "error",
290
+ "rest-spread-spacing": [
291
+ "error",
292
+ "never",
293
+ ],
294
+ "semi": [
295
+ "error",
296
+ "always",
297
+ ],
298
+ "semi-spacing": [
299
+ "error",
300
+ {
301
+ "before": false,
302
+ "after": true,
303
+ },
304
+ ],
305
+ "space-before-blocks": [
306
+ "error",
307
+ "always",
308
+ ],
309
+ "space-before-function-paren": [
310
+ "error",
311
+ "always",
312
+ ],
313
+ "space-in-parens": [
314
+ "error",
315
+ "never",
316
+ ],
317
+ "space-infix-ops": "error",
318
+ "space-unary-ops": [
319
+ "error",
320
+ {
321
+ "words": true,
322
+ "nonwords": false,
323
+ },
324
+ ],
325
+ "spaced-comment": [
326
+ "error",
327
+ "always",
328
+ {
329
+ "line": {
330
+ "markers": [
331
+ "*package",
332
+ "!",
333
+ "/",
334
+ ",",
335
+ "=",
336
+ ],
337
+ },
338
+ "block": {
339
+ "balanced": true,
340
+ "markers": [
341
+ "*package",
342
+ "!",
343
+ ",",
344
+ ":",
345
+ "::",
346
+ "flow-include",
347
+ ],
348
+ "exceptions": [
349
+ "*",
350
+ ],
351
+ },
352
+ },
353
+ ],
354
+ "symbol-description": "error",
355
+ "template-curly-spacing": [
356
+ "error",
357
+ "never",
358
+ ],
359
+ "template-tag-spacing": [
360
+ "error",
361
+ "never",
362
+ ],
363
+ "unicode-bom": [
364
+ "error",
365
+ "never",
366
+ ],
367
+ "use-isnan": "error",
368
+ "valid-typeof": [
369
+ "error",
370
+ {
371
+ "requireStringLiterals": true,
372
+ },
373
+ ],
374
+ "wrap-iife": [
375
+ "error",
376
+ "any",
377
+ {
378
+ "functionPrototypeMethods": true,
379
+ },
380
+ ],
381
+ "yield-star-spacing": [
382
+ "error",
383
+ "both",
384
+ ],
385
+ "yoda": [
386
+ "error",
387
+ "never",
388
+ ],
389
+ "no-prototype-builtins": "off",
390
+ "require-atomic-updates": "off",
391
+ "no-console": "off",
392
+ "prefer-template": "error",
393
+ "quotes": [
394
+ "error",
395
+ "double",
396
+ {
397
+ "allowTemplateLiterals": true,
398
+ },
399
+ ],
400
+ "no-var": "error",
401
+ };
@@ -0,0 +1,67 @@
1
+ import js from "@eslint/js";
2
+ import globals from "globals";
3
+ import pluginVetJquery from "./eslint-plugin-jquery.js";
4
+ import {ESLINT_RULES_BASE} from "./eslint-config-rules.js";
5
+ import {ESLINT_GLOBALS_FOUNDRY, ESLINT_GLOBALS_VETOOLS} from "./eslint-globals.js";
6
+
7
+ const _FILES_JS = ["**/*.js", "**/*.cjs", "**/*.mjs"];
8
+
9
+ export const ESLINT_CONFIG_BASE = [
10
+ js.configs.recommended,
11
+ {
12
+ files: _FILES_JS,
13
+ languageOptions: {
14
+ ecmaVersion: "latest",
15
+ sourceType: "module",
16
+ },
17
+ rules: ESLINT_RULES_BASE,
18
+ },
19
+ ];
20
+
21
+ export const ESLINT_CONFIG_BROWSER = {
22
+ files: _FILES_JS,
23
+ plugins: {
24
+ "vet-jquery": pluginVetJquery,
25
+ },
26
+ languageOptions: {
27
+ globals: globals.browser,
28
+ },
29
+ rules: {
30
+ "vet-jquery/jquery": "error",
31
+ },
32
+ };
33
+
34
+ export const ESLINT_CONFIG_NODE = {
35
+ files: _FILES_JS,
36
+ languageOptions: {
37
+ globals: globals.node,
38
+ },
39
+ };
40
+
41
+ export const ESLINT_CONFIG_JEST = {
42
+ files: _FILES_JS,
43
+ languageOptions: {
44
+ globals: globals.jest,
45
+ },
46
+ };
47
+
48
+ export const ESLINT_CONFIG_VETOOLS = {
49
+ files: _FILES_JS,
50
+ languageOptions: {
51
+ globals: ESLINT_GLOBALS_VETOOLS,
52
+ },
53
+ };
54
+
55
+ export const ESLINT_CONFIG_FOUNDRY = {
56
+ files: _FILES_JS,
57
+ languageOptions: {
58
+ globals: ESLINT_GLOBALS_FOUNDRY,
59
+ },
60
+ };
61
+
62
+ export const ESLINT_CONFIG_NO_CONSOLE = {
63
+ files: _FILES_JS,
64
+ rules: {
65
+ "no-console": "error",
66
+ },
67
+ };