@lichthagel/eslint-config 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-PRESENT Jens Gatzweiler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @lichthagel/eslint-config
2
+
3
+ Collection of eslint configs I use for my projects.
4
+
5
+ ## Installation
6
+
7
+ `npm|yarn|pnpm i -D eslint @lichthagel/eslint-config`
8
+
9
+ ## Configuration
10
+
11
+ ```js
12
+ // @ts-check
13
+
14
+ import lichthagel from "@lichthagel/eslint-config";
15
+
16
+ /** @type {import("@lichthagel/eslint-config").FlatConfigItem[]} */
17
+ export default [
18
+ ...await lichthagel({
19
+ ...options
20
+ }),
21
+ ...otherSettings
22
+ ];
23
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,562 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ browser: () => browser_default,
34
+ default: () => factory_default,
35
+ javascript: () => javascript_default,
36
+ node: () => node_default,
37
+ perfectionist: () => perfectionist_default,
38
+ solid: () => solid_default,
39
+ stylistic: () => stylistic_default,
40
+ svelte: () => svelte_default,
41
+ tailwindcss: () => tailwindcss_default,
42
+ typescript: () => typescript_default,
43
+ unicorn: () => unicorn_default
44
+ });
45
+ module.exports = __toCommonJS(src_exports);
46
+
47
+ // src/configs/browser.ts
48
+ var import_globals = __toESM(require("globals"), 1);
49
+ var browser_default = [
50
+ {
51
+ name: "lichthagel/browser",
52
+ languageOptions: {
53
+ globals: {
54
+ ...import_globals.default.browser,
55
+ document: "readonly",
56
+ navigator: "readonly",
57
+ window: "readonly"
58
+ }
59
+ }
60
+ }
61
+ ];
62
+
63
+ // src/configs/javascript.ts
64
+ var import_js = __toESM(require("@eslint/js"), 1);
65
+ var import_globals2 = __toESM(require("globals"), 1);
66
+ var javascript_default = [
67
+ { name: "js/recommended", ...import_js.default.configs.recommended },
68
+ {
69
+ name: "lichthagel/javascript",
70
+ languageOptions: {
71
+ ecmaVersion: 2022,
72
+ globals: {
73
+ ...import_globals2.default.es2022
74
+ },
75
+ parserOptions: {
76
+ ecmaVersion: 2022,
77
+ sourceType: "module"
78
+ },
79
+ sourceType: "module"
80
+ },
81
+ rules: {
82
+ "accessor-pairs": "error",
83
+ "array-callback-return": "error",
84
+ "arrow-body-style": "error",
85
+ "block-scoped-var": "error",
86
+ "curly": ["error", "all"],
87
+ "default-case-last": "error",
88
+ "dot-notation": "error",
89
+ "eqeqeq": ["error", "smart"],
90
+ "new-cap": [
91
+ "error",
92
+ {
93
+ capIsNew: false,
94
+ newIsCap: true,
95
+ properties: true
96
+ }
97
+ ],
98
+ "no-alert": "error",
99
+ "no-array-constructor": "error",
100
+ "no-await-in-loop": "error",
101
+ "no-bitwise": "error",
102
+ "no-caller": "error",
103
+ "no-cond-assign": ["error", "always"],
104
+ "no-console": ["error", { allow: ["warn", "error"] }],
105
+ "no-duplicate-imports": "error",
106
+ "no-eval": "error",
107
+ "no-extend-native": "error",
108
+ "no-extra-bind": "error",
109
+ "no-implied-eval": "error",
110
+ "no-iterator": "error",
111
+ "no-label-var": "error",
112
+ "no-labels": "error",
113
+ "no-lone-blocks": "error",
114
+ "no-multi-assign": "error",
115
+ "no-multi-str": "error",
116
+ "no-new": "error",
117
+ "no-new-func": "error",
118
+ "no-new-wrappers": "error",
119
+ "no-octal-escape": "error",
120
+ "no-promise-executor-return": ["error", { allowVoid: true }],
121
+ "no-proto": "error",
122
+ "no-restricted-globals": ["error", { name: "global", message: "Use `globalThis` instead." }, { name: "self", message: "Use `globalThis` instead." }],
123
+ "no-restricted-properties": [
124
+ "error",
125
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
126
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
127
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
128
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
129
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
130
+ ],
131
+ "no-restricted-syntax": [
132
+ "error",
133
+ "DebuggerStatement",
134
+ "LabeledStatement",
135
+ "WithStatement",
136
+ "TSEnumDeclaration[const=true]",
137
+ "TSExportAssignment"
138
+ ],
139
+ "no-self-compare": "error",
140
+ "no-sequences": "error",
141
+ "no-template-curly-in-string": "error",
142
+ "no-throw-literal": "error",
143
+ "no-undef-init": "error",
144
+ "no-unmodified-loop-condition": "error",
145
+ "no-unneeded-ternary": "error",
146
+ "no-unreachable-loop": "error",
147
+ "no-unused-expressions": ["error", { allowShortCircuit: true, allowTaggedTemplates: true, allowTernary: true }],
148
+ "no-useless-call": "error",
149
+ "no-useless-computed-key": "error",
150
+ "no-useless-concat": "error",
151
+ "no-useless-constructor": "error",
152
+ "no-useless-rename": "error",
153
+ "no-useless-return": "error",
154
+ "no-var": "error",
155
+ "object-shorthand": ["error", "always", { ignoreConstructors: false }],
156
+ "prefer-arrow-callback": "error",
157
+ "prefer-const": "error",
158
+ "prefer-destructuring": ["error", { AssignmentExpression: { array: false, object: false } }],
159
+ "prefer-exponentiation-operator": "error",
160
+ "prefer-object-spread": "error",
161
+ "prefer-promise-reject-errors": "error",
162
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
163
+ "prefer-rest-params": "error",
164
+ "prefer-spread": "error",
165
+ "prefer-template": "error",
166
+ "require-await": "error",
167
+ "sort-imports": [
168
+ "error",
169
+ {
170
+ allowSeparatedGroups: true,
171
+ ignoreCase: false,
172
+ ignoreDeclarationSort: true
173
+ }
174
+ ],
175
+ "symbol-description": "error",
176
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
177
+ "valid-typeof": ["error", { requireStringLiterals: true }],
178
+ "yoda": "error"
179
+ }
180
+ }
181
+ ];
182
+
183
+ // src/configs/node.ts
184
+ var import_globals3 = __toESM(require("globals"), 1);
185
+ var node = async () => {
186
+ const pluginN = await import("eslint-plugin-n").then((mod) => mod.default);
187
+ return [
188
+ pluginN.configs["flat/recommended-module"],
189
+ {
190
+ name: "lichthagel/node",
191
+ languageOptions: {
192
+ globals: {
193
+ ...import_globals3.default.node
194
+ }
195
+ },
196
+ rules: {
197
+ "n/handle-callback-err": ["error", "^.*(e|E)rr(or)?$"],
198
+ "n/no-new-require": "error",
199
+ "n/no-path-concat": "error",
200
+ "n/no-process-env": "error",
201
+ "n/no-missing-import": "off",
202
+ "n/no-missing-require": "off"
203
+ }
204
+ }
205
+ ];
206
+ };
207
+ var node_default = node;
208
+
209
+ // src/configs/perfectionist.ts
210
+ var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
211
+ var perfectionist_default = [
212
+ {
213
+ name: "perfectionist/recommended-natural",
214
+ ...import_eslint_plugin_perfectionist.default.configs["recommended-natural"]
215
+ },
216
+ {
217
+ name: "lichthagel/perfectionist",
218
+ rules: {
219
+ "perfectionist/sort-imports": [
220
+ "error",
221
+ {
222
+ type: "natural",
223
+ internalPattern: [
224
+ "^@/.*",
225
+ "^~.*",
226
+ "^$.*",
227
+ "^#.*"
228
+ ],
229
+ matcher: "regex"
230
+ }
231
+ ],
232
+ "perfectionist/sort-object-types": "off",
233
+ "perfectionist/sort-objects": [
234
+ "off",
235
+ {
236
+ customGroups: {
237
+ id: ["id", "name", "slug"]
238
+ },
239
+ groups: ["id", "unknown"],
240
+ partitionByComment: true,
241
+ partitionByNewLine: true
242
+ }
243
+ ],
244
+ "perfectionist/sort-union-types": [
245
+ "error",
246
+ {
247
+ groups: [
248
+ "named",
249
+ ["intersection", "union"],
250
+ "unknown",
251
+ "nullish"
252
+ ]
253
+ }
254
+ ],
255
+ "sort-imports": "off"
256
+ }
257
+ }
258
+ ];
259
+
260
+ // src/configs/solid.ts
261
+ var solid = async (options = {}) => {
262
+ const {
263
+ withTypescript = false
264
+ } = options;
265
+ const configSolid = await import("eslint-plugin-solid/configs/recommended").then((mod) => mod.default);
266
+ return [
267
+ {
268
+ name: "solid/recommended",
269
+ files: ["**/*.jsx", ...withTypescript ? ["**/*.tsx"] : []],
270
+ ...configSolid
271
+ }
272
+ ];
273
+ };
274
+ var solid_default = solid;
275
+
276
+ // src/configs/stylistic.ts
277
+ var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
278
+ var stylistic_default = [
279
+ {
280
+ name: "stylistic/custom",
281
+ ...import_eslint_plugin.default.configs.customize({
282
+ arrowParens: true,
283
+ braceStyle: "1tbs",
284
+ commaDangle: "always-multiline",
285
+ flat: true,
286
+ indent: 2,
287
+ jsx: true,
288
+ quoteProps: "consistent-as-needed",
289
+ quotes: "double",
290
+ semi: true
291
+ })
292
+ },
293
+ {
294
+ name: "lichthagel/stylistic",
295
+ rules: {
296
+ // JavaScript
297
+ "@stylistic/array-bracket-newline": ["error", { minItems: 4, multiline: true }],
298
+ "@stylistic/array-element-newline": ["error", { minItems: 4, multiline: true }],
299
+ "@stylistic/curly-newline": ["error", { consistent: true }],
300
+ "@stylistic/function-call-argument-newline": ["error", "consistent"],
301
+ "@stylistic/function-call-spacing": ["error", "never"],
302
+ "@stylistic/function-paren-newline": ["error", "multiline-arguments"],
303
+ "@stylistic/generator-star-spacing": ["error", { after: false, before: true }],
304
+ "@stylistic/implicit-arrow-linebreak": ["off", "beside"],
305
+ "@stylistic/lines-around-comment": [
306
+ "error",
307
+ {
308
+ afterHashbangComment: true,
309
+ allowArrayStart: true,
310
+ allowBlockStart: true,
311
+ allowClassStart: true,
312
+ allowEnumStart: true,
313
+ allowInterfaceStart: true,
314
+ allowModuleStart: true,
315
+ allowObjectStart: true,
316
+ allowTypeStart: true,
317
+ applyDefaultIgnorePatterns: true,
318
+ beforeBlockComment: true
319
+ }
320
+ ],
321
+ "@stylistic/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: false }],
322
+ "@stylistic/multiline-ternary": ["error", "always-multiline"],
323
+ "@stylistic/newline-per-chained-call": ["error", { ignoreChainWithDepth: 2 }],
324
+ "@stylistic/no-extra-semi": "error",
325
+ "@stylistic/nonblock-statement-body-position": ["error", "beside"],
326
+ "@stylistic/object-curly-newline": ["error", { consistent: true, minProperties: 4, multiline: true }],
327
+ "@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
328
+ "@stylistic/one-var-declaration-per-line": ["error", "always"],
329
+ "@stylistic/operator-linebreak": ["error", "before"],
330
+ "@stylistic/semi-style": ["error", "last"],
331
+ "@stylistic/switch-colon-spacing": ["error", { after: true, before: false }],
332
+ // JSX
333
+ "@stylistic/jsx-closing-bracket-location": ["error", "line-aligned"],
334
+ "@stylistic/jsx-curly-brace-presence": ["error", { children: "never", propElementValues: "always", props: "never" }],
335
+ "@stylistic/jsx-pascal-case": "error",
336
+ "@stylistic/jsx-props-no-multi-spaces": "error",
337
+ "@stylistic/jsx-self-closing-comp": "error"
338
+ }
339
+ }
340
+ ];
341
+
342
+ // src/configs/svelte.ts
343
+ var SVELTE_FILES = ["**/*.svelte"];
344
+ var svelte = async (options = {}) => {
345
+ const {
346
+ disableStylistic = false,
347
+ withTypescript = false
348
+ } = options;
349
+ const pluginSvelte = await import("eslint-plugin-svelte").then((mod) => mod.default);
350
+ const configs = [
351
+ ...pluginSvelte.configs["flat/recommended"].map((configItem) => ({
352
+ name: "svelte/recommended",
353
+ ...configItem
354
+ })),
355
+ {
356
+ name: "lichthagel/svelte",
357
+ files: SVELTE_FILES,
358
+ languageOptions: {
359
+ parserOptions: {
360
+ extraFileExtensions: [".svelte"],
361
+ parser: withTypescript ? "@typescript-eslint/parser" : null,
362
+ project: true
363
+ }
364
+ },
365
+ rules: {
366
+ "svelte/block-lang": [
367
+ "error",
368
+ {
369
+ enforceScriptPresent: false,
370
+ enforceStylePresent: false,
371
+ script: [withTypescript ? "ts" : null]
372
+ }
373
+ ],
374
+ "svelte/first-attribute-linebreak": [
375
+ "error",
376
+ {
377
+ multiline: "below",
378
+ singleline: "beside"
379
+ }
380
+ ],
381
+ "svelte/html-closing-bracket-spacing": [
382
+ "error",
383
+ {
384
+ endTag: "never",
385
+ selfClosingTag: "always",
386
+ startTag: "never"
387
+ }
388
+ ],
389
+ "svelte/html-quotes": [
390
+ "error",
391
+ {
392
+ prefer: "double"
393
+ }
394
+ ],
395
+ "svelte/indent": [
396
+ "error",
397
+ {
398
+ alignAttributesVertically: true,
399
+ indent: 2
400
+ }
401
+ ],
402
+ "svelte/infinite-reactive-loop": "error",
403
+ "svelte/max-attributes-per-line": [
404
+ "error",
405
+ {
406
+ multiline: 1,
407
+ singleline: 3
408
+ }
409
+ ],
410
+ "svelte/mustache-spacing": "error",
411
+ "svelte/no-dupe-on-directives": "error",
412
+ "svelte/no-dupe-use-directives": "error",
413
+ "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
414
+ "svelte/no-goto-without-base": "error",
415
+ "svelte/no-ignored-unsubscribe": "error",
416
+ "svelte/no-immutable-reactive-statements": "error",
417
+ "svelte/no-reactive-functions": "error",
418
+ "svelte/no-reactive-literals": "error",
419
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
420
+ "svelte/no-target-blank": "error",
421
+ "svelte/no-trailing-spaces": "error",
422
+ "svelte/no-useless-mustaches": "error",
423
+ "svelte/require-store-callbacks-use-set-param": "error",
424
+ "svelte/spaced-html-comment": ["error", "always"],
425
+ "svelte/valid-each-key": "error",
426
+ ...disableStylistic ? {
427
+ "@stylistic/indent": "off",
428
+ // superseded by svelte/indent
429
+ "@stylistic/no-trailing-spaces": "off"
430
+ // superseded by svelte/no-trailing-spaces
431
+ } : {}
432
+ }
433
+ }
434
+ ];
435
+ return configs;
436
+ };
437
+ var svelte_default = svelte;
438
+
439
+ // src/configs/tailwindcss.ts
440
+ var tailwindcss = async () => {
441
+ const pluginTailwind = await import("eslint-plugin-tailwindcss").then((mod) => mod.default);
442
+ return [
443
+ ...pluginTailwind.configs["flat/recommended"].map((config) => ({
444
+ ...config,
445
+ name: config.name?.replaceAll(":", "/")
446
+ })),
447
+ {
448
+ name: "lichthagel/tailwindcss",
449
+ rules: {
450
+ "tailwindcss/classnames-order": "error",
451
+ "tailwindcss/enforces-negative-arbitrary-values": "error",
452
+ "tailwindcss/enforces-shorthand": "error",
453
+ "tailwindcss/no-contradicting-classname": "error",
454
+ "tailwindcss/no-unnecessary-arbitrary-value": "error"
455
+ }
456
+ }
457
+ ];
458
+ };
459
+ var tailwindcss_default = tailwindcss;
460
+
461
+ // src/configs/typescript.ts
462
+ var import_typescript_eslint = __toESM(require("typescript-eslint"), 1);
463
+ var typescript_default = [
464
+ ...import_typescript_eslint.default.configs.recommendedTypeChecked,
465
+ {
466
+ name: "lichthagel/typescript",
467
+ rules: {
468
+ "@typescript-eslint/array-type": "error",
469
+ "@typescript-eslint/consistent-indexed-object-style": ["warn", "index-signature"],
470
+ "@typescript-eslint/consistent-type-assertions": ["warn", { assertionStyle: "as", objectLiteralTypeAssertions: "allow" }],
471
+ "@typescript-eslint/consistent-type-definitions": ["warn", "type"],
472
+ "@typescript-eslint/default-param-last": "warn",
473
+ "@typescript-eslint/explicit-member-accessibility": "error",
474
+ "@typescript-eslint/method-signature-style": "warn",
475
+ "@typescript-eslint/no-array-constructor": "error",
476
+ "default-param-last": "off"
477
+ }
478
+ }
479
+ ];
480
+
481
+ // src/configs/unicorn.ts
482
+ var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
483
+ var unicorn_default = [
484
+ {
485
+ name: "unicorn/flat/recommended",
486
+ ...import_eslint_plugin_unicorn.default.configs["flat/recommended"]
487
+ },
488
+ {
489
+ name: "lichthagel/unicorn",
490
+ rules: {
491
+ "unicorn/consistent-destructuring": "error",
492
+ "unicorn/filename-case": [
493
+ "error",
494
+ {
495
+ cases: {
496
+ camelCase: true,
497
+ kebabCase: true,
498
+ pascalCase: true
499
+ }
500
+ }
501
+ ],
502
+ "unicorn/import-style": "off",
503
+ "unicorn/no-null": "off",
504
+ "unicorn/no-useless-undefined": ["error", { checkArguments: false }],
505
+ "unicorn/prevent-abbreviations": "off"
506
+ }
507
+ }
508
+ ];
509
+
510
+ // src/factory.ts
511
+ var lichthagel = async (options = {}) => {
512
+ const {
513
+ browser = false,
514
+ node: node2 = false,
515
+ solid: solid2 = false,
516
+ stylistic: stylistic2 = true,
517
+ svelte: svelte2 = false,
518
+ tailwindcss: tailwindcss2 = false,
519
+ typescript = true,
520
+ ...rest
521
+ } = options;
522
+ if (Object.keys(rest).length > 0) {
523
+ throw new Error(`Unknown options: ${Object.keys(rest).join(", ")}`);
524
+ }
525
+ const config = [...javascript_default, ...unicorn_default, ...perfectionist_default];
526
+ if (stylistic2) {
527
+ config.push(...stylistic_default);
528
+ }
529
+ if (browser) {
530
+ config.push(...browser_default);
531
+ }
532
+ if (node2) {
533
+ config.push(...await node_default());
534
+ }
535
+ if (typescript) {
536
+ config.push(...typescript_default);
537
+ }
538
+ if (solid2) {
539
+ config.push(...await solid_default({ withTypescript: typescript }));
540
+ }
541
+ if (svelte2) {
542
+ config.push(...await svelte_default({ disableStylistic: stylistic2, withTypescript: typescript }));
543
+ }
544
+ if (tailwindcss2) {
545
+ config.push(...await tailwindcss_default());
546
+ }
547
+ return config;
548
+ };
549
+ var factory_default = lichthagel;
550
+ // Annotate the CommonJS export names for ESM import in node:
551
+ 0 && (module.exports = {
552
+ browser,
553
+ javascript,
554
+ node,
555
+ perfectionist,
556
+ solid,
557
+ stylistic,
558
+ svelte,
559
+ tailwindcss,
560
+ typescript,
561
+ unicorn
562
+ });