@gesslar/uglier 2.0.1 → 2.2.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/cli.js CHANGED
@@ -167,7 +167,7 @@ export async function install() {
167
167
  console.log(c`{F070}✓{/} Installation successful.`)
168
168
  console.log()
169
169
  console.log(c`{F039}For detailed setup and configuration options, visit:{/}`)
170
- console.log(c`https://github.com/gesslar/uglier#readme`)
170
+ console.log(c`https://uglier.gesslar.io`)
171
171
  }
172
172
 
173
173
  /**
@@ -585,6 +585,8 @@ export async function showHelp() {
585
585
  console.log(c` {<B}npx @gesslar/uglier remove <targets>{B>} Remove config blocks from existing eslint.config.js`)
586
586
  console.log(c` {<B}npx @gesslar/uglier --help{B>} Show this help`)
587
587
  console.log()
588
+ console.log(c`Learn how to bastardise the already beautiful defaults to your heart's desire at https://uglier.gesslar.io`)
589
+ console.log()
588
590
 
589
591
  const configs = await getAvailableConfigs()
590
592
 
@@ -600,5 +602,5 @@ export async function showHelp() {
600
602
  }
601
603
 
602
604
  console.log()
603
- console.log(`Documentation at https://github.com/gesslar/uglier.`)
605
+ console.log(`Documentation at https://uglier.io/.`)
604
606
  }
package/package.json CHANGED
@@ -5,13 +5,18 @@
5
5
  "name": "gesslar",
6
6
  "url": "https://gesslar.dev"
7
7
  },
8
- "version": "2.0.1",
8
+ "version": "2.2.0",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git+https://github.com/gesslar/uglier.git"
12
12
  },
13
13
  "type": "module",
14
- "exports": "./src/uglier.js",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./src/types/uglier.d.ts",
17
+ "default": "./src/uglier.js"
18
+ }
19
+ },
15
20
  "bin": {
16
21
  "uglier": "./src/install.js"
17
22
  },
@@ -34,6 +39,7 @@
34
39
  ],
35
40
  "scripts": {
36
41
  "test": "node --test tests/unit/*.test.js",
42
+ "types": "node -e \"require('fs').rmSync('types',{recursive:true,force:true});\" && tsc -p tsconfig.types.json",
37
43
  "lint": "eslint",
38
44
  "lint:fix": "eslint --fix",
39
45
  "update": "npx npm-check-updates -u && npm install",
@@ -41,7 +47,10 @@
41
47
  "pr": "gt submit -p --ai",
42
48
  "patch": "npm version patch",
43
49
  "minor": "npm version minor",
44
- "major": "npm version major"
50
+ "major": "npm version major",
51
+ "docs:dev": "cd docs && npm run start",
52
+ "docs:build": "cd docs && npm run build",
53
+ "docs:deploy": "gh workflow run deploy-docs.yml"
45
54
  },
46
55
  "license": "Unlicense",
47
56
  "engines": {
@@ -52,11 +61,12 @@
52
61
  "@gesslar/toolkit": ">=4.1.0",
53
62
  "@skarab/detect-package-manager": ">=1.0.0",
54
63
  "@stylistic/eslint-plugin": "^5.10.0",
55
- "eslint-plugin-jsdoc": ">=62.7.1",
64
+ "eslint-plugin-jsdoc": ">=62.8.0",
56
65
  "globals": ">=17.4.0"
57
66
  },
58
67
  "devDependencies": {
59
- "@gesslar/uglier": ">=2.0.0",
60
- "eslint": ">=10.0.3"
68
+ "@gesslar/uglier": ">=2.1.0",
69
+ "eslint": ">=10.0.3",
70
+ "typescript": "^5.9.3"
61
71
  }
62
72
  }
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Compose ESLint configuration from named config blocks
3
+ *
4
+ * @param {UglierOptions} [options] - Composition options
5
+ * @returns {Array<FlatConfig>} ESLint flat config array
6
+ */
7
+ export default function _default(options?: UglierOptions): Array<FlatConfig>;
8
+ /**
9
+ * All available config block names
10
+ *
11
+ * @type {Array<ConfigName>}
12
+ */
13
+ export const availableConfigs: Array<ConfigName>;
14
+ /**
15
+ * Available config block names
16
+ */
17
+ export type ConfigName = "lints-js" | "lints-jsdoc" | "languageOptions" | "web" | "node" | "react" | "tauri" | "vscode-extension" | "cjs-override" | "mjs-override";
18
+ /**
19
+ * ESLint rule severity or configuration
20
+ */
21
+ export type RuleEntry = ("off" | "warn" | "error" | 0 | 1 | 2 | [("off" | "warn" | "error" | 0 | 1 | 2), ...Array<string | number | boolean | object>]);
22
+ /**
23
+ * ESLint rule overrides map
24
+ */
25
+ export type RuleOverrides = {
26
+ [ruleName: string]: RuleEntry;
27
+ };
28
+ /**
29
+ * Options for the lints-js config block
30
+ */
31
+ export type LintsJsOptions = {
32
+ /**
33
+ * - Glob patterns for files to lint
34
+ */
35
+ files?: string | Array<string>;
36
+ /**
37
+ * - Glob patterns for files to ignore
38
+ */
39
+ ignores?: string | Array<string>;
40
+ /**
41
+ * - Indentation width (default: 2)
42
+ */
43
+ indent?: number;
44
+ /**
45
+ * - Maximum line length (default: 80)
46
+ */
47
+ maxLen?: number;
48
+ /**
49
+ * - ESLint rule overrides
50
+ */
51
+ overrides?: RuleOverrides;
52
+ };
53
+ /**
54
+ * Options for the lints-jsdoc config block
55
+ */
56
+ export type LintsJsdocOptions = {
57
+ /**
58
+ * - Glob patterns for files to lint
59
+ */
60
+ files?: string | Array<string>;
61
+ /**
62
+ * - Glob patterns for files to ignore
63
+ */
64
+ ignores?: string | Array<string>;
65
+ /**
66
+ * - ESLint rule overrides
67
+ */
68
+ overrides?: RuleOverrides;
69
+ };
70
+ /**
71
+ * Options for the languageOptions config block
72
+ */
73
+ export type LanguageOptionsOptions = {
74
+ /**
75
+ * - ECMAScript version (default: "latest")
76
+ */
77
+ ecmaVersion?: string | number;
78
+ /**
79
+ * - Source type (default: "module")
80
+ */
81
+ sourceType?: "module" | "script" | "commonjs";
82
+ /**
83
+ * - Extra global variables
84
+ */
85
+ additionalGlobals?: {
86
+ [name: string]: "readonly" | "writable" | "off";
87
+ };
88
+ };
89
+ /**
90
+ * Options for environment config blocks (web, node, react, tauri, vscode-extension)
91
+ */
92
+ export type EnvironmentOptions = {
93
+ /**
94
+ * - Glob patterns for files to lint
95
+ */
96
+ files?: string | Array<string>;
97
+ /**
98
+ * - Glob patterns for files to ignore
99
+ */
100
+ ignores?: string | Array<string>;
101
+ /**
102
+ * - Extra global variables
103
+ */
104
+ additionalGlobals?: {
105
+ [name: string]: "readonly" | "writable" | "off";
106
+ };
107
+ };
108
+ /**
109
+ * Options for module override config blocks (cjs-override, mjs-override)
110
+ */
111
+ export type ModuleOverrideOptions = {
112
+ /**
113
+ * - Glob patterns for files to lint
114
+ */
115
+ files?: string | Array<string>;
116
+ /**
117
+ * - Glob patterns for files to ignore
118
+ */
119
+ ignores?: string | Array<string>;
120
+ };
121
+ /**
122
+ * Per-config options map
123
+ */
124
+ export type PerConfigOptions = {
125
+ "lints-js"?: LintsJsOptions;
126
+ "lints-jsdoc"?: LintsJsdocOptions;
127
+ languageOptions?: LanguageOptionsOptions;
128
+ web?: EnvironmentOptions;
129
+ node?: EnvironmentOptions;
130
+ react?: EnvironmentOptions;
131
+ tauri?: EnvironmentOptions;
132
+ "vscode-extension"?: EnvironmentOptions;
133
+ "cjs-override"?: ModuleOverrideOptions;
134
+ "mjs-override"?: ModuleOverrideOptions;
135
+ };
136
+ /**
137
+ * Options for composing ESLint configurations
138
+ */
139
+ export type UglierOptions = {
140
+ /**
141
+ * - Config names to include (default: ["lints-js", "lints-jsdoc"])
142
+ */
143
+ with?: Array<ConfigName>;
144
+ /**
145
+ * - Config names to exclude (higher precedence than `with`)
146
+ */
147
+ without?: Array<ConfigName>;
148
+ /**
149
+ * - Per-config options
150
+ */
151
+ options?: PerConfigOptions;
152
+ };
153
+ /**
154
+ * An ESLint flat config object
155
+ */
156
+ export type FlatConfig = {
157
+ /**
158
+ * - Config name for debugging
159
+ */
160
+ name?: string;
161
+ /**
162
+ * - Glob patterns for files this config applies to
163
+ */
164
+ files?: Array<string>;
165
+ /**
166
+ * - Glob patterns for files to ignore
167
+ */
168
+ ignores?: Array<string>;
169
+ /**
170
+ * - ESLint plugins
171
+ */
172
+ plugins?: {
173
+ [pluginName: string]: object;
174
+ };
175
+ /**
176
+ * - ESLint rules
177
+ */
178
+ rules?: {
179
+ [ruleName: string]: RuleEntry;
180
+ };
181
+ /**
182
+ * - Language options
183
+ */
184
+ languageOptions?: object;
185
+ /**
186
+ * - Shared settings
187
+ */
188
+ settings?: object;
189
+ };
package/src/uglier.js CHANGED
@@ -74,22 +74,114 @@
74
74
  * - mjs-override: ES Module file handling (.mjs files)
