@ben_12/eslint-plugin-dprint 0.6.1 → 0.7.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
@@ -26,6 +26,10 @@ module.exports = {
26
26
  "@ben_12/dprint/dprint": [
27
27
  "error",
28
28
  {
29
+ // Use dprint JSON configuration file (default: "dprint.json")
30
+ // It may be created using `dprint init` command
31
+ // See also https://dprint.dev/config/
32
+ configFile: "dprint.json",
29
33
  config: {
30
34
  // The TypeScript configuration of dprint
31
35
  // See also https://dprint.dev/plugins/typescript/config/
@@ -4,7 +4,6 @@
4
4
  "useTabs": {
5
5
  "description": "Whether to use tabs (true) or spaces (false).",
6
6
  "type": "boolean",
7
- "default": false,
8
7
  "oneOf": [{
9
8
  "enum": [true],
10
9
  "description": "Uses tabs for indentation."
@@ -16,7 +15,6 @@
16
15
  "semiColons": {
17
16
  "description": "How semi-colons should be used.",
18
17
  "type": "string",
19
- "default": "prefer",
20
18
  "oneOf": [{
21
19
  "enum": ["always"],
22
20
  "description": "Always uses semi-colons where applicable."
@@ -31,7 +29,6 @@
31
29
  "quoteStyle": {
32
30
  "description": "How to use single or double quotes.",
33
31
  "type": "string",
34
- "default": "alwaysDouble",
35
32
  "oneOf": [{
36
33
  "enum": ["alwaysDouble"],
37
34
  "description": "Always uses double quotes."
@@ -49,7 +46,6 @@
49
46
  "jsx.quoteStyle": {
50
47
  "description": "How to use single or double quotes in JSX attributes.",
51
48
  "type": "string",
52
- "default": "preferDouble",
53
49
  "oneOf": [{
54
50
  "enum": ["preferDouble"],
55
51
  "description": "Prefers using double quotes except in scenarios where the string contains more double quotes than single quotes."
@@ -61,7 +57,6 @@
61
57
  "quoteProps": {
62
58
  "description": "Change when properties in objects are quoted.",
63
59
  "type": "string",
64
- "default": "preserve",
65
60
  "oneOf": [{
66
61
  "enum": ["asNeeded"],
67
62
  "description": "Remove unnecessary quotes around property names."
@@ -76,7 +71,6 @@
76
71
  "jsx.multiLineParens": {
77
72
  "description": "Surrounds the top-most JSX element or fragment in parentheses when it spans multiple lines.",
78
73
  "type": "string",
79
- "default": "prefer",
80
74
  "oneOf": [{
81
75
  "enum": ["never"],
82
76
  "description": "Never wrap JSX with parentheses."
@@ -91,7 +85,6 @@
91
85
  "jsx.forceNewLinesSurroundingContent": {
92
86
  "description": "Forces newlines surrounding the content of JSX elements.",
93
87
  "type": "boolean",
94
- "default": false,
95
88
  "oneOf": [{
96
89
  "enum": [true],
97
90
  "description": ""
@@ -103,7 +96,6 @@
103
96
  "jsx.bracketPosition": {
104
97
  "description": "If the end angle bracket of a jsx open element or self closing element should be on the same or next line when the attributes span multiple lines.",
105
98
  "type": "string",
106
- "default": "nextLine",
107
99
  "oneOf": [{
108
100
  "enum": ["maintain"],
109
101
  "description": "Maintains the position of the end angle bracket."
@@ -118,7 +110,6 @@
118
110
  "newLineKind": {
119
111
  "description": "The kind of newline to use.",
120
112
  "type": "string",
121
- "default": "lf",
122
113
  "oneOf": [{
123
114
  "enum": ["auto"],
124
115
  "description": "For each file, uses the last newline kind found in the file."
@@ -136,7 +127,6 @@
136
127
  "useBraces": {
137
128
  "description": "If braces should be used or not.",
138
129
  "type": "string",
139
- "default": "whenNotSingleLine",
140
130
  "oneOf": [{
141
131
  "enum": ["maintain"],
142
132
  "description": "Uses braces if they're used. Doesn't use braces if they're not used."
@@ -154,7 +144,6 @@
154
144
  "bracePosition": {
155
145
  "description": "Where to place the opening brace.",
156
146
  "type": "string",
157
- "default": "sameLineUnlessHanging",
158
147
  "oneOf": [{
159
148
  "enum": ["maintain"],
160
149
  "description": "Maintains the brace being on the next line or the same line."
@@ -172,7 +161,6 @@
172
161
  "singleBodyPosition": {
173
162
  "description": "Where to place the expression of a statement that could possibly be on one line (ex. `if (true) console.log(5);`).",
174
163
  "type": "string",
175
- "default": "maintain",
176
164
  "oneOf": [{
177
165
  "enum": ["maintain"],
178
166
  "description": "Maintains the position of the expression."
@@ -187,7 +175,6 @@
187
175
  "nextControlFlowPosition": {
188
176
  "description": "Where to place the next control flow within a control flow statement.",
189
177
  "type": "string",
190
- "default": "sameLine",
191
178
  "oneOf": [{
192
179
  "enum": ["maintain"],
193
180
  "description": "Maintains the next control flow being on the next line or the same line."
@@ -202,7 +189,6 @@
202
189
  "trailingCommas": {
203
190
  "description": "If trailing commas should be used.",
204
191
  "type": "string",
205
- "default": "onlyMultiLine",
206
192
  "oneOf": [{
207
193
  "enum": ["never"],
208
194
  "description": "Trailing commas should not be used."
@@ -217,7 +203,6 @@
217
203
  "operatorPosition": {
218
204
  "description": "Where to place the operator for expressions that span multiple lines.",
219
205
  "type": "string",
220
- "default": "nextLine",
221
206
  "oneOf": [{
222
207
  "enum": ["maintain"],
223
208
  "description": "Maintains the operator being on the next line or the same line."
@@ -232,7 +217,6 @@
232
217
  "preferHanging": {
233
218
  "description": "Set to prefer hanging indentation when exceeding the line width instead of making code split up on multiple lines.",
234
219
  "type": "boolean",
235
- "default": false,
236
220
  "oneOf": [{
237
221
  "enum": [true],
238
222
  "description": ""
@@ -244,7 +228,6 @@
244
228
  "preferHangingGranular": {
245
229
  "description": "Set to prefer hanging indentation when exceeding the line width instead of making code split up on multiple lines.",
246
230
  "type": "string",
247
- "default": "never",
248
231
  "oneOf": [{
249
232
  "enum": ["always"],
250
233
  "description": "Always prefers hanging regardless of the number of elements."
@@ -259,7 +242,6 @@
259
242
  "preferSingleLine": {
260
243
  "description": "If code should revert back from being on multiple lines to being on a single line when able.",
261
244
  "type": "boolean",
262
- "default": false,
263
245
  "oneOf": [{
264
246
  "enum": [true],
265
247
  "description": ""
@@ -271,7 +253,6 @@
271
253
  "forceSingleLine": {
272
254
  "description": "If code should be forced to be on a single line if able.",
273
255
  "type": "boolean",
274
- "default": false,
275
256
  "oneOf": [{
276
257
  "enum": [true],
277
258
  "description": ""
@@ -283,7 +264,6 @@
283
264
  "forceMultiLineSpecifiers": {
284
265
  "description": "If code import/export specifiers should be forced to be on multiple lines.",
285
266
  "type": "boolean",
286
- "default": false,
287
267
  "oneOf": [{
288
268
  "enum": [true],
289
269
  "description": ""
@@ -295,7 +275,6 @@
295
275
  "sortOrder": {
296
276
  "description": "The kind of sort ordering to use.",
297
277
  "type": "string",
298
- "default": "caseInsensitive",
299
278
  "oneOf": [{
300
279
  "enum": ["maintain"],
301
280
  "description": "Maintains the current ordering."
@@ -310,7 +289,6 @@
310
289
  "deno": {
311
290
  "description": "Top level configuration that sets the configuration to what is used in Deno.",
312
291
  "type": "boolean",
313
- "default": false,
314
292
  "oneOf": [{
315
293
  "enum": [true],
316
294
  "description": ""
@@ -322,7 +300,6 @@
322
300
  "arrowFunction.useParentheses": {
323
301
  "description": "Whether to use parentheses around a single parameter in an arrow function.",
324
302
  "type": "string",
325
- "default": "maintain",
326
303
  "oneOf": [{
327
304
  "enum": ["force"],
328
305
  "description": "Forces parentheses."
@@ -337,7 +314,6 @@
337
314
  "binaryExpression.linePerExpression": {
338
315
  "description": "Whether to force a line per expression when spanning multiple lines.",
339
316
  "type": "boolean",
340
- "default": false,
341
317
  "oneOf": [{
342
318
  "enum": [true],
343
319
  "description": "Formats with each part on a new line."
@@ -349,7 +325,6 @@
349
325
  "conditionalExpression.linePerExpression": {
350
326
  "description": "Whether to force a line per expression when spanning multiple lines.",
351
327
  "type": "boolean",
352
- "default": true,
353
328
  "oneOf": [{
354
329
  "enum": [true],
355
330
  "description": "Formats with each part on a new line."
@@ -361,7 +336,6 @@
361
336
  "memberExpression.linePerExpression": {
362
337
  "description": "Whether to force a line per expression when spanning multiple lines.",
363
338
  "type": "boolean",
364
- "default": false,
365
339
  "oneOf": [{
366
340
  "enum": [true],
367
341
  "description": "Formats with each part on a new line."
@@ -373,7 +347,6 @@
373
347
  "enumDeclaration.memberSpacing": {
374
348
  "description": "How to space the members of an enum.",
375
349
  "type": "string",
376
- "default": "maintain",
377
350
  "oneOf": [{
378
351
  "enum": ["newLine"],
379
352
  "description": "Forces a new line between members."
@@ -388,7 +361,6 @@
388
361
  "typeLiteral.separatorKind": {
389
362
  "description": "The kind of separator to use in type literals.",
390
363
  "type": "string",
391
- "default": "semiColon",
392
364
  "oneOf": [{
393
365
  "enum": ["semiColon"],
394
366
  "description": "Use semi-colons."
@@ -400,7 +372,6 @@
400
372
  "spaceAround": {
401
373
  "description": "Whether to place spaces around enclosed expressions.",
402
374
  "type": "boolean",
403
- "default": false,
404
375
  "oneOf": [{
405
376
  "enum": [true],
406
377
  "description": "Ex. `myFunction( true )`"
@@ -412,7 +383,6 @@
412
383
  "spaceSurroundingProperties": {
413
384
  "description": "Whether to add a space surrounding the properties of single line object-like nodes.",
414
385
  "type": "boolean",
415
- "default": true,
416
386
  "oneOf": [{
417
387
  "enum": [true],
418
388
  "description": "Ex. `{ key: value }`"
@@ -424,7 +394,6 @@
424
394
  "objectExpression.spaceSurroundingProperties": {
425
395
  "description": "Whether to add a space surrounding the properties of a single line object expression.",
426
396
  "type": "boolean",
427
- "default": true,
428
397
  "oneOf": [{
429
398
  "enum": [true],
430
399
  "description": "Ex. `{ key: value }`"
@@ -436,7 +405,6 @@
436
405
  "objectPattern.spaceSurroundingProperties": {
437
406
  "description": "Whether to add a space surrounding the properties of a single line object pattern.",
438
407
  "type": "boolean",
439
- "default": true,
440
408
  "oneOf": [{
441
409
  "enum": [true],
442
410
  "description": "Ex. `{ key: value } = obj`"
@@ -448,7 +416,6 @@
448
416
  "typeLiteral.spaceSurroundingProperties": {
449
417
  "description": "Whether to add a space surrounding the properties of a single line type literal.",
450
418
  "type": "boolean",
451
- "default": true,
452
419
  "oneOf": [{
453
420
  "enum": [true],
454
421
  "description": "Ex. `type Test = { key: string }`"
@@ -460,7 +427,6 @@
460
427
  "binaryExpression.spaceSurroundingBitwiseAndArithmeticOperator": {
461
428
  "description": "Whether to surround the operator in a binary expression with spaces.",
462
429
  "type": "boolean",
463
- "default": true,
464
430
  "oneOf": [{
465
431
  "enum": [true],
466
432
  "description": "Ex. `1 + 2`"
@@ -472,7 +438,6 @@
472
438
  "commentLine.forceSpaceAfterSlashes": {
473
439
  "description": "Forces a space after the double slash in a comment line.",
474
440
  "type": "boolean",
475
- "default": true,
476
441
  "oneOf": [{
477
442
  "enum": [true],
478
443
  "description": "Ex. `//test` -> `// test`"
@@ -484,7 +449,6 @@
484
449
  "constructor.spaceBeforeParentheses": {
485
450
  "description": "Whether to add a space before the parentheses of a constructor.",
486
451
  "type": "boolean",
487
- "default": false,
488
452
  "oneOf": [{
489
453
  "enum": [true],
490
454
  "description": "Ex. `constructor ()`"
@@ -496,7 +460,6 @@
496
460
  "constructorType.spaceAfterNewKeyword": {
497
461
  "description": "Whether to add a space after the `new` keyword in a constructor type.",
498
462
  "type": "boolean",
499
- "default": false,
500
463
  "oneOf": [{
501
464
  "enum": [true],
502
465
  "description": "Ex. `type MyClassCtor = new () => MyClass;`"
@@ -508,7 +471,6 @@
508
471
  "constructSignature.spaceAfterNewKeyword": {
509
472
  "description": "Whether to add a space after the `new` keyword in a construct signature.",
510
473
  "type": "boolean",
511
- "default": false,
512
474
  "oneOf": [{
513
475
  "enum": [true],
514
476
  "description": "Ex. `new (): MyClass;`"
@@ -520,7 +482,6 @@
520
482
  "doWhileStatement.spaceAfterWhileKeyword": {
521
483
  "description": "Whether to add a space after the `while` keyword in a do while statement.",
522
484
  "type": "boolean",
523
- "default": true,
524
485
  "oneOf": [{
525
486
  "enum": [true],
526
487
  "description": "Ex. `do {\n} while (condition);`"
@@ -532,7 +493,6 @@
532
493
  "exportDeclaration.spaceSurroundingNamedExports": {
533
494
  "description": "Whether to add spaces around named exports in an export declaration.",
534
495
  "type": "boolean",
535
- "default": true,
536
496
  "oneOf": [{
537
497
  "enum": [true],
538
498
  "description": "Ex. `export { SomeExport, OtherExport };`"
@@ -544,7 +504,6 @@
544
504
  "forInStatement.spaceAfterForKeyword": {
545
505
  "description": "Whether to add a space after the `for` keyword in a \"for in\" statement.",
546
506
  "type": "boolean",
547
- "default": true,
548
507
  "oneOf": [{
549
508
  "enum": [true],
550
509
  "description": "Ex. `for (const prop in obj)`"
@@ -556,7 +515,6 @@
556
515
  "forOfStatement.spaceAfterForKeyword": {
557
516
  "description": "Whether to add a space after the `for` keyword in a \"for of\" statement.",
558
517
  "type": "boolean",
559
- "default": true,
560
518
  "oneOf": [{
561
519
  "enum": [true],
562
520
  "description": "Ex. `for (const value of myArray)`"
@@ -568,7 +526,6 @@
568
526
  "forStatement.spaceAfterForKeyword": {
569
527
  "description": "Whether to add a space after the `for` keyword in a \"for\" statement.",
570
528
  "type": "boolean",
571
- "default": true,
572
529
  "oneOf": [{
573
530
  "enum": [true],
574
531
  "description": "Ex. `for (let i = 0; i < 5; i++)`"
@@ -580,7 +537,6 @@
580
537
  "forStatement.spaceAfterSemiColons": {
581
538
  "description": "Whether to add a space after the semi-colons in a \"for\" statement.",
582
539
  "type": "boolean",
583
- "default": true,
584
540
  "oneOf": [{
585
541
  "enum": [true],
586
542
  "description": "Ex. `for (let i = 0; i < 5; i++)`"
@@ -592,7 +548,6 @@
592
548
  "functionDeclaration.spaceBeforeParentheses": {
593
549
  "description": "Whether to add a space before the parentheses of a function declaration.",
594
550
  "type": "boolean",
595
- "default": false,
596
551
  "oneOf": [{
597
552
  "enum": [true],
598
553
  "description": "Ex. `function myFunction ()`"
@@ -604,7 +559,6 @@
604
559
  "functionExpression.spaceBeforeParentheses": {
605
560
  "description": "Whether to add a space before the parentheses of a function expression.",
606
561
  "type": "boolean",
607
- "default": false,
608
562
  "oneOf": [{
609
563
  "enum": [true],
610
564
  "description": "Ex. `function<T> ()`"
@@ -616,7 +570,6 @@
616
570
  "functionExpression.spaceAfterFunctionKeyword": {
617
571
  "description": "Whether to add a space after the function keyword of a function expression.",
618
572
  "type": "boolean",
619
- "default": false,
620
573
  "oneOf": [{
621
574
  "enum": [true],
622
575
  "description": "Ex. `function <T>()`"
@@ -628,7 +581,6 @@
628
581
  "getAccessor.spaceBeforeParentheses": {
629
582
  "description": "Whether to add a space before the parentheses of a get accessor.",
630
583
  "type": "boolean",
631
- "default": false,
632
584
  "oneOf": [{
633
585
  "enum": [true],
634
586
  "description": "Ex. `get myProp ()`"
@@ -640,7 +592,6 @@
640
592
  "ifStatement.spaceAfterIfKeyword": {
641
593
  "description": "Whether to add a space after the `if` keyword in an \"if\" statement.",
642
594
  "type": "boolean",
643
- "default": true,
644
595
  "oneOf": [{
645
596
  "enum": [true],
646
597
  "description": "Ex. `if (true)`"
@@ -652,7 +603,6 @@
652
603
  "importDeclaration.spaceSurroundingNamedImports": {
653
604
  "description": "Whether to add spaces around named imports in an import declaration.",
654
605
  "type": "boolean",
655
- "default": true,
656
606
  "oneOf": [{
657
607
  "enum": [true],
658
608
  "description": "Ex. `import { SomeExport, OtherExport } from \"my-module\";`"
@@ -664,7 +614,6 @@
664
614
  "jsxSelfClosingElement.spaceBeforeSlash": {
665
615
  "description": "Whether to add a space before a JSX element's slash when self closing.",
666
616
  "type": "boolean",
667
- "default": true,
668
617
  "oneOf": [{
669
618
  "enum": [true],
670
619
  "description": "Ex. `<Test />`"
@@ -676,7 +625,6 @@
676
625
  "jsxExpressionContainer.spaceSurroundingExpression": {
677
626
  "description": "Whether to add a space surrounding the expression of a JSX container.",
678
627
  "type": "boolean",
679
- "default": false,
680
628
  "oneOf": [{
681
629
  "enum": [true],
682
630
  "description": "Ex. `{ myValue }`"
@@ -688,7 +636,6 @@
688
636
  "method.spaceBeforeParentheses": {
689
637
  "description": "Whether to add a space before the parentheses of a method.",
690
638
  "type": "boolean",
691
- "default": false,
692
639
  "oneOf": [{
693
640
  "enum": [true],
694
641
  "description": "Ex. `myMethod ()`"
@@ -700,7 +647,6 @@
700
647
  "setAccessor.spaceBeforeParentheses": {
701
648
  "description": "Whether to add a space before the parentheses of a set accessor.",
702
649
  "type": "boolean",
703
- "default": false,
704
650
  "oneOf": [{
705
651
  "enum": [true],
706
652
  "description": "Ex. `set myProp (value: string)`"
@@ -712,7 +658,6 @@
712
658
  "taggedTemplate.spaceBeforeLiteral": {
713
659
  "description": "Whether to add a space before the literal in a tagged template.",
714
660
  "type": "boolean",
715
- "default": false,
716
661
  "oneOf": [{
717
662
  "enum": [true],
718
663
  "description": "Ex. `html `<element />``"
@@ -724,7 +669,6 @@
724
669
  "typeAnnotation.spaceBeforeColon": {
725
670
  "description": "Whether to add a space before the colon of a type annotation.",
726
671
  "type": "boolean",
727
- "default": false,
728
672
  "oneOf": [{
729
673
  "enum": [true],
730
674
  "description": "Ex. `function myFunction() : string`"
@@ -736,7 +680,6 @@
736
680
  "typeAssertion.spaceBeforeExpression": {
737
681
  "description": "Whether to add a space before the expression in a type assertion.",
738
682
  "type": "boolean",
739
- "default": true,
740
683
  "oneOf": [{
741
684
  "enum": [true],
742
685
  "description": "Ex. `<string> myValue`"
@@ -748,7 +691,6 @@
748
691
  "whileStatement.spaceAfterWhileKeyword": {
749
692
  "description": "Whether to add a space after the `while` keyword in a while statement.",
750
693
  "type": "boolean",
751
- "default": true,
752
694
  "oneOf": [{
753
695
  "enum": [true],
754
696
  "description": "Ex. `while (true)`"
@@ -765,12 +707,10 @@
765
707
  },
766
708
  "lineWidth": {
767
709
  "description": "The width of a line the printer will try to stay under. Note that the printer may exceed this width in certain cases.",
768
- "default": 120,
769
710
  "type": "number"
770
711
  },
771
712
  "indentWidth": {
772
713
  "description": "The number of columns for an indent.",
773
- "default": 2,
774
714
  "type": "number"
775
715
  },
776
716
  "useTabs": {
@@ -994,12 +934,10 @@
994
934
  },
995
935
  "ignoreNodeCommentText": {
996
936
  "description": "The text to use for an ignore comment (ex. `// dprint-ignore`).",
997
- "default": "dprint-ignore",
998
937
  "type": "string"
999
938
  },
1000
939
  "ignoreFileCommentText": {
1001
940
  "description": "The text to use for a file ignore comment (ex. `// dprint-ignore-file`).",
1002
- "default": "dprint-ignore-file",
1003
941
  "type": "string"
1004
942
  },
1005
943
  "forInStatement.useBraces": {
@@ -5,4 +5,4 @@
5
5
  * @param fileText The content of the file.
6
6
  * @returns The formatted text or undefined. It's undefined if the formatter doesn't change the text.
7
7
  */
8
- export declare function format(config: Record<string, any>, filePath: string, fileText: string): string | undefined;
8
+ export declare function format(configFile: string, config: Record<string, any>, filePath: string, fileText: string): string | undefined;
@@ -1,12 +1,36 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.format = void 0;
30
+ const typescript_1 = __importDefault(require("@dprint/typescript"));
7
31
  const debug_1 = __importDefault(require("debug"));
8
32
  const fs_1 = __importDefault(require("fs"));
9
- const typescript_1 = __importDefault(require("@dprint/typescript"));
33
+ const JSONC = __importStar(require("jsonc-parser"));
10
34
  const debug = (0, debug_1.default)("eslint:plugin-dprint");
11
35
  // Load `dprint-plugin-typescript`.
12
36
  const TSPluginPath = typescript_1.default.getPath();
@@ -16,6 +40,7 @@ const TSPlugin = TSPluginInstance.exports;
16
40
  const BufferSize = TSPlugin.get_wasm_memory_buffer_size();
17
41
  /** Cache to reduce copies of config values. */
18
42
  let lastConfig;
43
+ let lastConfigFile;
19
44
  /**
20
45
  * Format the given text with the given config.
21
46
  * @param config The config object.
@@ -23,10 +48,11 @@ let lastConfig;
23
48
  * @param fileText The content of the file.
24
49
  * @returns The formatted text or undefined. It's undefined if the formatter doesn't change the text.
25
50
  */
26
- function format(config, filePath, fileText) {
27
- if (config !== lastConfig) {
28
- lastConfig = config;
29
- writeConfig(config);
51
+ function format(configFile, config, filePath, fileText) {
52
+ if (JSON.stringify(config) !== lastConfig || configFile !== lastConfigFile) {
53
+ lastConfig = JSON.stringify(config);
54
+ lastConfigFile = configFile;
55
+ writeConfig(configFile, config);
30
56
  }
31
57
  writeFilePath(filePath);
32
58
  writeString(fileText);
@@ -45,18 +71,36 @@ function format(config, filePath, fileText) {
45
71
  }
46
72
  }
47
73
  exports.format = format;
74
+ function isConfigAllowedType(value) {
75
+ return ["string", "number", "boolean"].includes(typeof value);
76
+ }
77
+ function extractConfig(config, toConfig) {
78
+ for (const [key, value] of Object.entries(config)) {
79
+ if (isConfigAllowedType(value)) {
80
+ toConfig[key] = value;
81
+ }
82
+ }
83
+ }
48
84
  /**
49
85
  * Write the config to the plugin.
50
86
  * @param config The config object.
51
87
  */
52
- function writeConfig(config) {
88
+ function writeConfig(configFile, config) {
53
89
  TSPlugin.reset_config();
54
90
  // The setting values must be strings.
91
+ const globalConfig = {};
55
92
  const pluginConfig = {};
56
- for (const [key, value] of Object.entries(config)) {
57
- pluginConfig[key] = String(value);
93
+ if ((configFile === null || configFile === void 0 ? void 0 : configFile.length) && fs_1.default.existsSync(configFile)) {
94
+ const configFileContent = fs_1.default.readFileSync(configFile, { encoding: "utf-8" });
95
+ const configFileJson = JSONC.parse(configFileContent);
96
+ extractConfig(configFileJson, globalConfig);
97
+ const typescriptConfig = configFileJson.typescript;
98
+ if (typeof typescriptConfig === "object") {
99
+ extractConfig(typescriptConfig, pluginConfig);
100
+ }
58
101
  }
59
- writeString("{}");
102
+ extractConfig(config, pluginConfig);
103
+ writeString(JSON.stringify(globalConfig));
60
104
  TSPlugin.set_global_config();
61
105
  writeString(JSON.stringify(pluginConfig));
62
106
  TSPlugin.set_plugin_config();
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../lib/dprint/typescript.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAAuC;AACvC,kDAA+B;AAC/B,4CAAmB;AACnB,oDAAqC;AAErC,MAAM,KAAK,GAAG,IAAA,eAAW,EAAC,sBAAsB,CAAC,CAAA;AAOjD,mCAAmC;AACnC,MAAM,YAAY,GAAG,oBAAM,CAAC,OAAO,EAAE,CAAA;AACrC,MAAM,cAAc,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,YAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAA;AAC5E,MAAM,gBAAgB,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;AACrE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,CAAA;AACzC,MAAM,UAAU,GAAG,QAAQ,CAAC,2BAA2B,EAAE,CAAA;AAEzD,+CAA+C;AAC/C,IAAI,UAA8B,CAAA;AAClC,IAAI,cAAkC,CAAA;AAEtC;;;;;;GAMG;AACH,SAAgB,MAAM,CAClB,UAAkB,EAClB,MAA2B,EAC3B,QAAgB,EAChB,QAAgB;IAEhB,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,UAAU,IAAI,UAAU,KAAK,cAAc,EAAE;QACxE,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QACnC,cAAc,GAAG,UAAU,CAAA;QAC3B,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;KAClC;IACD,aAAa,CAAC,QAAQ,CAAC,CAAA;IAEvB,WAAW,CAAC,QAAQ,CAAC,CAAA;IACrB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AG,KAAK,EAAE,UAAU,CAAC,CAAA;QAEvD,MAAM,CAAC,IAAI,CACP,IAAI,UAAU,CACV,QAAQ;aACH,MAAM;aACN,MAAM,EACX,QAAQ,CAAC,sBAAsB,EAAE,EACjC,UAAU,CACb,EACD,CAAC,EACD,KAAK,EACL,KAAK,GAAG,UAAU,CACrB,CAAA;QACD,QAAQ,CAAC,+BAA+B,CAAC,UAAU,CAAC,CAAA;QAEpD,KAAK,IAAI,UAAU,CAAA;KACtB;AACL,CAAC;AAED;;;;GAIG;AACH,SAAS,UAAU,CAAC,MAAc;IAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IAEzC,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,OAAO,KAAK,GAAG,MAAM,EAAE;QACnB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,KAAK,EAAE,UAAU,CAAC,CAAA;QACtD,QAAQ,CAAC,4BAA4B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QAEvD,MAAM,CAAC,GAAG,CACN,IAAI,UAAU,CACV,QAAQ;aACH,MAAM;aACN,MAAM,EACX,QAAQ,CAAC,sBAAsB,EAAE,EACjC,SAAS,CACZ,EACD,KAAK,CACR,CAAA;QAED,KAAK,IAAI,SAAS,CAAA;KACrB;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAClC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const dprint: ESLintUtils.RuleModule<"requireLinebreak" | "extraLinebreak" | "requireWhitespace" | "extraWhitespace" | "requireCode" | "extraCode" | "replaceWhitespace" | "replaceCode" | "moveCodeToNextLine" | "moveCodeToPrevLine" | "moveCode", {
3
+ configFile: string;
4
+ config: {};
5
+ }[], ESLintUtils.RuleListener>;
@@ -118,26 +118,35 @@ exports.dprint = createRule({
118
118
  type: "array",
119
119
  items: [{
120
120
  type: "object",
121
- properties: { config: config_schema_json_1.default },
121
+ properties: {
122
+ configFile: {
123
+ type: "string",
124
+ default: "dprint.json",
125
+ description: "dprint configuration file (default 'dprint.json')",
126
+ },
127
+ config: config_schema_json_1.default,
128
+ },
122
129
  additionalProperties: false,
123
130
  }],
124
131
  additionalItems: false,
125
132
  },
126
133
  type: "layout",
127
134
  },
128
- defaultOptions: [{ config: {} }],
135
+ defaultOptions: [{ configFile: "dprint.json", config: {} }],
129
136
  create: (context, options) => ({
130
137
  Program() {
138
+ var _a;
131
139
  const sourceCode = context.getSourceCode();
132
140
  const filePath = context.getFilename();
133
141
  const fileText = sourceCode.getText();
142
+ const configFile = (_a = options[0].configFile) !== null && _a !== void 0 ? _a : "dprint.json";
134
143
  const config = options[0].config || {};
135
144
  // Needs an absolute path
136
145
  if (!filePath || !path_1.default.isAbsolute(filePath)) {
137
146
  return;
138
147
  }
139
148
  // Does format
140
- const formattedText = (0, typescript_1.format)(config, filePath, fileText);
149
+ const formattedText = (0, typescript_1.format)(configFile, config, filePath, fileText);
141
150
  if (typeof formattedText !== "string") {
142
151
  return;
143
152
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dprint.js","sourceRoot":"","sources":["../../../lib/rules/dprint.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAgE;AAChE,gDAAuB;AACvB,sFAAuD;AACvD,qDAA6C;AAC7C,qEAAsE;AACtE,iDAA8D;AAY9D,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAClD,wEAAwE,QAAQ,KAAK,CACxF,CAAA;AAED;;;GAGG;AACH,SAAS,wBAAwB,CAAC,CAAS;IACvC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACzB,IAAI,CAAC,CAAC,EAAE;QACJ,OAAO,CAAC,CAAA;KACX;IAED,MAAM,SAAS,GAAG,eAAe,CAAA;IACjC,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,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GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;gBAE5C,OAAO,CAAC,MAAM,CAAC;oBACX,GAAG;oBACH,SAAS;oBACT,IAAI;oBAEJ,GAAG,CAAC,KAAK;wBACL,MAAM,KAAK,GAAG,CAAC,CAAC,KAAyB,CAAA;wBACzC,IAAI,CAAC,CAAC,IAAI,KAAK,KAAK,EAAE;4BAClB,OAAO,KAAK,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;yBACtD;wBACD,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;4BACrB,OAAO,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;yBAClC;wBACD,OAAO,KAAK,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;oBACnD,CAAC;iBACJ,CAAC,CAAA;aACL;QACL,CAAC;KACJ,CAAC;CACL,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,33 +1,32 @@
1
1
  {
2
2
  "name": "@ben_12/eslint-plugin-dprint",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "An ESLint plugin that fixes code with dprint",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
7
7
  },
8
- "main": "lib/index.js",
8
+ "main": "dist/lib/index.js",
9
9
  "type": "commonjs",
10
10
  "files": [
11
- "lib"
11
+ "dist"
12
12
  ],
13
13
  "peerDependencies": {
14
14
  "eslint": ">=5.16.0"
15
15
  },
16
16
  "dependencies": {
17
- "@dprint/typescript": "^0.87.1",
17
+ "@dprint/typescript": "^0.88.1",
18
18
  "debug": "^4.1.1",
19
- "diff": "^4.0.2"
19
+ "diff": "^5.0.0",
20
+ "jsonc-parser": "^3.2.0"
20
21
  },
21
22
  "devDependencies": {
22
- "@ben_12/eslint-plugin-dprint": "^0.6.0",
23
+ "@ben_12/eslint-plugin-dprint": "^0.6.1",
23
24
  "@types/debug": "^4.1.5",
24
25
  "@types/diff": "^5.0.0",
25
26
  "@types/node": "^18.0.0",
26
- "@types/rimraf": "^4.0.0",
27
27
  "@typescript-eslint/eslint-plugin": "^6.0.0",
28
28
  "@typescript-eslint/parser": "^6.0.0",
29
29
  "@typescript-eslint/utils": "^6.0.0",
30
- "codecov": "^3.7.0",
31
30
  "eslint": "^8.50.0",
32
31
  "mocha": "^10.0.0",
33
32
  "nyc": "^15.0.1",
@@ -37,7 +36,7 @@
37
36
  "typescript": "~5.0.0"
38
37
  },
39
38
  "scripts": {
40
- "build": "rimraf dist && tsc -p tsconfig.build.json && shx cp \"{LICENSE,README.md,package.json}\" dist",
39
+ "build": "rimraf dist && tsc -p tsconfig.build.json",
41
40
  "codecov": "nyc report --reporter text-lcov | codecov --pipe --disable=gcov",
42
41
  "lint": "eslint --rulesdir scripts/internal-rules \"**/*.ts\"",
43
42
  "test": "npm run -s lint && npm run -s test:ci",
@@ -51,6 +50,10 @@
51
50
  "type": "git",
52
51
  "url": "git+https://github.com/ben12/eslint-plugin-dprint.git"
53
52
  },
53
+ "publishConfig": {
54
+ "registry": "https://registry.npmjs.org",
55
+ "access": "public"
56
+ },
54
57
  "keywords": [
55
58
  "eslint",
56
59
  "eslintplugin",
@@ -61,6 +64,5 @@
61
64
  "bugs": {
62
65
  "url": "https://github.com/ben12/eslint-plugin-dprint/issues"
63
66
  },
64
- "homepage": "https://github.com/ben12/eslint-plugin-dprint#readme",
65
- "funding": "https://github.com/sponsors/ben12"
67
+ "homepage": "https://eslint-plugin-dprint.ben12.eu"
66
68
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../lib/dprint/typescript.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA+B;AAC/B,4CAAmB;AACnB,oEAAuC;AAEvC,MAAM,KAAK,GAAG,IAAA,eAAW,EAAC,sBAAsB,CAAC,CAAA;AAKjD,mCAAmC;AACnC,MAAM,YAAY,GAAG,oBAAM,CAAC,OAAO,EAAE,CAAA;AACrC,MAAM,c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C,CAAA;QAEpD,KAAK,IAAI,UAAU,CAAA;KACtB;AACL,CAAC;AAED;;;;GAIG;AACH,SAAS,UAAU,CAAC,MAAc;IAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IAEzC,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,OAAO,KAAK,GAAG,MAAM,EAAE;QACnB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,KAAK,EAAE,UAAU,CAAC,CAAA;QACtD,QAAQ,CAAC,4BAA4B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QAEvD,MAAM,CAAC,GAAG,CACN,IAAI,UAAU,CACV,QAAQ;aACH,MAAM;aACN,MAAM,EACX,QAAQ,CAAC,sBAAsB,EAAE,EACjC,SAAS,CACZ,EACD,KAAK,CACR,CAAA;QAED,KAAK,IAAI,SAAS,CAAA;KACrB;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAClC,CAAC"}
@@ -1,4 +0,0 @@
1
- import { TSESLint } from "@typescript-eslint/utils";
2
- export declare const dprint: TSESLint.RuleModule<"requireLinebreak" | "extraLinebreak" | "requireWhitespace" | "extraWhitespace" | "requireCode" | "extraCode" | "replaceWhitespace" | "replaceCode" | "moveCodeToNextLine" | "moveCodeToPrevLine" | "moveCode", {
3
- config: {};
4
- }[], TSESLint.RuleListener>;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes