@gesslar/uglier 1.6.1 → 2.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/README.md CHANGED
@@ -47,7 +47,10 @@ npx @gesslar/uglier add react
47
47
 
48
48
  This automatically installs `@gesslar/uglier`, `eslint`, and all dependencies.
49
49
 
50
- **Package Manager Support:** Automatically detects and uses your preferred package manager (npm, pnpm, yarn, or Bun). Use `pnpx`, `yarn dlx`, or `bunx` instead of `npx` - the installer will detect your choice and install packages accordingly.
50
+ **Package Manager Support:** Automatically detects and uses your preferred
51
+ package manager (npm, pnpm, yarn, or Bun). Use `pnpx`, `yarn dlx`, or `bunx`
52
+ instead of `npx` - the installer will detect your choice and install packages
53
+ accordingly.
51
54
 
52
55
  ## Usage
53
56
 
@@ -61,9 +64,9 @@ import uglify from "@gesslar/uglier"
61
64
  export default [
62
65
  ...uglify({
63
66
  with: [
64
- "lints-js", // default files: ["**/*.{js,mjs,cjs}"]
65
- "lints-jsdoc", // default files: ["**/*.{js,mjs,cjs}"]
66
- "node", // default files: ["**/*.{js,mjs,cjs}"]
67
+ "lints-js", // default files: ["src/**/*.{js,mjs,cjs}"]
68
+ "lints-jsdoc", // default files: ["src/**/*.{js,mjs,cjs}"]
69
+ "node", // default files: ["src/**/*.{js,mjs,cjs}"]
67
70
  ]
68
71
  })
69
72
  ]
