pickier 0.1.29 → 0.1.30

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/bin/cli.js CHANGED
@@ -21288,6 +21288,50 @@ var init_no_unused_vars = __esm(() => {
21288
21288
  }
21289
21289
  return null;
21290
21290
  };
21291
+ const collectArrowExpressionBody = (startLine, arrowCol) => {
21292
+ const state = {
21293
+ parenDepth: 0,
21294
+ braceDepth: 0,
21295
+ bracketDepth: 0,
21296
+ inTemplate: false
21297
+ };
21298
+ const updateState = (text2) => {
21299
+ for (let k = 0;k < text2.length; k++) {
21300
+ const ch = text2[k];
21301
+ if (ch === "`")
21302
+ state.inTemplate = !state.inTemplate;
21303
+ else if (ch === "(")
21304
+ state.parenDepth++;
21305
+ else if (ch === ")")
21306
+ state.parenDepth--;
21307
+ else if (ch === "{")
21308
+ state.braceDepth++;
21309
+ else if (ch === "}")
21310
+ state.braceDepth--;
21311
+ else if (ch === "[")
21312
+ state.bracketDepth++;
21313
+ else if (ch === "]")
21314
+ state.bracketDepth--;
21315
+ }
21316
+ };
21317
+ const isOpen = () => state.parenDepth > 0 || state.braceDepth > 0 || state.bracketDepth > 0 || state.inTemplate;
21318
+ const endsWithContinuation = (text2) => /(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)$/.test(text2.trimEnd());
21319
+ const startsWithContinuation = (text2) => /^(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)/.test(text2.trimStart());
21320
+ let bodyText = lines[startLine].slice(arrowCol + 2);
21321
+ updateState(bodyText);
21322
+ let nextLine = startLine + 1;
21323
+ while (nextLine < lines.length) {
21324
+ const previousLine = nextLine === startLine + 1 ? bodyText : lines[nextLine - 1];
21325
+ const shouldContinue = !bodyText.trim() || isOpen() || endsWithContinuation(previousLine) || startsWithContinuation(lines[nextLine]);
21326
+ if (!shouldContinue)
21327
+ break;
21328
+ bodyText += `
21329
+ ${lines[nextLine]}`;
21330
+ updateState(lines[nextLine]);
21331
+ nextLine++;
21332
+ }
21333
+ return bodyText;
21334
+ };
21291
21335
  const mainTmplStack = [];
21292
21336
  let mainInSingle = false;
21293
21337
  let mainInDouble = false;
@@ -21651,73 +21695,7 @@ ${lines.slice(bodyRange.from + 1, bodyRange.to + 1).join(`
21651
21695
  }
21652
21696
  }
21653
21697
  } else {
21654
- bodyText = line.slice(arrowIdx + 2);
21655
- let parenDepth = 0;
21656
- let braceDepth = 0;
21657
- let bracketDepth = 0;
21658
- let inTemplate = false;
21659
- for (let k = arrowIdx + 2;k < line.length; k++) {
21660
- const ch = line[k];
21661
- if (ch === "`")
21662
- inTemplate = !inTemplate;
21663
- else if (ch === "(")
21664
- parenDepth++;
21665
- else if (ch === ")")
21666
- parenDepth--;
21667
- else if (ch === "{")
21668
- braceDepth++;
21669
- else if (ch === "}")
21670
- braceDepth--;
21671
- else if (ch === "[")
21672
- bracketDepth++;
21673
- else if (ch === "]")
21674
- bracketDepth--;
21675
- }
21676
- let nextLine = i + 1;
21677
- if ((!bodyText.trim() || inTemplate) && nextLine < lines.length) {
21678
- bodyText += `
21679
- ${lines[nextLine]}`;
21680
- for (let k = 0;k < lines[nextLine].length; k++) {
21681
- const ch = lines[nextLine][k];
21682
- if (ch === "`")
21683
- inTemplate = !inTemplate;
21684
- else if (ch === "(")
21685
- parenDepth++;
21686
- else if (ch === ")")
21687
- parenDepth--;
21688
- else if (ch === "{")
21689
- braceDepth++;
21690
- else if (ch === "}")
21691
- braceDepth--;
21692
- else if (ch === "[")
21693
- bracketDepth++;
21694
- else if (ch === "]")
21695
- bracketDepth--;
21696
- }
21697
- nextLine++;
21698
- }
21699
- while (nextLine < lines.length && (parenDepth > 0 || braceDepth > 0 || bracketDepth > 0 || inTemplate)) {
21700
- bodyText += `
21701
- ${lines[nextLine]}`;
21702
- for (let k = 0;k < lines[nextLine].length; k++) {
21703
- const ch = lines[nextLine][k];
21704
- if (ch === "`")
21705
- inTemplate = !inTemplate;
21706
- else if (ch === "(")
21707
- parenDepth++;
21708
- else if (ch === ")")
21709
- parenDepth--;
21710
- else if (ch === "{")
21711
- braceDepth++;
21712
- else if (ch === "}")
21713
- braceDepth--;
21714
- else if (ch === "[")
21715
- bracketDepth++;
21716
- else if (ch === "]")
21717
- bracketDepth--;
21718
- }
21719
- nextLine++;
21720
- }
21698
+ bodyText = collectArrowExpressionBody(i, arrowIdx);
21721
21699
  }