75
75
  */
76
76
 
77
+ /**
78
+ * Available config block names
79
+ *
80
+ * @typedef {"lints-js" | "lints-jsdoc" | "languageOptions" | "web" | "node" | "react" | "tauri" | "vscode-extension" | "cjs-override" | "mjs-override"} ConfigName
81
+ */
82
+
83
+ /**
84
+ * ESLint rule severity or configuration
85
+ *
86
+ * @typedef {("off" | "warn" | "error" | 0 | 1 | 2 | [("off" | "warn" | "error" | 0 | 1 | 2), ...Array<string | number | boolean | object>])} RuleEntry
87
+ */
88
+
89
+ /**
90
+ * ESLint rule overrides map
91
+ *
92
+ * @typedef {{[ruleName: string]: RuleEntry}} RuleOverrides
93
+ */
94
+
95
+ /**
96
+ * Options for the lints-js config block
97
+ *
98
+ * @typedef {object} LintsJsOptions
99
+ * @property {string | Array<string>} [files] - Glob patterns for files to lint
100
+ * @property {string | Array<string>} [ignores] - Glob patterns for files to ignore
101
+ * @property {number} [indent] - Indentation width (default: 2)
102
+ * @property {number} [maxLen] - Maximum line length (default: 80)
103
+ * @property {RuleOverrides} [overrides] - ESLint rule overrides
104
+ */
105
+
106
+ /**
107
+ * Options for the lints-jsdoc config block
108
+ *
109
+ * @typedef {object} LintsJsdocOptions
110
+ * @property {string | Array<string>} [files] - Glob patterns for files to lint
111
+ * @property {string | Array<string>} [ignores] - Glob patterns for files to ignore
112
+ * @property {RuleOverrides} [overrides] - ESLint rule overrides
113
+ */
114
+
115
+ /**
116
+ * Options for the languageOptions config block
117
+ *
118
+ * @typedef {object} LanguageOptionsOptions
119
+ * @property {string | number} [ecmaVersion] - ECMAScript version (default: "latest")
120
+ * @property {"module" | "script" | "commonjs"} [sourceType] - Source type (default: "module")
121
+ * @property {{[name: string]: "readonly" | "writable" | "off"}} [additionalGlobals] - Extra global variables
122
+ */
123
+
124
+ /**
125
+ * Options for environment config blocks (web, node, react, tauri, vscode-extension)
126
+ *
127
+ * @typedef {object} EnvironmentOptions
128
+ * @property {string | Array<string>} [files] - Glob patterns for files to lint
129
+ * @property {string | Array<string>} [ignores] - Glob patterns for files to ignore
130
+ * @property {{[name: string]: "readonly" | "writable" | "off"}} [additionalGlobals] - Extra global variables
131
+ */
132
+
133
+ /**
134
+ * Options for module override config blocks (cjs-override, mjs-override)
135
+ *
136
+ * @typedef {object} ModuleOverrideOptions
137
+ * @property {string | Array<string>} [files] - Glob patterns for files to lint
138
+ * @property {string | Array<string>} [ignores] - Glob patterns for files to ignore
139
+ */
140
+
141
+ /**
142
+ * Per-config options map
143
+ *
144
+ * @typedef {{"lints-js"?: LintsJsOptions, "lints-jsdoc"?: LintsJsdocOptions, languageOptions?: LanguageOptionsOptions, web?: EnvironmentOptions, node?: EnvironmentOptions, react?: EnvironmentOptions, tauri?: EnvironmentOptions, "vscode-extension"?: EnvironmentOptions, "cjs-override"?: ModuleOverrideOptions, "mjs-override"?: ModuleOverrideOptions}} PerConfigOptions
145
+ */
146
+
147
+ /**
148
+ * Options for composing ESLint configurations
149
+ *
150
+ * @typedef {object} UglierOptions
151
+ * @property {Array<ConfigName>} [with] - Config names to include (default: ["lints-js", "lints-jsdoc"])
152
+ * @property {Array<ConfigName>} [without] - Config names to exclude (higher precedence than `with`)
153
+ * @property {PerConfigOptions} [options] - Per-config options
154
+ */
155
+
156
+ /**
157
+ * An ESLint flat config object
158
+ *
159
+ * @typedef {object} FlatConfig
160
+ * @property {string} [name] - Config name for debugging
161
+ * @property {Array<string>} [files] - Glob patterns for files this config applies to
162
+ * @property {Array<string>} [ignores] - Glob patterns for files to ignore
163
+ * @property {{[pluginName: string]: object}} [plugins] - ESLint plugins
164
+ * @property {{[ruleName: string]: RuleEntry}} [rules] - ESLint rules
165
+ * @property {object} [languageOptions] - Language options
166
+ * @property {object} [settings] - Shared settings
167
+ */
168
+
77
169
  import jsdoc from "eslint-plugin-jsdoc"
