Skip to content

Commit

Permalink
Fix type and lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Mar 22, 2024
1 parent 71b511d commit eeb307e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/utils/stylelint/process-linter-result.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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: [] };
Expand All @@ -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;
},
},
Expand All @@ -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 };
}

0 comments on commit eeb307e

Please sign in to comment.