pickier 0.1.29 → 0.1.32

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
@@ -21246,6 +21246,27 @@ var init_no_unused_vars = __esm(() => {
21246
21246
  continue;
21247
21247
  }
21248
21248
  if (inTmplExpr) {
21249
+ if (ch === "/") {
21250
+ const before = lineToProcess.slice(0, k).trimEnd();
21251
+ const regexPrecedeRe = /[=([{,:;!&|?]$/;
21252
+ if (!before || regexPrecedeRe.test(before) || before.endsWith("return")) {
21253
+ k++;
21254
+ while (k < lineToProcess.length) {
21255
+ if (lineToProcess[k] === "\\") {
21256
+ k += 2;
21257
+ continue;
21258
+ }
21259
+ if (lineToProcess[k] === "/") {
21260
+ while (k + 1 < lineToProcess.length && /[gimsuvy]/.test(lineToProcess[k + 1])) {
21261
+ k++;
21262
+ }
21263
+ break;
21264
+ }
21265
+ k++;
21266
+ }
21267
+ continue;
21268
+ }
21269
+ }
21249
21270
  if (ch === "`") {
21250
21271
  depthTmplStack.push(-1);
21251
21272
  continue;
@@ -21288,6 +21309,50 @@ var init_no_unused_vars = __esm(() => {
21288
21309
  }
21289
21310
  return null;
21290
21311
  };
21312
+ const collectArrowExpressionBody = (startLine, arrowCol) => {
21313
+ const state = {
21314
+ parenDepth: 0,
21315
+ braceDepth: 0,
21316
+ bracketDepth: 0,
21317
+ inTemplate: false
21318
+ };
21319
+ const updateState = (text2) => {
21320
+ for (let k = 0;k < text2.length; k++) {
21321
+ const ch = text2[k];
21322
+ if (ch === "`")
21323
+ state.inTemplate = !state.inTemplate;
21324
+ else if (ch === "(")
21325
+ state.parenDepth++;
21326
+ else if (ch === ")")
21327
+ state.parenDepth--;
21328
+ else if (ch === "{")
21329
+ state.braceDepth++;
21330
+ else if (ch === "}")
21331
+ state.braceDepth--;
21332
+ else if (ch === "[")
21333
+ state.bracketDepth++;
21334
+ else if (ch === "]")
21335
+ state.bracketDepth--;
21336
+ }
21337
+ };
21338
+ const isOpen = () => state.parenDepth > 0 || state.braceDepth > 0 || state.bracketDepth > 0 || state.inTemplate;
21339
+ const endsWithContinuation = (text2) => /(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)$/.test(text2.trimEnd());
21340
+ const startsWithContinuation = (text2) => /^(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)/.test(text2.trimStart());
21341
+ let bodyText = lines[startLine].slice(arrowCol + 2);
21342
+ updateState(bodyText);
21343
+ let nextLine = startLine + 1;
21344
+ while (nextLine < lines.length) {
21345
+ const previousLine = nextLine === startLine + 1 ? bodyText : lines[nextLine - 1];
21346
+ const shouldContinue = !bodyText.trim() || isOpen() || endsWithContinuation(previousLine) || startsWithContinuation(lines[nextLine]);
21347
+ if (!shouldContinue)
21348
+ break;
21349
+ bodyText += `
21350
+ ${lines[nextLine]}`;
21351
+ updateState(lines[nextLine]);
21352
+ nextLine++;
21353
+ }
21354
+ return bodyText;
21355
+ };
21291
21356
  const mainTmplStack = [];
21292
21357
  let mainInSingle = false;
21293
21358
  let mainInDouble = false;
@@ -21651,73 +21716,7 @@ ${lines.slice(bodyRange.from + 1, bodyRange.to + 1).join(`
21651
21716
  }
21652
21717
  }
21653
21718
  } 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
- }
21719
+ bodyText = collectArrowExpressionBody(i, arrowIdx);
21721
21720
  }
21722
21721
  for (const name of params) {
21723
21722
  if (!name || argIgnoreRe.test(name) || name === "undefined")
@@ -21774,73 +21773,7 @@ ${lines.slice(bodyRange.from + 1, bodyRange.to + 1).join(`
21774
21773
  }
21775
21774
  }
21776
21775
  } 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
- }
21776
+ bodyText = collectArrowExpressionBody(i, arrowIdx2);
21844
21777
  }
21845
21778
  const useRe = new RegExp(`\\b${name}\\b`, "g");
21846
21779
  if (!useRe.test(bodyText)) {
@@ -43587,7 +43520,7 @@ var require_package = __commonJS((exports, module) => {
43587
43520
  module.exports = {
43588
43521
  name: "pickier",
43589
43522
  type: "module",
43590
- version: "0.1.29",
43523
+ version: "0.1.32",
43591
43524
  description: "Format, lint and more in a fraction of seconds.",
43592
43525
  author: "Chris Breuer <chris@stacksjs.org>",
43593
43526
  license: "MIT",
@@ -43663,6 +43596,7 @@ var require_package = __commonJS((exports, module) => {
43663
43596
  "test:watch": "PICKIER_NO_AUTO_CONFIG=1 bun test --watch"
43664
43597
  },
43665
43598
  dependencies: {
43599
+ "@stacksjs/clarity": "^0.3.24",
43666
43600
  "@stacksjs/clapp": "^0.2.3"
43667
43601
  },
43668
43602
  optionalDependencies: {
package/dist/src/index.js CHANGED
@@ -20844,6 +20844,27 @@ var init_no_unused_vars = __esm(() => {
20844
20844
  continue;
20845
20845
  }
20846
20846
  if (inTmplExpr) {
20847
+ if (ch === "/") {
20848
+ const before = lineToProcess.slice(0, k).trimEnd();
20849
+ const regexPrecedeRe = /[=([{,:;!&|?]$/;
20850
+ if (!before || regexPrecedeRe.test(before) || before.endsWith("return")) {
20851
+ k++;
20852
+ while (k < lineToProcess.length) {
20853
+ if (lineToProcess[k] === "\\") {
20854
+ k += 2;
20855
+ continue;
20856
+ }
20857
+ if (lineToProcess[k] === "/") {
20858
+ while (k + 1 < lineToProcess.length && /[gimsuvy]/.test(lineToProcess[k + 1])) {
20859
+ k++;
20860
+ }
20861
+ break;
20862
+ }
20863
+ k++;
20864
+ }
20865
+ continue;
20866
+ }
20867
+ }
20847
20868
  if (ch === "`") {
20848
20869
  depthTmplStack.push(-1);
20849
20870
  continue;
@@ -20886,6 +20907,50 @@ var init_no_unused_vars = __esm(() => {
20886
20907
  }
20887
20908
  return null;
20888
20909
  };
20910
+ const collectArrowExpressionBody = (startLine, arrowCol) => {
20911
+ const state = {
20912
+ parenDepth: 0,
20913
+ braceDepth: 0,
20914
+ bracketDepth: 0,
20915
+ inTemplate: false
20916
+ };
20917
+ const updateState = (text2) => {
20918
+ for (let k = 0;k < text2.length; k++) {
20919
+ const ch = text2[k];
20920
+ if (ch === "`")
20921
+ state.inTemplate = !state.inTemplate;
20922
+ else if (ch === "(")
20923
+ state.parenDepth++;
20924
+ else if (ch === ")")
20925
+ state.parenDepth--;
20926
+ else if (ch === "{")
20927
+ state.braceDepth++;
20928
+ else if (ch === "}")
20929
+ state.braceDepth--;
20930
+ else if (ch === "[")
20931
+ state.bracketDepth++;
20932
+ else if (ch === "]")
20933
+ state.bracketDepth--;
20934
+ }
20935
+ };
20936
+ const isOpen = () => state.parenDepth > 0 || state.braceDepth > 0 || state.bracketDepth > 0 || state.inTemplate;
20937
+ const endsWithContinuation = (text2) => /(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)$/.test(text2.trimEnd());
20938
+ const startsWithContinuation = (text2) => /^(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)/.test(text2.trimStart());
20939
+ let bodyText = lines[startLine].slice(arrowCol + 2);
20940
+ updateState(bodyText);
20941
+ let nextLine = startLine + 1;
20942
+ while (nextLine < lines.length) {
20943
+ const previousLine = nextLine === startLine + 1 ? bodyText : lines[nextLine - 1];
20944
+ const shouldContinue = !bodyText.trim() || isOpen() || endsWithContinuation(previousLine) || startsWithContinuation(lines[nextLine]);
20945
+ if (!shouldContinue)
20946
+ break;
20947
+ bodyText += `
20948
+ ${lines[nextLine]}`;
20949
+ updateState(lines[nextLine]);
20950
+ nextLine++;
20951
+ }
20952
+ return bodyText;
20953
+ };
20889
20954
  const mainTmplStack = [];
20890
20955
  let mainInSingle = false;
20891
20956
  let mainInDouble = false;
@@ -21249,73 +21314,7 @@ ${lines.slice(bodyRange.from + 1, bodyRange.to + 1).join(`
21249
21314
  }
21250
21315
  }
21251
21316
  } 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
- }
21317
+ bodyText = collectArrowExpressionBody(i, arrowIdx);
21319
21318
  }
21320
21319
  for (const name of params) {
21321
21320
  if (!name || argIgnoreRe.test(name) || name === "undefined")
@@ -21372,73 +21371,7 @@ ${lines.slice(bodyRange.from + 1, bodyRange.to + 1).join(`
21372
21371
  }
21373
21372
  }
21374
21373
  } 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
- }
21374
+ bodyText = collectArrowExpressionBody(i, arrowIdx2);
21442
21375
  }
21443
21376
  const useRe = new RegExp(`\\b${name}\\b`, "g");
21444
21377
  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.32",
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": {
package/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- # MIT License
2
-
3
- Copyright (c) 2024 Open Web Foundation
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.