From eeb307e02afa5c54fbcffb20013e2c30ee6ecf54 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Sat, 23 Mar 2024 01:29:53 +0900 Subject: [PATCH] Fix type and lint errors --- src/utils/stylelint/process-linter-result.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/utils/stylelint/process-linter-result.ts b/src/utils/stylelint/process-linter-result.ts index 615cc10d..4d765076 100644 --- a/src/utils/stylelint/process-linter-result.ts +++ b/src/utils/stylelint/process-linter-result.ts @@ -1,8 +1,7 @@ import { warningToDiagnostic } from './warning-to-diagnostic'; // eslint-disable-next-line n/no-unpublished-import -import type stylelint from 'stylelint'; -import { LintDiagnostics, InvalidOptionError } from './types'; -import { Stylelint } from './types'; +import type { LinterResult } from 'stylelint'; +import { type LintDiagnostics, type Stylelint, InvalidOptionError } from './types'; /** * Processes the results of a Stylelint lint run. @@ -18,7 +17,7 @@ import { Stylelint } from './types'; */ export function processLinterResult( stylelint: Stylelint, - { results, output, ruleMetadata }: stylelint.LinterResult, + { results, output, ruleMetadata }: LinterResult, ): LintDiagnostics { if (results.length === 0) { return { diagnostics: [] }; @@ -40,6 +39,10 @@ export function processLinterResult( {}, { get: (_, key: string) => { + // @ts-expect-error -- (TS7053) `stylelint.rules` has returned `Promise` values since v16. + // See https://stylelint.io/migration-guide/to-16#changed-nodejs-api-stylelintrules-object + // + // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access return stylelint.rules?.[key]?.meta; }, }, @@ -48,5 +51,5 @@ export function processLinterResult( const diagnostics = warnings.map((warning) => warningToDiagnostic(warning, ruleMetadata)); - return output ? { output: output as string, diagnostics } : { diagnostics }; + return output ? { output, diagnostics } : { diagnostics }; }