MCPcopy Index your code
hub / github.com/tinyplex/tinybase / lintCheckFiles

Function lintCheckFiles

gulpfile.mjs:368–399  ·  view source on GitHub ↗
(dir)

Source from the content-addressed store, hash-verified

366};
367
368const lintCheckFiles = async (dir) => {
369 const {default: prettier} = await import('prettier');
370 const prettierConfig = await getPrettierConfig();
371
372 const filePaths = [];
373 ['.ts', '.tsx', '.js', '.d.ts', '.svelte'].forEach((extension) =>
374 forEachDeepFile(dir, (filePath) => filePaths.push(filePath), extension),
375 );
376 await allOf(filePaths, async (filePath) => {
377 const fileConfig = filePath.endsWith('.svelte')
378 ? {...prettierConfig, filepath: filePath, parser: undefined}
379 : {...prettierConfig, filepath: filePath};
380 const code = await promises.readFile(filePath, UTF8);
381 if (!(await prettier.check(code, fileConfig))) {
382 writeFileSync(filePath, await prettier.format(code, fileConfig), UTF8);
383 }
384 });
385
386 const {
387 default: {ESLint},
388 } = await import('eslint');
389 const esLint = new ESLint({});
390 const results = await esLint.lintFiles([dir]);
391 if (
392 results.filter((result) => result.errorCount > 0 || result.warningCount > 0)
393 .length > 0
394 ) {
395 const formatter = await esLint.loadFormatter();
396 const errors = await formatter.format(results);
397 throw errors;
398 }
399};
400
401const lintCheckDocs = async (dir) => {
402 const {

Callers 1

lintFilesFunction · 0.85

Calls 3

getPrettierConfigFunction · 0.85
allOfFunction · 0.85
forEachDeepFileFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…