@@ -97,7 +100,7 @@ export default [
97
100
  export default [
98
101
  ...uglify({
99
102
  with: ["lints-js", "node", "web"],
100
- overrides: {
103
+ options: {
101
104
  "node": { files: ["server/**/*.js"] },
102
105
  "web": { files: ["client/**/*.js"] }
103
106
  }
@@ -111,7 +114,7 @@ export default [
111
114
  export default [
112
115
  ...uglify({
113
116
  with: ["lints-js"],
114
- overrides: {
117
+ options: {
115
118
  "lints-js": {
116
119
  indent: 4, // default: 2
117
120
  maxLen: 120, // default: 80
@@ -156,7 +159,8 @@ export default [
156
159
  - **`cjs-override`** - CommonJS file handling (`.cjs`)
157
160
  - **`mjs-override`** - ES Module file handling (`.mjs`)
158
161
 
159
- Run `npx @gesslar/uglier --help` to see all available configs with descriptions.
162
+ Run `npx @gesslar/uglier --help` to see all available configs with
163
+ descriptions.
160
164
 
161
165
  ## Commands
162
166
 
@@ -177,7 +181,7 @@ npx @gesslar/uglier add tauri vscode-extension # Multiple targets
177
181
  # Remove config blocks from existing eslint.config.js
178
182
  npx @gesslar/uglier remove react
179
183
  npx @gesslar/uglier remove web tauri # Multiple targets
180
- # Note: Also removes any overrides for removed targets
184
+ # Note: Also removes any options for removed targets
181
185
 
182
186
  # Show available configs
183
187
  npx @gesslar/uglier --help
@@ -206,7 +210,8 @@ yarn add -D @gesslar/uglier eslint
206
210
  bun add -d @gesslar/uglier eslint
207
211
  ```
208
212
 
209
- Note: `@stylistic/eslint-plugin`, `eslint-plugin-jsdoc`, and `globals` are bundled as dependencies.
213
+ Note: `@stylistic/eslint-plugin`, `eslint-plugin-jsdoc`, and `globals` are
214
+ bundled as dependencies.
210
215
 
211
216
  ## Development
212
217
 
@@ -227,11 +232,25 @@ This config enforces:
227
232
 
228
233
  - **Readable spacing** - Blank lines between control structures
229
234
  - **Consistent style** - Double quotes, no semicolons, 2-space indent
230
- - **Flexible customization** - Override anything via the `overrides` option
231
- - **Composability** - Mix configs for different file patterns in the same project
235
+ - **Flexible customization** - Override anything via the `options` key
236
+ - **Composability** - Mix configs for different file patterns in the same
237
+ project
232
238
 
233
- It's opinionated, but you can override any rule. The defaults just happen to be correct. 😉
239
+ It's opinionated, but you can override any rule. The defaults just happen to be
240
+ correct. 😉
234
241
 
235
242
  ## License
236
243
 
237
244
  [Unlicense](https://unlicense.org/) - Public domain. Do whatever you want.
245
+
246
+ ## Post Chips Ahoy
247
+
248
+ If you love code and want to support it, you should write code or hug a coder,
249
+ but maybe not physically, just emotionally, because they're busy, or instead of
250
+ telling the coder to go out and touch grass, maybe go out and touch the grass
251
+ for them and then come back and not tell them about it because first, charity
252
+ for charity's sake is its own reward and how dare you to try to cash in on your
253
+ good deeds when the entire point of doing the good deed is ... ok so, if you're
254
+ _not_ a coder, this is called recursion; but the better reason is, as stated,
255
+ they're busy. So, thanks. At the very least you can put it in Workday and claim
256
+ it, you good-deed profiteer.
package/bin/cli.js CHANGED
@@ -14,12 +14,6 @@ const PROJECT_ROOT = DirectoryObject.fromCwd()
14
14
  const SRC_DIR = PROJECT_ROOT.getDirectory("src")
15
15
  const PACKAGE_NAME = "@gesslar/uglier"
16
16
 
17
- // Only peer dependencies need to be installed separately
18
- // (all other dependencies come bundled with the package)
19
- const PEER_DEPS = [
20
- "eslint"
21
- ]
22
-
23
17
  /**
24
18
  * Parse targets from config file's with array
25
19
  *
@@ -123,15 +117,13 @@ export async function getAvailableConfigs() {
123
117
 
124
118
  let uglierFile = null
125
119
 
126
- if(await localSource.exists) {
120
+ if(await localSource.exists)
127
121
  uglierFile = localSource
128
- } else if(await installedSource.exists) {
122
+ else if(await installedSource.exists)
129
123
  uglierFile = installedSource
130
- }
131
124
 
132
- if(!uglierFile) {
125
+ if(!uglierFile)
133
126
  return null
134
- }
135
127
 
136
128
  const source = await uglierFile.read()
137
129
 
@@ -155,35 +147,6 @@ export async function getAvailableConfigs() {
155
147
  }
156
148
  }
157
149
 
158
- /**
159
- * Check if a package is already installed
160
- *
161
- * @param {string} packageName - Name of package to check
162
- * @returns {Promise<boolean>} True if installed
163
- */
164
- export async function isInstalled(packageName) {
165
- try {
166
- const cwd = DirectoryObject.fromCwd()
167
- const packageJsonFile = cwd.getFile("package.json")
168
-
169
- if(!(await packageJsonFile.exists)) {
170
- console.warn(c`No {<B}package.json{B>} found. Please initialize your project first.`)
171
- process.exit(1)
172
- }
173
-
174
- const packageJson = await packageJsonFile.loadData("json")
175
- const allDeps = {
176
- ...packageJson.dependencies,
177
- ...packageJson.devDependencies,
178
- ...packageJson.peerDependencies
179
- }
180
-
181
- return packageName in allDeps
182
- } catch {
183
- return false
184
- }
185
- }
186
-
187
150
  /**
188
151
  * Main installation routine
189
152
  */
@@ -191,39 +154,17 @@ export async function install() {
191
154
  console.log(c`Installing {<B}${PACKAGE_NAME}{B>}...`)
192
155
  console.log()
193
156
 
194
- const toInstall = []
195
-
196
- // Check if main package is already installed
197
- if(!(await isInstalled(PACKAGE_NAME))) {
198
- toInstall.push(PACKAGE_NAME)
199
- } else {
200
- console.log(c`{F070}✓{/} {<B}${PACKAGE_NAME}{B>} already installed`)
201
- }
202
-
203
- // Check peer dependencies
204
- for(const dep of PEER_DEPS) {
205
- if(!(await isInstalled(dep))) {
206
- toInstall.push(dep)
207
- } else {
208
- console.log(c`{F070}✓{/} {<B}${dep}{B>} already installed`)
209
- }
210
- }
211
-
212
- // Install missing packages
213
- if(toInstall.length > 0) {
214
- console.log(c`\n{F027} Installing:{/} ${toInstall.map(p => c`{F172}${p}{/}`).join(", ")}`)
157
+ const {manager, installCmd} = await getPackageManagerInfo()
158
+ const packages = [PACKAGE_NAME, "eslint"]
159
+ const fullCmd = `${installCmd} ${packages.join(" ")}`
215
160
 
216
- const {manager, installCmd} = await getPackageManagerInfo()
217
- const fullCmd = `${installCmd} ${toInstall.join(" ")}`
161
+ console.log(c`{F244}Using package manager: ${manager}{/}`)
162
+ console.log(c`{F244}Running: ${fullCmd}{/}`)
218
163
 
219
- console.log(c`{F244}Using package manager: ${manager}{/}`)
220
- console.log(c`{F244}Running: ${fullCmd}{/}`)
221
- exec(fullCmd)
222
-
223
- console.log()
224
- console.log(c`{F070}✓{/} Installation successful.`)
225
- }
164
+ exec(fullCmd)
226
165
 
166
+ console.log()
167
+ console.log(c`{F070}✓{/} Installation successful.`)
227
168
  console.log()
228
169
  console.log(c`{F039}For detailed setup and configuration options, visit:{/}`)
229
170
  console.log(c`https://github.com/gesslar/uglier#readme`)
@@ -453,7 +394,7 @@ export async function addToConfig(targets = []) {
453
394
  * Remove config blocks from existing eslint.config.js
454
395
  *
455
396
  * @param {Array<string>} targets - Target environments to remove (node, web, react, etc.)
456
- * @returns {Promise<{success: boolean, removedTargets: Array<string>, removedOverrides: Array<string>}>} Result info
397
+ * @returns {Promise<{success: boolean, removedTargets: Array<string>, removedOptions: Array<string>}>} Result info
457
398
  */
458
399
  export async function removeFromConfig(targets = []) {
459
400
  const cwd = DirectoryObject.fromCwd()
@@ -463,7 +404,7 @@ export async function removeFromConfig(targets = []) {
463
404
  console.log(c`{F214}Error:{/} {<B}eslint.config.js{B>} not found`)
464
405
  console.log(c`Use {<B}npx @gesslar/uglier init <targets>{B>} to create one first`)
465
406
 
466
- return {success: false, removedTargets: [], removedOverrides: []}
407
+ return {success: false, removedTargets: [], removedOptions: []}
467
408
  }
468
409
 
469
410
  // Get available configs dynamically
@@ -481,7 +422,7 @@ export async function removeFromConfig(targets = []) {
481
422
  console.log()
482
423
  console.log(c`{F244}Example: npx @gesslar/uglier remove react{/}`)
483
424
 
484
- return {success: false, removedTargets: [], removedOverrides: []}
425
+ return {success: false, removedTargets: [], removedOptions: []}
485
426
  }
486
427
 
487
428
  // Read existing config
@@ -494,7 +435,7 @@ export async function removeFromConfig(targets = []) {
494
435
  console.log(c`{F214}Error:{/} Could not parse existing config`)
495
436
  console.log(c`The config file may have a non-standard format`)
496
437
 
497
- return {success: false, removedTargets: [], removedOverrides: []}
438
+ return {success: false, removedTargets: [], removedOptions: []}
498
439
  }
499
440
 
500
441
  // Find which targets exist and can be removed
@@ -510,7 +451,7 @@ export async function removeFromConfig(targets = []) {
510
451
  console.log()
511
452
  console.log(c`Current targets: ${existingTargets.map(t => c`{F070}${t}{/}`).join(", ")}`)
512
453
 
513
- return {success: false, removedTargets: [], removedOverrides: []}
454
+ return {success: false, removedTargets: [], removedOptions: []}
514
455
  }
515
456
 
516
457
  // Build new with array content without the removed targets
@@ -547,11 +488,11 @@ export async function removeFromConfig(targets = []) {
547
488
  `with: [\n${newLines.join("\n")}\n ]`
548
489
  )
549
490
 
550
- // Check for and remove overrides for removed targets
551
- const removedOverrides = []
552
- const overridesMatch = newContent.match(/overrides:\s*\{/m)
491
+ // Check for and remove options for removed targets
492
+ const removedOptions = []
493
+ const optionsMatch = newContent.match(/options:\s*\{/m)
553
494
 
554
- if(overridesMatch) {
495
+ if(optionsMatch) {
555
496
  for(const target of targetsToRemove) {
556
497
  // Find the start of this target's override entry
557
498
  const targetPattern = new RegExp(`[\\s,]*(?:\\/\\/[^\\n]*\\n\\s*)?["']${target}["']:\\s*\\{`)
@@ -583,7 +524,7 @@ export async function removeFromConfig(targets = []) {
583
524
  }
584
525
 
585
526
  if(blockEnd !== -1) {
586
- removedOverrides.push(target)
527
+ removedOptions.push(target)
587
528
  newContent = newContent.slice(0, blockStart)
588
529
  + newContent.slice(blockEnd)
589
530
  }
@@ -595,9 +536,9 @@ export async function removeFromConfig(targets = []) {
595
536
  /\}(\s*["'][\w-]+["']:\s*\{)/g, "},$1"
596
537
  )
597
538
 
598
- // Clean up empty overrides object or trailing commas
539
+ // Clean up empty options object or trailing commas
599
540
  newContent = newContent.replace(
600
- /overrides:\s*\{\s*,?\s*\}/m, ""
541
+ /options:\s*\{\s*,?\s*\}/m, ""
601
542
  )
602
543
  newContent = newContent.replace(/,(\s*)\}/g, "$1}")
603
544
  }
@@ -612,11 +553,11 @@ export async function removeFromConfig(targets = []) {
612
553
  console.log(c` {F070}•{/} ${target}`)
613
554
  }
614
555
 
615
- if(removedOverrides.length > 0) {
556
+ if(removedOptions.length > 0) {
616
557
  console.log()
617
- console.log(c`{F039}Also removed overrides for:{/}`)
558
+ console.log(c`{F039}Also removed options for:{/}`)
618
559
 
619
- for(const target of removedOverrides) {
560
+ for(const target of removedOptions) {
620
561
  console.log(c` {F070}•{/} ${target}`)
621
562
  }
622
563
  }
@@ -626,7 +567,7 @@ export async function removeFromConfig(targets = []) {
626
567
  console.log()
627
568
  console.log(c`{F244}Run {<B}${eslintCmd}{B>} to lint your project{/}`)
628
569
 
629
- return {success: true, removedTargets: targetsToRemove, removedOverrides}
570
+ return {success: true, removedTargets: targetsToRemove, removedOptions}
630
571
  }
631
572
 
632
573
  /**
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "gesslar",
6
6
  "url": "https://gesslar.dev"
7
7
  },
8
- "version": "1.6.1",
8
+ "version": "2.0.0",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git+https://github.com/gesslar/uglier.git"
@@ -44,27 +44,19 @@
44
44
  "major": "npm version major"
45
45
  },
46
46
  "license": "Unlicense",
47
- "peerDependencies": {
48
- "eslint": ">=10.0.0"
49
- },
50
- "peerDependenciesMeta": {
51
- "eslint": {
52
- "optional": true
53
- }
54
- },
55
47
  "engines": {
56
48
  "node": ">=24.13.0"
57
49
  },
58
50
  "dependencies": {
59
51
  "@gesslar/colours": ">=0.8.0",
60
- "@gesslar/toolkit": ">=3.37.0",
52
+ "@gesslar/toolkit": ">=3.42.0",
61
53
  "@skarab/detect-package-manager": ">=1.0.0",
62
54
  "@stylistic/eslint-plugin": "^5.9.0",
63
- "eslint-plugin-jsdoc": ">=62.6.1",
55
+ "eslint-plugin-jsdoc": ">=62.7.1",
64
56
  "globals": ">=17.3.0"
65
57
  },
66
58
  "devDependencies": {
67
- "@gesslar/uglier": ">=1.4.1",
68
- "eslint": ">=10.0.0"
59
+ "@gesslar/uglier": ">=1.6.2",
60
+ "eslint": ">=10.0.2"
69
61
  }
70
62
  }
package/src/uglier.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * export default [
24
24
  * ...uglify({
25
25
  * with: ["lints-js", "lints-jsdoc", "tauri"],
26
- * overrides: {
26
+ * options: {
27
27
  * "lints-js": { files: ["src/**\/*.js"] },
28
28
  * "tauri": { files: ["src/**\/*.js"] }
29
29
  * }
@@ -48,7 +48,7 @@
48
48
  * export default [
49
49
  * ...uglify({
50
50
  * with: ["lints-js"],
51
- * overrides: {
51
+ * options: {
52
52
  * "lints-js": {
53
53
  * indent: 4,
54
54
  * maxLen: 120,
@@ -93,7 +93,8 @@ const CONFIGS = {
93
93
  */
94
94
  "lints-js": (options = {}) => {
95
95
  const {
96
- files = ["**/*.{js,mjs,cjs}"],
96
+ files = ["src/**/*.{js,mjs,cjs}"],
97
+ ignores = [],
97
98
  indent = 2,
98
99
  maxLen = 80,
99
100
  overrides = {},
@@ -102,6 +103,7 @@ const CONFIGS = {
102
103
  return {
103
104
  name: "gesslar/uglier/lints-js",
104
105
  files: Array.isArray(files) ? files : [files],
106
+ ignores: Array.isArray(ignores) ? ignores : [ignores],
105
107
  plugins: {
106
108
  "@stylistic": stylistic,
107
109
  },
@@ -206,13 +208,15 @@ const CONFIGS = {
206
208
  */
207
209
  "lints-jsdoc": (options = {}) => {
208
210
  const {
209
- files = ["**/*.{js,mjs,cjs}"],
211
+ files = ["src/**/*.{js,mjs,cjs}"],
212
+ ignores = [],
210
213
  overrides = {},
211
214
  } = options
212
215
 
213
216
  return {
214
217
  name: "gesslar/uglier/lints-jsdoc",
215
218
  files: Array.isArray(files) ? files : [files],
219
+ ignores: Array.isArray(ignores) ? ignores : [ignores],
216
220
  plugins: {
217
221
  jsdoc,
218
222
  },
@@ -269,12 +273,14 @@ const CONFIGS = {
269
273
  "web": (options = {}) => {
270
274
  const {
271
275
  files = ["src/**/*.{js,mjs,cjs}"],
276
+ ignores = [],
272
277
  additionalGlobals = {},
273
278
  } = options
274
279
 
275
280
  return {
276
281
  name: "gesslar/uglier/web",
277
282
  files: Array.isArray(files) ? files : [files],
283
+ ignores: Array.isArray(ignores) ? ignores : [ignores],
278
284
  languageOptions: {
279
285
  globals: {
280
286
  ...globals.browser,
@@ -293,12 +299,14 @@ const CONFIGS = {
293
299
  "vscode-extension": (options = {}) => {
294
300
  const {
295
301
  files = ["src/**/*.{js,mjs,cjs}"],
302
+ ignores = [],
296
303
  additionalGlobals = {},
297
304
  } = options
298
305
 
299
306
  return {
300
307
  name: "gesslar/uglier/vscode-extension",
301
308
  files: Array.isArray(files) ? files : [files],
309
+ ignores: Array.isArray(ignores) ? ignores : [ignores],
302
310
  languageOptions: {
303
311
  globals: {
304
312
  acquireVsCodeApi: "readonly",
@@ -316,13 +324,15 @@ const CONFIGS = {
316
324
  */
317
325
  "node": (options = {}) => {
318
326
  const {
319
- files = ["**/*.{js,mjs,cjs}"],
327
+ files = ["src/**/*.{js,mjs,cjs}"],
328
+ ignores = [],
320
329
  additionalGlobals = {},
321
330
  } = options
322
331
 
323
332
  return {
324
333
  name: "gesslar/uglier/node",
325
334
  files: Array.isArray(files) ? files : [files],
335
+ ignores: Array.isArray(ignores) ? ignores : [ignores],
326
336
  languageOptions: {
327
337
  globals: {
328
338
  ...globals.node,
@@ -343,12 +353,14 @@ const CONFIGS = {
343
353
  "react": (options = {}) => {
344
354
  const {
345
355
  files = ["src/**/*.{js,jsx,mjs,cjs}"],
356
+ ignores = [],
346
357
  additionalGlobals = {},
347
358
  } = options
348
359
 
349
360
  return {
350
361
  name: "gesslar/uglier/react",
351
362
  files: Array.isArray(files) ? files : [files],
363
+ ignores: Array.isArray(ignores) ? ignores : [ignores],
352
364
  languageOptions: {
353
365
  globals: {
354
366
  ...globals.browser,
@@ -369,11 +381,13 @@ const CONFIGS = {
369
381
  "cjs-override": (options = {}) => {
370
382
  const {
371
383
  files = ["**/*.cjs"],
384
+ ignores = [],
372
385
  } = options
373
386
 
374
387
  return {
375
388
  name: "gesslar/uglier/cjs-override",
376
389
  files: Array.isArray(files) ? files : [files],
390
+ ignores: Array.isArray(ignores) ? ignores : [ignores],
377
391
  languageOptions: {
378
392
  sourceType: "script",
379
393
  ecmaVersion: 2021
@@ -390,11 +404,13 @@ const CONFIGS = {
390
404
  "mjs-override": (options = {}) => {
391
405
  const {
392
406
  files = ["**/*.mjs"],
407
+ ignores = [],
393
408
  } = options
394
409
 
395
410
  return {
396
411
  name: "gesslar/uglier/mjs-override",
397
412
  files: Array.isArray(files) ? files : [files],
413
+ ignores: Array.isArray(ignores) ? ignores : [ignores],
398
414
  languageOptions: {
399
415
  sourceType: "module",
400
416
  ecmaVersion: 2021
@@ -411,12 +427,14 @@ const CONFIGS = {
411
427
  "tauri": (options = {}) => {
412
428
  const {
413
429
  files = ["src/**/*.{js,mjs,cjs}"],
430
+ ignores = [],
414
431
  additionalGlobals = {},
415
432
  } = options
416
433
 
417
434
  return {
418
435
  name: "gesslar/uglier/tauri",
419
436
  files: Array.isArray(files) ? files : [files],
437
+ ignores: Array.isArray(ignores) ? ignores : [ignores],
420
438
  languageOptions: {
421
439
  globals: {
422
440
  ...globals.browser,
@@ -435,14 +453,14 @@ const CONFIGS = {
435
453
  * @param {object} options - Composition options
436
454
  * @param {string[]} [options.with] - Config names to include
437
455
  * @param {string[]} [options.without] - Config names to exclude (higher precedence)
438
- * @param {object} [options.overrides] - Per-config options overrides
456
+ * @param {object} [options.options] - Per-config options
439
457
  * @returns {Array} ESLint flat config array
440
458
  */
441
459
  export default function(options = {}) {
442
460
  const {
443
461
  with: includeConfigs = ["lints-js", "lints-jsdoc"],
444
462
  without: excludeConfigs = [],
445
- overrides = {},
463
+ options: perConfigOptions = {},
446
464
  } = options
447
465
 
448
466
  const configs = []
@@ -458,7 +476,7 @@ export default function(options = {}) {
458
476
  )
459
477
  }
460
478
 
461
- const configOptions = overrides[configName] || {}
479
+ const configOptions = perConfigOptions[configName] || {}
462
480
  const config = CONFIGS[configName](configOptions)
463
481
 
464
482
  configs.push(config)