From 873f25e9d52f15a7cde1d5b5fc94b3646aec7871 Mon Sep 17 00:00:00 2001 From: Dirk de Visser Date: Tue, 8 Oct 2024 10:54:06 +0200 Subject: [PATCH] feat: cleanup file-progress spinner output Closes #265 Signed-off-by: Dirk de Visser --- packages/eslint-config/src/index.ts | 15 ++-------- packages/eslint-config/src/progress.ts | 39 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 packages/eslint-config/src/progress.ts diff --git a/packages/eslint-config/src/index.ts b/packages/eslint-config/src/index.ts index 045393c..3e8dabf 100644 --- a/packages/eslint-config/src/index.ts +++ b/packages/eslint-config/src/index.ts @@ -1,7 +1,5 @@ import type { FlatConfig } from "@typescript-eslint/utils/ts-eslint"; import gitignore from "eslint-config-flat-gitignore"; -// @ts-expect-error no types available -import pluginFileProgress from "eslint-plugin-file-progress"; import { defineGlobals } from "./globals.js"; import type { GlobalsConfig } from "./globals.js"; import { globUseFromUserConfig } from "./globs.js"; @@ -10,6 +8,7 @@ import { javascript } from "./javascript.js"; import { markdownConfig, markdownSnippetOverrides } from "./markdown.js"; import { prettierConfig } from "./prettier.js"; import type { PrettierConfig } from "./prettier.js"; +import { progress } from "./progress.js"; import type { ReactConfig } from "./react.js"; import { typescript, typescriptResolveConfig } from "./typescript.js"; import type { TypeScriptConfig } from "./typescript.js"; @@ -52,17 +51,7 @@ export async function defineConfig( }, }, ...defineGlobals(opts.globals), - - { - // Show a friendly spinner. - files: ["**/*"], - plugins: { - "file-progress": pluginFileProgress as unknown as FlatConfig.Plugin, - }, - rules: { - "file-progress/activate": "warn", - }, - }, + ...progress(), // Language specifics ...markdownConfig(), diff --git a/packages/eslint-config/src/progress.ts b/packages/eslint-config/src/progress.ts new file mode 100644 index 0000000..27d5124 --- /dev/null +++ b/packages/eslint-config/src/progress.ts @@ -0,0 +1,39 @@ +import type { FlatConfig } from "@typescript-eslint/utils/ts-eslint"; +// @ts-expect-error no types available +import pluginFileProgress from "eslint-plugin-file-progress"; +import { globMarkdownSnippetFromGlob, globUse } from "./globs.js"; + +export function progress(): Array { + if (process.env.CI === "true") { + return []; + } + + return [ + { + // Show a friendly spinner. + files: ["**/*"], + plugins: { + "file-progress": pluginFileProgress as unknown as FlatConfig.Plugin, + }, + rules: { + "file-progress/activate": "warn", + }, + }, + + { + // Don't show snippets in the progress-spinner. + files: globUse([globMarkdownSnippetFromGlob("**/*")]), + rules: { + "file-progress/activate": "off", + }, + }, + + { + // Don't show virtual format files in the progress-spinner. + files: ["**/*.*/**/*.format"], + rules: { + "file-progress/activate": "off", + }, + }, + ]; +}