/
examples.test.js.snap
597 lines (471 loc) · 14.6 KB
/
examples.test.js.snap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`examples 1.spaces.just-sort.js 1`] = `
// The spacing inside \`{…}\` might look a bit weird after sorting:
import {bar, baz,foo} from "example";
// The indentation (tabs) will be kept here:
import {
DocumentNode,
FieldNode,
FragmentDefinitionNode,
FragmentSpreadNode,
InlineFragmentNode,
OperationDefinitionNode,
SelectionSetNode,
} from "../language/ast";
`;
exports[`examples 2.spaces.eslint-builtin.js 1`] = `
// This file uses other ESLint rules to fix the spacing inside \`{…}\`:
import {bar, baz, foo} from "example";
// And the “indent” rule changes these tabs to 4 spaces:
import {
DocumentNode,
FieldNode,
FragmentDefinitionNode,
FragmentSpreadNode,
InlineFragmentNode,
OperationDefinitionNode,
SelectionSetNode,
} from "../language/ast";
`;
exports[`examples 3.spaces.prettier.js 1`] = `
// This file uses Prettier to fix the spacing inside \`{…}\`:
import { bar, baz, foo } from "example";
// And Prettier will also change these tabs to 2 spaces:
import {
DocumentNode,
FieldNode,
FragmentDefinitionNode,
FragmentSpreadNode,
InlineFragmentNode,
OperationDefinitionNode,
SelectionSetNode,
} from "../language/ast";
`;
exports[`examples eslint-plugin-import.js 1`] = `
// This file uses rules from eslint-plugin-import
// (https://github.com/benmosher/eslint-plugin-import/) if you want hoist
// imports to the top, add a blank line after them and merge duplicates.
import "z";
import a from "a";
import b, {b1, b2,b3} from "b";
foo();
bar();
`;
exports[`examples groups.custom.js 1`] = `
import assert from "assert";
import fs from "fs";
import react from "react";
import Select from "react-select"
import _ from "lodash"
import Textarea from "@/ui/Textarea"
import {name} from "@company/config"
import Button from "@ui/Button";
import Label from "components/Label"
import {API_URL} from "config";
import {pluralize} from "utils/string"
import VendoredLib from "vendored-lib"
import createWrapper from "vendored-lib/lib/create-wrapper"
import "./local-polyfill"
import "polyfill-package"
import cssGlobals from "../../css/globals"
import {removeWhitespace,truncate} from "../../utils";
import {CATEGORIES} from "../"
import now from "./time/now"
import tomorrow from "./time/tomorrow"
import {providers} from "./providers"
import {PRODUCT_NAMES} from "."
import "./global.scss"
import "../../alert.css"
import circleStyles from "./circle.scss";
import styles from "./styles.scss";
`;
exports[`examples groups.default-reverse.js 1`] = `
import styles from "./styles";
import config from "/config";
import App from "@/App";
import { storiesOf } from "@storybook/react";
import fs2 from "fs";
import forge from "node-forge";
import react from "react";
import * as fs from "node:fs";
import "./polyfills";
`;
exports[`examples groups.no-blank-lines.js 1`] = `
import classnames from "classnames";
import PropTypes from "prop-types";
import React from "react";
import { getUser } from "../../api";
import { User } from "../../types";
import { formatNumber,truncate } from "../../utils";
import Button from "../Button";
import styles from "./styles.css";
`;
exports[`examples groups.none.js 1`] = `
import styles from "./styles";
import config from "/config";
import App from "@/App";
import { storiesOf } from "@storybook/react";
import * as fs from "node:fs";
import react from "react";
`;
exports[`examples groups.type-imports-first.ts 1`] = `
import type { Page } from "./page";
import type { Css } from "./styles";
import type { Config } from "/config";
import type { AppRouter } from "@/App";
import type { Story } from "@storybook/react";
import type { Dirent } from "node:fs";
import type { ParsedPath } from "node:path";
import type { Component } from "react";
import type { Store } from "redux";
import "./polyfills";
import fs from "node:fs";
import * as path from "node:path";
import { storiesOf } from "@storybook/react";
import react from "react";
import config from "/config";
import App from "@/App";
import page from "./page";
import styles from "./styles";
`;
exports[`examples groups.type-imports-first-in-each-group.ts 1`] = `
import "./polyfills";
import type { Dirent } from "node:fs";
import type { ParsedPath } from "node:path";
import fs from "node:fs";
import * as path from "node:path";
import type { Story } from "@storybook/react";
import type { Component } from "react";
import type { Store } from "redux";
import { storiesOf } from "@storybook/react";
import react from "react";
import type { Config } from "/config";
import type { AppRouter } from "@/App";
import config from "/config";
import App from "@/App";
import type { Page } from "./page";
import type { Css } from "./styles";
import page from "./page";
import styles from "./styles";
`;
exports[`examples groups.type-imports-first-sorted.ts 1`] = `
import type { Dirent } from "node:fs";
import type { ParsedPath } from "node:path";
import type { Story } from "@storybook/react";
import type { Component } from "react";
import type { Store } from "redux";
import type { Config } from "/config";
import type { AppRouter } from "@/App";
import type { Page } from "./page";
import type { Css } from "./styles";
import "./polyfills";
import fs from "node:fs";
import * as path from "node:path";
import { storiesOf } from "@storybook/react";
import react from "react";
import config from "/config";
import App from "@/App";
import page from "./page";
import styles from "./styles";
`;
exports[`examples groups.type-imports-last.ts 1`] = `
import "./polyfills";
import fs from "node:fs";
import * as path from "node:path";
import { storiesOf } from "@storybook/react";
import react from "react";
import config from "/config";
import App from "@/App";
import page from "./page";
import styles from "./styles";
import type { Page } from "./page";
import type { Css } from "./styles";
import type { Config } from "/config";
import type { AppRouter } from "@/App";
import type { Story } from "@storybook/react";
import type { Dirent } from "node:fs";
import type { ParsedPath } from "node:path";
import type { Component } from "react";
import type { Store } from "redux";
`;
exports[`examples groups.type-imports-last-in-each-group.ts 1`] = `
import "./polyfills";
import fs from "node:fs";
import * as path from "node:path";
import type { Dirent } from "node:fs";
import type { ParsedPath } from "node:path";
import { storiesOf } from "@storybook/react";
import react from "react";
import type { Story } from "@storybook/react";
import type { Component } from "react";
import type { Store } from "redux";
import config from "/config";
import App from "@/App";
import type { Config } from "/config";
import type { AppRouter } from "@/App";
import page from "./page";
import styles from "./styles";
import type { Page } from "./page";
import type { Css } from "./styles";
`;
exports[`examples groups.type-imports-last-sorted.ts 1`] = `
import "./polyfills";
import fs from "node:fs";
import * as path from "node:path";
import { storiesOf } from "@storybook/react";
import react from "react";
import config from "/config";
import App from "@/App";
import page from "./page";
import styles from "./styles";
import type { Dirent } from "node:fs";
import type { ParsedPath } from "node:path";
import type { Story } from "@storybook/react";
import type { Component } from "react";
import type { Store } from "redux";
import type { Config } from "/config";
import type { AppRouter } from "@/App";
import type { Page } from "./page";
import type { Css } from "./styles";
`;
exports[`examples ignore.js 1`] = `
// First off, imports that are only used for side effects stay in the input
// order. These won’t be sorted:
import "b";
import "a";
// Just to separate the chunks of imports for this example. Move along.
separator();
// You can also disable sorting for a whole chunk. The actual rule name is
// "simple-import-sort/imports", but for technical reasons it’s just called
// "imports" within the examples of this repo.
// For copying: eslint-disable-next-line simple-import-sort/imports
// eslint-disable-next-line imports
import d from "d";
import c from "c";
// Note that putting a \`eslint-disable-next-line simple-import-sort/imports\`
// comment in the middle of a chunk of imports WON’T WORK. It HAS to be at the
// very start!
separator();
// If you want to both import something from a module _and_ import it for its
// side effects _and_ you need it to run before other things, but don’t want to
// disable sorting altogether, there’s a workaround. Import it twice – once for
// side effects, once for the thing you want to import from it. You might need
// to disable some “no duplicate imports” rules if you use them.
// eslint-disable-next-line import/no-duplicates
import "side-effects";
import Other from "another";
// eslint-disable-next-line no-duplicate-imports, import/no-duplicates
import Thing from "side-effects";
// The above two lines will still be sorted after autofixing! This can be
// especially useful for long chunks of imports, where you don’t want one little
// edge case disable sorting for the whole thing. Even better is to try to fix
// the issue with the side effects – relying on import order is pretty brittle.
// If all else fails, you can use this trick of inserting code between imports
// to separate chunks of imports.
separator();
`;
exports[`examples markdown.md 1`] = `
# Markdown
\`\`\`js
import a1 from "a";
import b1 from "b"
\`\`\`
Some text.
\`\`\`js
code();
import a2 from "a";
import b2 from "b";
code()
import c2 from "c";
import d2 from "d"
import e2 from "e";
;[].forEach()
\`\`\`
- Item 1.
- Item 2.
\`\`\`js
import a3 from "a"
import b3 from "b"
\`\`\`
End text.
`;
exports[`examples prettier-comments.js 1`] = `
// This is just a test to make sure that this plugin plays well with Prettier.
import def, { // start
/*c
*/
c,
d /*d*/,
e,
// f
f, // f
// end
} from "s";
import { /* start */ a, /*a*/ b /*b*/ } from "t";
`;
exports[`examples readme-comments.js 1`] = `
// comment before import chunk
// a1
/* a2
*/ import a /* a3 */ from "a"; /* a4 */
// b1
import b from "b"; // b2
/* c1 */ import c from "c"; // c2
/* not-a
*/ // comment after import chunk
`;
exports[`examples readme-comments-items.js 1`] = `
import { // comment at start
/* a1
*/ a,
// b1
b as /* b2 */ renamed
, /* b3 */
/* c1 */ c /* c2 */// c3
/* not-a
*/ // comment at end
} from "wherever";
import {
d, /* d */ e,
/* not-d
*/ // comment at end after trailing comma
} from "wherever2";
import {/* comment at start */ f, /* f */g/* g */ } from "wherever3";
`;
exports[`examples readme-example.prettier.ts 1`] = `
import classnames from "classnames";
import PropTypes from "prop-types";
import React from "react";
import { getUser } from "../../api";
import type { User } from "../../types";
import { formatNumber, truncate } from "../../utils";
import Button from "../Button";
import styles from "./styles.css";
`;
exports[`examples readme-exports-grouping.prettier.js 1`] = `
export * from "x";
export * from "y";
// This comment starts a new group.
/* This one does not. */ export * from "a"; // Neither does this one.
/* Nor this
one */ export * from "b";
/* But this one does. */
export * from "./";
`;
exports[`examples readme-exports-grouping-less-comments.prettier.js 1`] = `
export * from "./";
/* This one does not. */ export * from "a"; // Neither does this one.
/* Nor this
one */ export * from "b";
export * from "x";
export * from "y";
`;
exports[`examples readme-order.prettier.ts 1`] = `
// Side effect imports. (These are not sorted internally.)
import "./setup";
import "some-polyfill";
import "./global.css";
// Node.js builtins prefixed with \`node:\`.
import * as fs from "node:fs";
// Packages.
import type A from "an-npm-package";
import a from "an-npm-package";
import fs2 from "fs";
import b from "https://example.com/script.js";
// Absolute imports and other imports.
import c from "/";
import d from "/home/user/foo";
import Error from "@/components/error.vue";
// Relative imports.
import e from "../..";
import type { B } from "../types";
import f from "../Utils"; // Case insensitive.
import g from ".";
import h from "./constants";
import i from "./styles";
// Different types of exports:
export { a } from "../..";
export { b } from "/";
export { Error } from "@/components/error.vue";
export * from "an-npm-package";
export { readFile } from "fs";
export * as ns from "https://example.com/script.js";
// This comment groups some more exports:
export { e } from "../..";
export { f } from "../Utils";
export { g } from ".";
export { h } from "./constants";
export { i } from "./styles";
// Other exports – the plugin does not touch these, other than sorting named
// exports inside braces.
export var one = 1;
export let two = 2;
export const three = 3;
export function func() {}
export class Class {}
export type Type = string;
export { named, other as renamed };
export type { T, U as V };
export default whatever;
`;
exports[`examples readme-order-items.prettier.ts 1`] = `
import {
// Numbers are sorted by their numeric value:
img1,
img2,
img10,
// Then everything else, alphabetically:
k,
L, // Case insensitive.
m as anotherName, // Sorted by the “external interface” name “m”, not “anotherName”.
m as tie, // But do use the file-local name in case of a tie.
// Types are sorted as if the \`type\` keyword wasn’t there.
type x,
y,
} from "./x";
export {
k,
L, // Case insensitive.
anotherName as m, // Sorted by the “external interface” name “m”, not “anotherName”.
// tie as m, // For exports there can’t be ties – all exports must be unique.
// Types are sorted as if the \`type\` keyword wasn’t there.
type x,
y,
};
export type { A, B, A as C };
var k_, L_, anotherName_, n_;
type A = 1;
type B = 1;
`;
exports[`examples typescript.ts 1`] = `
import classnames from "classnames";
import PropTypes from "prop-types";
import React from "react";
import { getUser } from "../../api";
import { formatNumber,truncate } from "../../utils";
import Button from "../Button";
import styles from "./styles.css";
// The above is the same as readme-example.prettier.js. The below function is here to
// make sure that this file isn’t both valid JS and valid TS, forcing the need
// for \`@typescript-eslint/parser\`.
function pluck<T, K extends keyof T>(o: T, names: K[]): T[K][] {
return names.map(n => o[n]);
}
`;
exports[`examples vue.vue 1`] = `
<script lang="ts">
/* a */ import a from "a";
// b
import {
b2,
b3,
b4 } from "b";
import c from "c"
// d
import d from "d"
import e from "e"
// Comment for vue-property-decorator
import { Component, Vue, Watch } from 'vue-property-decorator';
import { Location } from 'vue-router';
</script>
`;