Skip to content

Commit 05df862

Browse files
committed
[hygiene] prettier-plugin-organize-imports
1 parent 78f3e9a commit 05df862

5 files changed

Lines changed: 8339 additions & 935 deletions

File tree

.prettierrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"singleQuote": true,
44
"trailingComma": "all",
55
"plugins": [
6-
"@trivago/prettier-plugin-sort-imports"
7-
],
8-
"importOrderSortSpecifiers": true
6+
"prettier-plugin-organize-imports"
7+
]
98
}

cspell.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@
168168
"Todos",
169169
"TODOS",
170170
"transpilations",
171-
"trivago",
172171
"Turso",
173172
"typeof",
174173
"uirc",

gulpfile.mjs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,22 @@ const lintCheckFiles = async (dir) => {
304304
const prettierConfig = await getPrettierConfig();
305305

306306
const filePaths = [];
307-
['.js', '.d.ts'].forEach((extension) =>
307+
['.ts', '.tsx', '.js', '.d.ts'].forEach((extension) =>
308308
forEachDeepFile(dir, (filePath) => filePaths.push(filePath), extension),
309309
);
310310
await allOf(filePaths, async (filePath) => {
311311
const code = await promises.readFile(filePath, UTF8);
312312
if (
313313
!(await prettier.check(code, {...prettierConfig, filepath: filePath}))
314314
) {
315-
throw `${filePath} not pretty`;
315+
writeFileSync(
316+
filePath,
317+
await prettier.format(
318+
code,
319+
{...prettierConfig, filepath: filePath},
320+
UTF8,
321+
),
322+
);
316323
}
317324
});
318325

@@ -359,33 +366,27 @@ const lintCheckDocs = async (dir) => {
359366
);
360367
await allOf(filePaths, async (filePath) => {
361368
const code = await promises.readFile(filePath, UTF8);
362-
if (
363-
!(await prettier.check(code, {...prettierConfig, filepath: filePath}))
364-
) {
365-
throw `${filePath} not pretty`;
366-
}
367369
await allOf(
368370
[...(code.matchAll(LINT_BLOCKS) ?? [])],
369371
async ([_, hint, docBlock]) => {
370372
if (hint?.trim() == 'override') {
371373
return; // can't lint orphaned TS methods
372374
}
373375
const code = docBlock.replace(/\n +\* ?/g, '\n').trimStart();
376+
let pretty = code;
374377
if (!(await prettier.check(code, docConfig))) {
375-
const pretty = (await prettier.format(code, docConfig))
376-
.trim()
377-
.split('\n')
378-
.map((line) => (line == '' ? ' *' : ' * ' + line))
379-
.join('\n');
380-
// eslint-disable-next-line no-console
381-
console.log(
382-
`${filePath} not pretty:\n${code}\n\nShould be:\n${pretty}\n`,
383-
);
378+
pretty = await prettier.format(code, docConfig);
384379
writeFileSync(
385380
filePath,
386381
readFileSync(filePath, UTF8).replace(
387382
docBlock,
388-
'\n' + pretty + '\n * ',
383+
'\n' +
384+
pretty
385+
.trim()
386+
.split('\n')
387+
.map((line) => (line == '' ? ' *' : ' * ' + line))
388+
.join('\n') +
389+
'\n * ',
389390
),
390391
UTF8,
391392
);
@@ -691,7 +692,7 @@ export const lintFiles = async () => {
691692
await lintCheckFiles('site');
692693
};
693694
export const lintDocs = async () => await lintCheckDocs('src');
694-
export const lint = parallel(lintFiles, lintDocs);
695+
export const lint = series(lintDocs, lintFiles);
695696

696697
export const spell = async () => {
697698
await spellCheck('.');
@@ -777,4 +778,4 @@ export const prePublishPackage = series(
777778
testE2e,
778779
);
779780

780-
export const publishPackage = series(prePublishPackage, npmPublish);
781+
export const publishPackage = series(prePublishPackage, npmPublish);

0 commit comments

Comments
 (0)