@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/dist/index.js ADDED
@@ -0,0 +1,516 @@
1
+ // src/configs/browser.ts
2
+ import globals from "globals";
3
+ var browser_default = [
4
+ {
5
+ name: "lichthagel/browser",
6
+ languageOptions: {
7
+ globals: {
8
+ ...globals.browser,
9
+ document: "readonly",
10
+ navigator: "readonly",
11
+ window: "readonly"
12
+ }
13
+ }
14
+ }
15
+ ];
16
+
17
+ // src/configs/javascript.ts
18
+ import js from "@eslint/js";
19
+ import globals2 from "globals";
20
+ var javascript_default = [
21
+ { name: "js/recommended", ...js.configs.recommended },
22
+ {
23
+ name: "lichthagel/javascript",
24
+ languageOptions: {
25
+ ecmaVersion: 2022,
26
+ globals: {
27
+ ...globals2.es2022
28
+ },
29
+ parserOptions: {
30
+ ecmaVersion: 2022,
31
+ sourceType: "module"
32
+ },
33
+ sourceType: "module"
34
+ },
35
+ rules: {
36
+ "accessor-pairs": "error",
37
+ "array-callback-return": "error",
38
+ "arrow-body-style": "error",
39
+ "block-scoped-var": "error",
40
+ "curly": ["error", "all"],
41
+ "default-case-last": "error",
42
+ "dot-notation": "error",
43
+ "eqeqeq": ["error", "smart"],
44
+ "new-cap": [
45
+ "error",
46
+ {
47
+ capIsNew: false,
48
+ newIsCap: true,
49
+ properties: true
50
+ }
51
+ ],
52
+ "no-alert": "error",
53
+ "no-array-constructor": "error",
54
+ "no-await-in-loop": "error",
55
+ "no-bitwise": "error",
56
+ "no-caller": "error",
57
+ "no-cond-assign": ["error", "always"],
58
+ "no-console": ["error", { allow: ["warn", "error"] }],
59
+ "no-duplicate-imports": "error",
60
+ "no-eval": "error",
61
+ "no-extend-native": "error",
62
+ "no-extra-bind": "error",
63
+ "no-implied-eval": "error",
64
+ "no-iterator": "error",
65
+ "no-label-var": "error",
66
+ "no-labels": "error",
67
+ "no-lone-blocks": "error",
68
+ "no-multi-assign": "error",
69
+ "no-multi-str": "error",
70
+ "no-new": "error",
71
+ "no-new-func": "error",
72
+ "no-new-wrappers": "error",
73
+ "no-octal-escape": "error",
74
+ "no-promise-executor-return": ["error", { allowVoid: true }],
75
+ "no-proto": "error",
76
+ "no-restricted-globals": ["error", { name: "global", message: "Use `globalThis` instead." }, { name: "self", message: "Use `globalThis` instead." }],
77
+ "no-restricted-properties": [
78
+ "error",
79
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
80
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
81
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
82
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
83
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
84
+ ],
85
+ "no-restricted-syntax": [
86
+ "error",
87
+ "DebuggerStatement",
88
+ "LabeledStatement",
89
+ "WithStatement",
90
+ "TSEnumDeclaration[const=true]",
91
+ "TSExportAssignment"
92
+ ],
93
+ "no-self-compare": "error",
94
+ "no-sequences": "error",
95
+ "no-template-curly-in-string": "error",
96
+ "no-throw-literal": "error",
97
+ "no-undef-init": "error",
98
+ "no-unmodified-loop-condition": "error",
99
+ "no-unneeded-ternary": "error",
100
+ "no-unreachable-loop": "error",
101
+ "no-unused-expressions": ["error", { allowShortCircuit: true, allowTaggedTemplates: true, allowTernary: true }],
102
+ "no-useless-call": "error",
103
+ "no-useless-computed-key": "error",
104
+ "no-useless-concat": "error",
105
+ "no-useless-constructor": "error",
106
+ "no-useless-rename": "error",
107
+ "no-useless-return": "error",
108
+ "no-var": "error",
109
+ "object-shorthand": ["error", "always", { ignoreConstructors: false }],
110
+ "prefer-arrow-callback": "error",
111
+ "prefer-const": "error",
112
+ "prefer-destructuring": ["error", { AssignmentExpression: { array: false, object: false } }],
113
+ "prefer-exponentiation-operator": "error",
114
+ "prefer-object-spread": "error",
115
+ "prefer-promise-reject-errors": "error",
116
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
117
+ "prefer-rest-params": "error",
118
+ "prefer-spread": "error",
119
+ "prefer-template": "error",
120
+ "require-await": "error",
121
+ "sort-imports": [
122
+ "error",
123
+ {
124
+ allowSeparatedGroups: true,
125
+ ignoreCase: false,
126
+ ignoreDeclarationSort: true
127
+ }
128
+ ],
129
+ "symbol-description": "error",
130
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
131
+ "valid-typeof": ["error", { requireStringLiterals: true }],
132
+ "yoda": "error"
133
+ }
134
+ }
135
+ ];
136
+
137
+ // src/configs/node.ts
138
+ import globals3 from "globals";
139
+ var node = async () => {
140
+ const pluginN = await import("eslint-plugin-n").then((mod) => mod.default);
141
+ return [
142
+ pluginN.configs["flat/recommended-module"],
143
+ {
144
+ name: "lichthagel/node",
145
+ languageOptions: {
146
+ globals: {
147
+ ...globals3.node
148
+ }
149
+ },
150
+ rules: {
151
+ "n/handle-callback-err": ["error", "^.*(e|E)rr(or)?$"],
152
+ "n/no-new-require": "error",
153
+ "n/no-path-concat": "error",
154
+ "n/no-process-env": "error",
155
+ "n/no-missing-import": "off",
156
+ "n/no-missing-require": "off"
157
+ }
158
+ }
159
+ ];
160
+ };
161
+ var node_default = node;
162
+
163
+ // src/configs/perfectionist.ts
164
+ import perfectionst from "eslint-plugin-perfectionist";
165
+ var perfectionist_default = [
166
+ {
167
+ name: "perfectionist/recommended-natural",
168
+ ...perfectionst.configs["recommended-natural"]
169
+ },
170
+ {
171
+ name: "lichthagel/perfectionist",
172
+ rules: {
173
+ "perfectionist/sort-imports": [
174
+ "error",
175
+ {
176
+ type: "natural",
177
+ internalPattern: [
178
+ "^@/.*",
179
+ "^~.*",
180
+ "^$.*",
181
+ "^#.*"
182
+ ],
183
+ matcher: "regex"
184
+ }
185
+ ],
186
+ "perfectionist/sort-object-types": "off",
187
+ "perfectionist/sort-objects": [
188
+ "off",
189
+ {
190
+ customGroups: {
191
+ id: ["id", "name", "slug"]
192
+ },
193
+ groups: ["id", "unknown"],
194
+ partitionByComment: true,
195
+ partitionByNewLine: true
196
+ }
197
+ ],
198
+ "perfectionist/sort-union-types": [
199
+ "error",
200
+ {
201
+ groups: [
202
+ "named",
203
+ ["intersection", "union"],
204
+ "unknown",
205
+ "nullish"
206
+ ]
207
+ }
208
+ ],
209
+ "sort-imports": "off"
210
+ }
211
+ }
212
+ ];
213
+
214
+ // src/configs/solid.ts
215
+ var solid = async (options = {}) => {
216
+ const {
217
+ withTypescript = false
218
+ } = options;
219
+ const configSolid = await import("eslint-plugin-solid/configs/recommended").then((mod) => mod.default);
220
+ return [
221
+ {
222
+ name: "solid/recommended",
223
+ files: ["**/*.jsx", ...withTypescript ? ["**/*.tsx"] : []],
224
+ ...configSolid
225
+ }
226
+ ];
227
+ };
228
+ var solid_default = solid;
229
+
230
+ // src/configs/stylistic.ts
231
+ import stylistic from "@stylistic/eslint-plugin";
232
+ var stylistic_default = [
233
+ {
234
+ name: "stylistic/custom",
235
+ ...stylistic.configs.customize({
236
+ arrowParens: true,
237
+ braceStyle: "1tbs",
238
+ commaDangle: "always-multiline",
239
+ flat: true,
240
+ indent: 2,
241
+ jsx: true,
242
+ quoteProps: "consistent-as-needed",
243
+ quotes: "double",
244
+ semi: true
245
+ })
246
+ },
247
+ {
248
+ name: "lichthagel/stylistic",
249
+ rules: {
250
+ // JavaScript
251
+ "@stylistic/array-bracket-newline": ["error", { minItems: 4, multiline: true }],
252
+ "@stylistic/array-element-newline": ["error", { minItems: 4, multiline: true }],
253
+ "@stylistic/curly-newline": ["error", { consistent: true }],
254
+ "@stylistic/function-call-argument-newline": ["error", "consistent"],
255
+ "@stylistic/function-call-spacing": ["error", "never"],
256
+ "@stylistic/function-paren-newline": ["error", "multiline-arguments"],
257
+ "@stylistic/generator-star-spacing": ["error", { after: false, before: true }],
258
+ "@stylistic/implicit-arrow-linebreak": ["off", "beside"],
259
+ "@stylistic/lines-around-comment": [
260
+ "error",
261
+ {
262
+ afterHashbangComment: true,
263
+ allowArrayStart: true,
264
+ allowBlockStart: true,
265
+ allowClassStart: true,
266
+ allowEnumStart: true,
267
+ allowInterfaceStart: true,
268
+ allowModuleStart: true,
269
+ allowObjectStart: true,
270
+ allowTypeStart: true,
271
+ applyDefaultIgnorePatterns: true,
272
+ beforeBlockComment: true
273
+ }
274
+ ],
275
+ "@stylistic/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: false }],
276
+ "@stylistic/multiline-ternary": ["error", "always-multiline"],
277
+ "@stylistic/newline-per-chained-call": ["error", { ignoreChainWithDepth: 2 }],
278
+ "@stylistic/no-extra-semi": "error",
279
+ "@stylistic/nonblock-statement-body-position": ["error", "beside"],
280
+ "@stylistic/object-curly-newline": ["error", { consistent: true, minProperties: 4, multiline: true }],
281
+ "@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
282
+ "@stylistic/one-var-declaration-per-line": ["error", "always"],
283
+ "@stylistic/operator-linebreak": ["error", "before"],
284
+ "@stylistic/semi-style": ["error", "last"],
285
+ "@stylistic/switch-colon-spacing": ["error", { after: true, before: false }],
286
+ // JSX
287
+ "@stylistic/jsx-closing-bracket-location": ["error", "line-aligned"],
288
+ "@stylistic/jsx-curly-brace-presence": ["error", { children: "never", propElementValues: "always", props: "never" }],
289
+ "@stylistic/jsx-pascal-case": "error",
290
+ "@stylistic/jsx-props-no-multi-spaces": "error",
291
+ "@stylistic/jsx-self-closing-comp": "error"
292
+ }
293
+ }
294
+ ];
295
+
296
+ // src/configs/svelte.ts
297
+ var SVELTE_FILES = ["**/*.svelte"];
298
+ var svelte = async (options = {}) => {
299
+ const {
300
+ disableStylistic = false,
301
+ withTypescript = false
302
+ } = options;
303
+ const pluginSvelte = await import("eslint-plugin-svelte").then((mod) => mod.default);
304
+ const configs = [
305
+ ...pluginSvelte.configs["flat/recommended"].map((configItem) => ({
306
+ name: "svelte/recommended",
307
+ ...configItem
308
+ })),
309
+ {
310
+ name: "lichthagel/svelte",
311
+ files: SVELTE_FILES,
312
+ languageOptions: {
313
+ parserOptions: {
314
+ extraFileExtensions: [".svelte"],
315
+ parser: withTypescript ? "@typescript-eslint/parser" : null,
316
+ project: true
317
+ }
318
+ },
319
+ rules: {
320
+ "svelte/block-lang": [
321
+ "error",
322
+ {
323
+ enforceScriptPresent: false,
324
+ enforceStylePresent: false,
325
+ script: [withTypescript ? "ts" : null]
326
+ }
327
+ ],
328
+ "svelte/first-attribute-linebreak": [
329
+ "error",
330
+ {
331
+ multiline: "below",
332
+ singleline: "beside"
333
+ }
334
+ ],
335
+ "svelte/html-closing-bracket-spacing": [
336
+ "error",
337
+ {
338
+ endTag: "never",
339
+ selfClosingTag: "always",
340
+ startTag: "never"
341
+ }
342
+ ],
343
+ "svelte/html-quotes": [
344
+ "error",
345
+ {
346
+ prefer: "double"
347
+ }
348
+ ],
349
+ "svelte/indent": [
350
+ "error",
351
+ {
352
+ alignAttributesVertically: true,
353
+ indent: 2
354
+ }
355
+ ],
356
+ "svelte/infinite-reactive-loop": "error",
357
+ "svelte/max-attributes-per-line": [
358
+ "error",
359
+ {
360
+ multiline: 1,
361
+ singleline: 3
362
+ }
363
+ ],
364
+ "svelte/mustache-spacing": "error",
365
+ "svelte/no-dupe-on-directives": "error",
366
+ "svelte/no-dupe-use-directives": "error",
367
+ "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
368
+ "svelte/no-goto-without-base": "error",
369
+ "svelte/no-ignored-unsubscribe": "error",
370
+ "svelte/no-immutable-reactive-statements": "error",
371
+ "svelte/no-reactive-functions": "error",
372
+ "svelte/no-reactive-literals": "error",
373
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
374
+ "svelte/no-target-blank": "error",
375
+ "svelte/no-trailing-spaces": "error",
376
+ "svelte/no-useless-mustaches": "error",
377
+ "svelte/require-store-callbacks-use-set-param": "error",
378
+ "svelte/spaced-html-comment": ["error", "always"],
379
+ "svelte/valid-each-key": "error",
380
+ ...disableStylistic ? {
381
+ "@stylistic/indent": "off",
382
+ // superseded by svelte/indent
383
+ "@stylistic/no-trailing-spaces": "off"
384
+ // superseded by svelte/no-trailing-spaces
385
+ } : {}
386
+ }
387
+ }
388
+ ];
389
+ return configs;
390
+ };
391
+ var svelte_default = svelte;
392
+
393
+ // src/configs/tailwindcss.ts
394
+ var tailwindcss = async () => {
395
+ const pluginTailwind = await import("eslint-plugin-tailwindcss").then((mod) => mod.default);
396
+ return [
397
+ ...pluginTailwind.configs["flat/recommended"].map((config) => ({
398
+ ...config,
399
+ name: config.name?.replaceAll(":", "/")
400
+ })),
401
+ {
402
+ name: "lichthagel/tailwindcss",
403
+ rules: {
404
+ "tailwindcss/classnames-order": "error",
405
+ "tailwindcss/enforces-negative-arbitrary-values": "error",
406
+ "tailwindcss/enforces-shorthand": "error",
407
+ "tailwindcss/no-contradicting-classname": "error",
408
+ "tailwindcss/no-unnecessary-arbitrary-value": "error"
409
+ }
410
+ }
411
+ ];
412
+ };
413
+ var tailwindcss_default = tailwindcss;
414
+
415
+ // src/configs/typescript.ts
416
+ import ts from "typescript-eslint";
417
+ var typescript_default = [
418
+ ...ts.configs.recommendedTypeChecked,
419
+ {
420
+ name: "lichthagel/typescript",
421
+ rules: {
422
+ "@typescript-eslint/array-type": "error",
423
+ "@typescript-eslint/consistent-indexed-object-style": ["warn", "index-signature"],
424
+ "@typescript-eslint/consistent-type-assertions": ["warn", { assertionStyle: "as", objectLiteralTypeAssertions: "allow" }],
425
+ "@typescript-eslint/consistent-type-definitions": ["warn", "type"],
426
+ "@typescript-eslint/default-param-last": "warn",
427
+ "@typescript-eslint/explicit-member-accessibility": "error",
428
+ "@typescript-eslint/method-signature-style": "warn",
429
+ "@typescript-eslint/no-array-constructor": "error",
430
+ "default-param-last": "off"
431
+ }
432
+ }
433
+ ];
434
+
435
+ // src/configs/unicorn.ts
436
+ import unicornPlugin from "eslint-plugin-unicorn";
437
+ var unicorn_default = [
438
+ {
439
+ name: "unicorn/flat/recommended",
440
+ ...unicornPlugin.configs["flat/recommended"]
441
+ },
442
+ {
443
+ name: "lichthagel/unicorn",
444
+ rules: {
445
+ "unicorn/consistent-destructuring": "error",
446
+ "unicorn/filename-case": [
447
+ "error",
448
+ {
449
+ cases: {
450
+ camelCase: true,
451
+ kebabCase: true,
452
+ pascalCase: true
453
+ }
454
+ }
455
+ ],
456
+ "unicorn/import-style": "off",
457
+ "unicorn/no-null": "off",
458
+ "unicorn/no-useless-undefined": ["error", { checkArguments: false }],
459
+ "unicorn/prevent-abbreviations": "off"
460
+ }
461
+ }
462
+ ];
463
+
464
+ // src/factory.ts
465
+ var lichthagel = async (options = {}) => {
466
+ const {
467
+ browser = false,
468
+ node: node2 = false,
469
+ solid: solid2 = false,
470
+ stylistic: stylistic2 = true,
471
+ svelte: svelte2 = false,
472
+ tailwindcss: tailwindcss2 = false,
473
+ typescript = true,
474
+ ...rest
475
+ } = options;
476
+ if (Object.keys(rest).length > 0) {
477
+ throw new Error(`Unknown options: ${Object.keys(rest).join(", ")}`);
478
+ }
479
+ const config = [...javascript_default, ...unicorn_default, ...perfectionist_default];
480
+ if (stylistic2) {
481
+ config.push(...stylistic_default);
482
+ }
483
+ if (browser) {
484
+ config.push(...browser_default);
485
+ }
486
+ if (node2) {
487
+ config.push(...await node_default());
488
+ }
489
+ if (typescript) {
490
+ config.push(...typescript_default);
491
+ }
492
+ if (solid2) {
493
+ config.push(...await solid_default({ withTypescript: typescript }));
494
+ }
495
+ if (svelte2) {
496
+ config.push(...await svelte_default({ disableStylistic: stylistic2, withTypescript: typescript }));
497
+ }
498
+ if (tailwindcss2) {
499
+ config.push(...await tailwindcss_default());
500
+ }
501
+ return config;
502
+ };
503
+ var factory_default = lichthagel;
504
+ export {
505
+ browser_default as browser,
506
+ factory_default as default,
507
+ javascript_default as javascript,
508
+ node_default as node,
509
+ perfectionist_default as perfectionist,
510
+ solid_default as solid,
511
+ stylistic_default as stylistic,
512
+ svelte_default as svelte,
513
+ tailwindcss_default as tailwindcss,
514
+ typescript_default as typescript,
515
+ unicorn_default as unicorn
516
+ };
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "@lichthagel/eslint-config",
3
+ "version": "1.0.0",
4
+ "description": "Licht's ESLint config",
5
+ "keywords": [
6
+ "eslint",
7
+ "eslintconfig",
8
+ "styleguide"
9
+ ],
10
+ "author": "Lichthagel <hey@lichthagel.de>",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/Lichthagel/eslint-config.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/Lichthagel/eslint-config/issues"
17
+ },
18
+ "homepage": "https://github.com/Lichthagel/eslint-config",
19
+ "license": "MIT",
20
+ "type": "module",
21
+ "engines": {
22
+ "node": ">=16.0.0"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "LICENSE",
27
+ "README.md"
28
+ ],
29
+ "exports": {
30
+ ".": {
31
+ "import": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/index.d.cts",
37
+ "default": "./dist/index.cjs"
38
+ }
39
+ }
40
+ },
41
+ "main": "dist/index.js",
42
+ "types": "dist/index.d.ts",
43
+ "dependencies": {
44
+ "@eslint/js": "^9.11.1",
45
+ "@stylistic/eslint-plugin": "^2.9.0",
46
+ "eslint-plugin-perfectionist": "^3.9.0",
47
+ "eslint-plugin-unicorn": "^56.0.0",
48
+ "globals": "^15.9.0",
49
+ "typescript-eslint": "^8.7.0"
50
+ },
51
+ "devDependencies": {
52
+ "@types/eslint": "^9.6.1",
53
+ "@types/eslint-plugin-tailwindcss": "^3.17.0",
54
+ "@types/eslint__js": "^8.42.3",
55
+ "@types/node": "^22.7.4",
56
+ "eslint": "^9.11.1",
57
+ "eslint-plugin-n": "^17.10.3",
58
+ "eslint-plugin-solid": "^0.14.3",
59
+ "eslint-plugin-svelte": "^2.44.1",
60
+ "eslint-plugin-tailwindcss": "^3.17.4",
61
+ "eslint-typegen": "^0.3.2",
62
+ "tsup": "^8.3.0",
63
+ "tsx": "^4.19.1",
64
+ "typescript": "^5.6.2",
65
+ "vitest": "^2.1.2"
66
+ },
67
+ "peerDependencies": {
68
+ "eslint": ">=8.40.0",
69
+ "eslint-plugin-n": "^17.2.1",
70
+ "eslint-plugin-solid": "^0.14.3",
71
+ "eslint-plugin-svelte": "^2.39.0",
72
+ "eslint-plugin-tailwindcss": "^3.17.4"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "eslint-plugin-n": {
76
+ "optional": true
77
+ },
78
+ "eslint-plugin-solid": {
79
+ "optional": true
80
+ },
81
+ "eslint-plugin-svelte": {
82
+ "optional": true
83
+ },
84
+ "eslint-plugin-tailwindcss": {
85
+ "optional": true
86
+ }
87
+ },
88
+ "scripts": {
89
+ "build": "pnpm run typegen && tsup --format esm,cjs --clean --dts",
90
+ "typegen": "tsx scripts/typegen.ts",
91
+ "watch": "tsup --format esm,cjs --watch",
92
+ "test": "vitest",
93
+ "lint": "eslint .",
94
+ "inspect": "pnpx @eslint/config-inspector"
95
+ }
96
+ }