diff --git a/packages/browser-pyright/src/browserWorkersHost.ts b/packages/browser-pyright/src/browserWorkersHost.ts index cbaeffaa43..94afe3bfc4 100644 --- a/packages/browser-pyright/src/browserWorkersHost.ts +++ b/packages/browser-pyright/src/browserWorkersHost.ts @@ -1,3 +1,4 @@ +import { getDiagnosticRulesets } from 'pyright-internal/common/configOptions'; import { Transferable, WorkersHost, @@ -29,6 +30,7 @@ export class BrowserWorkersHost implements WorkersHost { type: 'browser/newWorker', initialData, port: channel.port1, + diagnosticRulesets: getDiagnosticRulesets(), }, [channel.port1] ); diff --git a/packages/pyright-internal/src/common/configOptions.ts b/packages/pyright-internal/src/common/configOptions.ts index 1f243c2c6f..f2f10be1ce 100644 --- a/packages/pyright-internal/src/common/configOptions.ts +++ b/packages/pyright-internal/src/common/configOptions.ts @@ -1272,6 +1272,17 @@ export function getStrictDiagnosticRuleSet(): DiagnosticRuleSet { export const allTypeCheckingModes = ['off', 'basic', 'standard', 'strict', 'recommended', 'all'] as const; +export const getDiagnosticRulesets = () => + [...getBooleanDiagnosticRules(true), ...getDiagLevelDiagnosticRules()].map((rule) => ({ + 'Diagnostic Rule': rule, + ...Object.fromEntries( + allTypeCheckingModes.map((typeCheckingMode) => [ + typeCheckingMode, + ConfigOptions.getDiagnosticRuleSet(typeCheckingMode)[rule], + ]) + ), + })); + export function matchFileSpecs(configOptions: ConfigOptions, uri: Uri, isFile = true) { for (const includeSpec of configOptions.include) { if (FileSpec.matchIncludeFileSpec(includeSpec.regExp, configOptions.exclude, uri, isFile)) { diff --git a/packages/pyright-internal/src/pyright.ts b/packages/pyright-internal/src/pyright.ts index 9771b215ad..69f8f31dd0 100644 --- a/packages/pyright-internal/src/pyright.ts +++ b/packages/pyright-internal/src/pyright.ts @@ -50,12 +50,7 @@ import { convertDiagnostics } from 'pyright-to-gitlab-ci/src/converter'; import path from 'path'; import { BaselineHandler } from './baseline'; import { pluralize } from './common/stringUtils'; -import { - allTypeCheckingModes, - ConfigOptions, - getBooleanDiagnosticRules, - getDiagLevelDiagnosticRules, -} from './common/configOptions'; +import { getDiagnosticRulesets } from './common/configOptions'; type SeverityLevel = 'error' | 'warning' | 'information'; @@ -203,19 +198,7 @@ async function processArgs(): Promise { return ExitStatus.ParameterError; } if (args.printdiagnosticrulesets) { - console.log( - JSON.stringify( - [...getBooleanDiagnosticRules(true), ...getDiagLevelDiagnosticRules()].map((rule) => ({ - 'Diagnostic Rule': rule, - ...Object.fromEntries( - allTypeCheckingModes.map((typeCheckingMode) => [ - typeCheckingMode, - ConfigOptions.getDiagnosticRuleSet(typeCheckingMode)[rule], - ]) - ), - })) - ) - ); + console.log(JSON.stringify(getDiagnosticRulesets())); return ExitStatus.NoErrors; } if (args.help !== undefined) {