From 34f08512ac1d0e791f18f594d6b9041b4dbbabf4 Mon Sep 17 00:00:00 2001 From: rrd108 Date: Wed, 4 Sep 2024 16:45:06 +0200 Subject: [PATCH] chore lint fix --- src/helpers/validateOption.ts | 2 +- src/index.test.ts | 9 +++++---- src/index.ts | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/helpers/validateOption.ts b/src/helpers/validateOption.ts index 684d19f1..4a2e44e5 100644 --- a/src/helpers/validateOption.ts +++ b/src/helpers/validateOption.ts @@ -15,7 +15,7 @@ export const validateOption = (value: T, flag: Flag) => { if (!Array.isArray(validOptions) || !validOptions.includes(value as any)) { console.error( `\nInvalid option ${BG_ERR}${value}${BG_RESET} provided for flag ${TEXT_INFO}${flag}${TEXT_RESET}. Valid options are: ${BG_INFO}${validOptions.join(', ')}${BG_RESET}.\n`, - ); + ) // eslint-disable-next-line node/prefer-global/process process.exit(1) } diff --git a/src/index.test.ts b/src/index.test.ts index 517dc496..c42e7375 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -93,17 +93,17 @@ describe('yarn analyze command with default configuration', () => { expect(stdout).toContain(`Analyzing Vue, TS and JS files in`) expect(stdout).toContain(`codeHealthOutput`) }) - + it('should execute with group parameter', async () => { const { stdout } = await execa('yarn', ['analyze', './src/rules/vue-caution', '--group=file']) expect(stdout).toContain(`- ${TEXT_INFO} src/rules/vue-caution/elementSelectorsWithScoped.ts${TEXT_RESET}`) }) - + it('should execute with sort parameter', async () => { const { stdout } = await execa('yarn', ['analyze', '--sort=asc']) expect(stdout).toContain(`Analyzing Vue, TS and JS files in`) }) - + it('should execute with level parameter', async () => { const { stdout } = await execa('yarn', ['analyze', '--level=error']) expect(stdout).toContain(`Analyzing Vue, TS and JS files in`) @@ -125,7 +125,8 @@ describe('yarn analyze command with default configuration', () => { await execa('yarn', ['analyze', '--output=gauranga']) // If the command doesn't throw, fail the test expect(true).toBe(false) - } catch (error) { + } + catch (error) { expect((error as any).stderr).toContain(`Invalid option ${BG_ERR}gauranga${BG_RESET} provided for flag ${TEXT_INFO}outputFormat${TEXT_RESET}. Valid options are: ${BG_INFO}text, json, table${BG_RESET}.`) } }) diff --git a/src/index.ts b/src/index.ts index 618ce4a3..7e8b36e9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,12 +6,12 @@ import Table from 'cli-table3' import { analyze } from './analyzer' import { BG_ERR, BG_RESET, TEXT_INFO, TEXT_RESET } from './rules/asceeCodes' import { RULESETS } from './rules/rules' -import type { GroupBy, SortBy, OutputFormat, OutputLevel } from './types' +import type { GroupBy, OutputFormat, OutputLevel, SortBy } from './types' import { validateOption } from './helpers/validateOption' import getProjectRoot from './helpers/getProjectRoot' import coerceRules from './helpers/coerceRules' import { FLAT_RULESETS_RULES } from './helpers/constants' -import { GROUP_BY, SORT_BY, OUTPUT_FORMATS, OUTPUT_LEVELS } from './types' +import { GROUP_BY, OUTPUT_FORMATS, OUTPUT_LEVELS, SORT_BY } from './types' import { getPackageJson } from './helpers/getPackageJson' // eslint-disable-next-line node/prefer-global/process