Skip to content

Commit

Permalink
get diagnostic ruleset defaults for the playground
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed Oct 15, 2024
1 parent 9f0be60 commit 679f50d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
2 changes: 2 additions & 0 deletions packages/browser-pyright/src/browserWorkersHost.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getDiagnosticRulesets } from 'pyright-internal/common/configOptions';
import {
Transferable,
WorkersHost,
Expand Down Expand Up @@ -29,6 +30,7 @@ export class BrowserWorkersHost implements WorkersHost {
type: 'browser/newWorker',
initialData,
port: channel.port1,
diagnosticRulesets: getDiagnosticRulesets(),
},
[channel.port1]
);
Expand Down
11 changes: 11 additions & 0 deletions packages/pyright-internal/src/common/configOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
21 changes: 2 additions & 19 deletions packages/pyright-internal/src/pyright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -203,19 +198,7 @@ async function processArgs(): Promise<ExitStatus> {
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) {
Expand Down

0 comments on commit 679f50d

Please sign in to comment.