78
170
  import stylistic from "@stylistic/eslint-plugin"
79
171
  import globals from "globals"
80
172
 
81
173
  /**
82
- * Registry of named configuration blocks
83
- * Each config is a factory function that returns an ESLint config object
174
+ * Registry of named configuration blocks.
175
+ * Each config is a factory function that returns an ESLint flat config object.
84
176
  *
85
- * @type {{[key: string]: Function}}
177
+ * @type {{[K in ConfigName]: (options?: object) => FlatConfig}}
86
178
  */
87
179
  const CONFIGS = {
88
180
  /**
89
181
  * Core stylistic linting rules
90
182
  *
91
- * @param {object} options - Configuration options
92
- * @returns {object} Config object
183
+ * @param {LintsJsOptions} options - Configuration options
184
+ * @returns {FlatConfig} ESLint flat config object
93
185
  */
94
186
  "lints-js": (options = {}) => {
95
187
  const {
@@ -195,6 +287,7 @@ const CONFIGS = {
195
287
  "prefer-const": "error",
196
288
  "@stylistic/no-multiple-empty-lines": ["error", {max: 1}],
197
289
  "@stylistic/array-bracket-spacing": ["error", "never"],
290
+ "@stylistic/no-extra-semi": "error",
198
291
  ...overrides,
199
292
  }
200
293
  }
@@ -203,8 +296,8 @@ const CONFIGS = {
203
296
  /**
204
297
  * JSDoc linting rules
205
298
  *
206
- * @param {object} options - Configuration options
207
- * @returns {object} Config object
299
+ * @param {LintsJsdocOptions} options - Configuration options
300
+ * @returns {FlatConfig} ESLint flat config object
208
301
  */
209
302
  "lints-jsdoc": (options = {}) => {
210
303
  const {
@@ -244,8 +337,8 @@ const CONFIGS = {
244
337
  /**
245
338
  * Language options configuration
246
339
  *
247
- * @param {object} options - Configuration options
248
- * @returns {object} Config object
340
+ * @param {LanguageOptionsOptions} options - Configuration options
341
+ * @returns {FlatConfig} ESLint flat config object
249
342
  */
250
343
  "languageOptions": (options = {}) => {
251
344
  const {
@@ -267,8 +360,8 @@ const CONFIGS = {
267
360
  /**
268
361
  * Browser/web globals configuration
269
362
  *
270
- * @param {object} options - Configuration options
271
- * @returns {object} Config object
363
+ * @param {EnvironmentOptions} options - Configuration options
364
+ * @returns {FlatConfig} ESLint flat config object
272
365
  */
273
366
  "web": (options = {}) => {
274
367
  const {
@@ -293,8 +386,8 @@ const CONFIGS = {
293
386
  /**
294
387
  * VSCode extension globals
295
388
  *
296
- * @param {object} options - Configuration options
297
- * @returns {object} Config object
389
+ * @param {EnvironmentOptions} options - Configuration options
390
+ * @returns {FlatConfig} ESLint flat config object
298
391
  */
299
392
  "vscode-extension": (options = {}) => {
300
393
  const {
@@ -319,8 +412,8 @@ const CONFIGS = {
319
412
  /**
320
413
  * Node.js globals
321
414
  *
322
- * @param {object} options - Configuration options
323
- * @returns {object} Config object
415
+ * @param {EnvironmentOptions} options - Configuration options
416
+ * @returns {FlatConfig} ESLint flat config object
324
417
  */
325
418
  "node": (options = {}) => {
326
419
  const {
@@ -347,8 +440,8 @@ const CONFIGS = {
347
440
  /**
348
441
  * React application globals
349
442
  *
350
- * @param {object} options - Configuration options
351
- * @returns {object} Config object
443
+ * @param {EnvironmentOptions} options - Configuration options
444
+ * @returns {FlatConfig} ESLint flat config object
352
445
  */
353
446
  "react": (options = {}) => {
354
447
  const {
@@ -375,8 +468,8 @@ const CONFIGS = {
375
468
  /**
376
469
  * CommonJS file override
377
470
  *
378
- * @param {object} options - Configuration options
379
- * @returns {object} Config object
471
+ * @param {ModuleOverrideOptions} options - Configuration options
472
+ * @returns {FlatConfig} ESLint flat config object
380
473
  */
381
474
  "cjs-override": (options = {}) => {
382
475
  const {
@@ -398,8 +491,8 @@ const CONFIGS = {
398
491
  /**
399
492
  * ES Module file override
400
493
  *
401
- * @param {object} options - Configuration options
402
- * @returns {object} Config object
494
+ * @param {ModuleOverrideOptions} options - Configuration options
495
+ * @returns {FlatConfig} ESLint flat config object
403
496
  */
404
497
  "mjs-override": (options = {}) => {
405
498
  const {
@@ -421,8 +514,8 @@ const CONFIGS = {
421
514
  /**
422
515
  * Tauri application configuration (browser + Tauri APIs, no Node.js)
423
516
  *
424
- * @param {object} options - Configuration options
425
- * @returns {object} Config object
517
+ * @param {EnvironmentOptions} options - Configuration options
518
+ * @returns {FlatConfig} ESLint flat config object
426
519
  */
427
520
  "tauri": (options = {}) => {
428
521
  const {
@@ -450,11 +543,8 @@ const CONFIGS = {
450
543
  /**
451
544
  * Compose ESLint configuration from named config blocks
452
545
  *
453
- * @param {object} options - Composition options
454
- * @param {string[]} [options.with] - Config names to include
455
- * @param {string[]} [options.without] - Config names to exclude (higher precedence)
456
- * @param {object} [options.options] - Per-config options
457
- * @returns {Array} ESLint flat config array
546
+ * @param {UglierOptions} [options] - Composition options
547
+ * @returns {Array<FlatConfig>} ESLint flat config array
458
548
  */
459
549
  export default function(options = {}) {
460
550
  const {
@@ -486,6 +576,9 @@ export default function(options = {}) {
486
576
  }
487
577
 
488
578
  /**
489
- * Export all available config names for reference
579
+ * All available config block names
580
+ *
581
+ * @type {Array<ConfigName>}
490
582
  */
491
- export const availableConfigs = Object.keys(CONFIGS)
583
+ export const availableConfigs =
584
+ /** @type {Array<ConfigName>} */ (Object.keys(CONFIGS))