21722
21700
  for (const name of params) {
21723
21701
  if (!name || argIgnoreRe.test(name) || name === "undefined")
@@ -21774,73 +21752,7 @@ ${lines.slice(bodyRange.from + 1, bodyRange.to + 1).join(`
21774
21752
  }
21775
21753
  }
21776
21754
  } else {
21777
- bodyText = line.slice(arrowIdx2 + 2);
21778
- let parenDepth = 0;
21779
- let braceDepth = 0;
21780
- let bracketDepth = 0;
21781
- let inTemplate = false;
21782
- for (let k = arrowIdx2 + 2;k < line.length; k++) {
21783
- const ch = line[k];
21784
- if (ch === "`")
21785
- inTemplate = !inTemplate;
21786
- else if (ch === "(")
21787
- parenDepth++;
21788
- else if (ch === ")")
21789
- parenDepth--;
21790
- else if (ch === "{")
21791
- braceDepth++;
21792
- else if (ch === "}")
21793
- braceDepth--;
21794
- else if (ch === "[")
21795
- bracketDepth++;
21796
- else if (ch === "]")
21797
- bracketDepth--;
21798
- }
21799
- let nextLine = i + 1;
21800
- if ((!bodyText.trim() || inTemplate) && nextLine < lines.length) {
21801
- bodyText += `
21802
- ${lines[nextLine]}`;
21803
- for (let k = 0;k < lines[nextLine].length; k++) {
21804
- const ch = lines[nextLine][k];
21805
- if (ch === "`")
21806
- inTemplate = !inTemplate;
21807
- else if (ch === "(")
21808
- parenDepth++;
21809
- else if (ch === ")")
21810
- parenDepth--;
21811
- else if (ch === "{")
21812
- braceDepth++;
21813
- else if (ch === "}")
21814
- braceDepth--;
21815
- else if (ch === "[")
21816
- bracketDepth++;
21817
- else if (ch === "]")
21818
- bracketDepth--;
21819
- }
21820
- nextLine++;
21821
- }
21822
- while (nextLine < lines.length && (parenDepth > 0 || braceDepth > 0 || bracketDepth > 0 || inTemplate)) {
21823
- bodyText += `
21824
- ${lines[nextLine]}`;
21825
- for (let k = 0;k < lines[nextLine].length; k++) {
21826
- const ch = lines[nextLine][k];
21827
- if (ch === "`")
21828
- inTemplate = !inTemplate;
21829
- else if (ch === "(")
21830
- parenDepth++;
21831
- else if (ch === ")")
21832
- parenDepth--;
21833
- else if (ch === "{")
21834
- braceDepth++;
21835
- else if (ch === "}")
21836
- braceDepth--;
21837
- else if (ch === "[")
21838
- bracketDepth++;
21839
- else if (ch === "]")
21840
- bracketDepth--;
21841
- }
21842
- nextLine++;
21843
- }
21755
+ bodyText = collectArrowExpressionBody(i, arrowIdx2);
21844
21756
  }
21845
21757
  const useRe = new RegExp(`\\b${name}\\b`, "g");
21846
21758
  if (!useRe.test(bodyText)) {
@@ -43587,7 +43499,7 @@ var require_package = __commonJS((exports, module) => {
43587
43499
  module.exports = {
43588
43500
  name: "pickier",
43589
43501
  type: "module",
43590
- version: "0.1.29",
43502
+ version: "0.1.30",
43591
43503
  description: "Format, lint and more in a fraction of seconds.",
43592
43504
  author: "Chris Breuer <chris@stacksjs.org>",
43593
43505
  license: "MIT",
@@ -43663,6 +43575,7 @@ var require_package = __commonJS((exports, module) => {
43663
43575
  "test:watch": "PICKIER_NO_AUTO_CONFIG=1 bun test --watch"
43664
43576
  },
43665
43577
  dependencies: {
43578
+ "@stacksjs/clarity": "^0.3.24",
43666
43579
  "@stacksjs/clapp": "^0.2.3"
43667
43580
  },
43668
43581
  optionalDependencies: {
package/dist/src/index.js CHANGED
@@ -20886,6 +20886,50 @@ var init_no_unused_vars = __esm(() => {
20886
20886
  }
20887
20887
  return null;
20888
20888
  };
20889
+ const collectArrowExpressionBody = (startLine, arrowCol) => {
20890
+ const state = {
20891
+ parenDepth: 0,
20892
+ braceDepth: 0,
20893
+ bracketDepth: 0,
20894
+ inTemplate: false
20895
+ };
20896
+ const updateState = (text2) => {
20897
+ for (let k = 0;k < text2.length; k++) {
20898
+ const ch = text2[k];
20899
+ if (ch === "`")
20900
+ state.inTemplate = !state.inTemplate;
20901
+ else if (ch === "(")
20902
+ state.parenDepth++;
20903
+ else if (ch === ")")
20904
+ state.parenDepth--;
20905
+ else if (ch === "{")
20906
+ state.braceDepth++;
20907
+ else if (ch === "}")
20908
+ state.braceDepth--;
20909
+ else if (ch === "[")
20910
+ state.bracketDepth++;
20911
+ else if (ch === "]")
20912
+ state.bracketDepth--;
20913
+ }
20914
+ };
20915
+ const isOpen = () => state.parenDepth > 0 || state.braceDepth > 0 || state.bracketDepth > 0 || state.inTemplate;
20916
+ const endsWithContinuation = (text2) => /(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)$/.test(text2.trimEnd());
20917
+ const startsWithContinuation = (text2) => /^(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)/.test(text2.trimStart());
20918
+ let bodyText = lines[startLine].slice(arrowCol + 2);
20919
+ updateState(bodyText);
20920
+ let nextLine = startLine + 1;
20921
+ while (nextLine < lines.length) {
20922
+ const previousLine = nextLine === startLine + 1 ? bodyText : lines[nextLine - 1];
20923
+ const shouldContinue = !bodyText.trim() || isOpen() || endsWithContinuation(previousLine) || startsWithContinuation(lines[nextLine]);
20924
+ if (!shouldContinue)
20925
+ break;
20926
+ bodyText += `
20927
+ ${lines[nextLine]}`;
20928
+ updateState(lines[nextLine]);
20929
+ nextLine++;
20930
+ }
20931
+ return bodyText;
20932
+ };
20889
20933
  const mainTmplStack = [];
20890
20934
  let mainInSingle = false;
20891
20935
  let mainInDouble = false;
@@ -21249,73 +21293,7 @@ ${lines.slice(bodyRange.from + 1, bodyRange.to + 1).join(`
21249
21293
  }
21250
21294
  }
21251
21295
  } else {
21252
- bodyText = line.slice(arrowIdx + 2);
21253
- let parenDepth = 0;
21254
- let braceDepth = 0;
21255
- let bracketDepth = 0;
21256
- let inTemplate = false;
21257
- for (let k = arrowIdx + 2;k < line.length; k++) {
21258
- const ch = line[k];
21259
- if (ch === "`")
21260
- inTemplate = !inTemplate;
21261
- else if (ch === "(")
21262
- parenDepth++;
21263
- else if (ch === ")")
21264
- parenDepth--;
21265
- else if (ch === "{")
21266
- braceDepth++;
21267
- else if (ch === "}")
21268
- braceDepth--;
21269
- else if (ch === "[")
21270
- bracketDepth++;
21271
- else if (ch === "]")
21272
- bracketDepth--;
21273
- }
21274
- let nextLine = i + 1;
21275
- if ((!bodyText.trim() || inTemplate) && nextLine < lines.length) {
21276
- bodyText += `
21277
- ${lines[nextLine]}`;
21278
- for (let k = 0;k < lines[nextLine].length; k++) {
21279
- const ch = lines[nextLine][k];
21280
- if (ch === "`")
21281
- inTemplate = !inTemplate;
21282
- else if (ch === "(")
21283
- parenDepth++;
21284
- else if (ch === ")")
21285
- parenDepth--;
21286
- else if (ch === "{")
21287
- braceDepth++;
21288
- else if (ch === "}")
21289
- braceDepth--;
21290
- else if (ch === "[")
21291
- bracketDepth++;
21292
- else if (ch === "]")
21293
- bracketDepth--;
21294
- }
21295
- nextLine++;
21296
- }
21297
- while (nextLine < lines.length && (parenDepth > 0 || braceDepth > 0 || bracketDepth > 0 || inTemplate)) {
21298
- bodyText += `
21299
- ${lines[nextLine]}`;
21300
- for (let k = 0;k < lines[nextLine].length; k++) {
21301
- const ch = lines[nextLine][k];
21302
- if (ch === "`")
21303
- inTemplate = !inTemplate;
21304
- else if (ch === "(")
21305
- parenDepth++;
21306
- else if (ch === ")")
21307
- parenDepth--;
21308
- else if (ch === "{")
21309
- braceDepth++;
21310
- else if (ch === "}")
21311
- braceDepth--;
21312
- else if (ch === "[")
21313
- bracketDepth++;
21314
- else if (ch === "]")
21315
- bracketDepth--;
21316
- }
21317
- nextLine++;
21318
- }
21296
+ bodyText = collectArrowExpressionBody(i, arrowIdx);
21319
21297
  }
21320
21298
  for (const name of params) {
21321
21299
  if (!name || argIgnoreRe.test(name) || name === "undefined")
@@ -21372,73 +21350,7 @@ ${lines.slice(bodyRange.from + 1, bodyRange.to + 1).join(`
21372
21350
  }
21373
21351
  }
21374
21352
  } else {
21375
- bodyText = line.slice(arrowIdx2 + 2);
21376
- let parenDepth = 0;
21377
- let braceDepth = 0;
21378
- let bracketDepth = 0;
21379
- let inTemplate = false;
21380
- for (let k = arrowIdx2 + 2;k < line.length; k++) {
21381
- const ch = line[k];
21382
- if (ch === "`")
21383
- inTemplate = !inTemplate;
21384
- else if (ch === "(")
21385
- parenDepth++;
21386
- else if (ch === ")")
21387
- parenDepth--;
21388
- else if (ch === "{")
21389
- braceDepth++;
21390
- else if (ch === "}")
21391
- braceDepth--;
21392
- else if (ch === "[")
21393
- bracketDepth++;
21394
- else if (ch === "]")
21395
- bracketDepth--;
21396
- }
21397
- let nextLine = i + 1;
21398
- if ((!bodyText.trim() || inTemplate) && nextLine < lines.length) {
21399
- bodyText += `
21400
- ${lines[nextLine]}`;
21401
- for (let k = 0;k < lines[nextLine].length; k++) {
21402
- const ch = lines[nextLine][k];
21403
- if (ch === "`")
21404
- inTemplate = !inTemplate;
21405
- else if (ch === "(")
21406
- parenDepth++;
21407
- else if (ch === ")")
21408
- parenDepth--;
21409
- else if (ch === "{")
21410
- braceDepth++;
21411
- else if (ch === "}")
21412
- braceDepth--;
21413
- else if (ch === "[")
21414
- bracketDepth++;
21415
- else if (ch === "]")
21416
- bracketDepth--;
21417
- }
21418
- nextLine++;
21419
- }
21420
- while (nextLine < lines.length && (parenDepth > 0 || braceDepth > 0 || bracketDepth > 0 || inTemplate)) {
21421
- bodyText += `
21422
- ${lines[nextLine]}`;
21423
- for (let k = 0;k < lines[nextLine].length; k++) {
21424
- const ch = lines[nextLine][k];
21425
- if (ch === "`")
21426
- inTemplate = !inTemplate;
21427
- else if (ch === "(")
21428
- parenDepth++;
21429
- else if (ch === ")")
21430
- parenDepth--;
21431
- else if (ch === "{")
21432
- braceDepth++;
21433
- else if (ch === "}")
21434
- braceDepth--;
21435
- else if (ch === "[")
21436
- bracketDepth++;
21437
- else if (ch === "]")
21438
- bracketDepth--;
21439
- }
21440
- nextLine++;
21441
- }
21353
+ bodyText = collectArrowExpressionBody(i, arrowIdx2);
21442
21354
  }
21443
21355
  const useRe = new RegExp(`\\b${name}\\b`, "g");
21444
21356
  if (!useRe.test(bodyText)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pickier",
3
3
  "type": "module",
4
- "version": "0.1.29",
4
+ "version": "0.1.30",
5
5
  "description": "Format, lint and more in a fraction of seconds.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -77,6 +77,7 @@
77
77
  "test:watch": "PICKIER_NO_AUTO_CONFIG=1 bun test --watch"
78
78
  },
79
79
  "dependencies": {
80
+ "@stacksjs/clarity": "^0.3.24",
80
81
  "@stacksjs/clapp": "^0.2.3"
81
82
  },
82
83
  "optionalDependencies": {