Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript-eslint workaround + misc fixes #613

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions packages/dtslint-runner/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,21 +206,13 @@ function logPerformance() {
console.log("\n\n=== PERFORMANCE ===\n");
for (const filename of readdirSync(perfDir, { encoding: "utf8" })) {
const x = JSON.parse(readFileSync(joinPaths(perfDir, filename), { encoding: "utf8" })) as {
[s: string]: { typeCount: number; memory: number };
[s: string]: { types: number; memory: number };
};
for (const k of Object.keys(x)) {
big.push([k, x[k].typeCount]);
types.push(x[k].typeCount);
big.push([k, x[k].types]);
types.push(x[k].types);
}
}
console.log(
"{" +
big
.sort((a, b) => b[1] - a[1])
.map(([name, count]) => ` "${name}": ${count}`)
.join(",") +
"}"
);

console.log(" * Percentiles: ");
console.log("99:", percentile(types, 0.99));
Expand Down
4 changes: 4 additions & 0 deletions packages/dtslint/src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export async function lint(
tsLocal: string | undefined
): Promise<string | undefined> {
const tsconfigPath = joinPaths(dirPath, "tsconfig.json");
const estree = await import(require.resolve("@typescript-eslint/typescript-estree", { paths: [dirPath] }));
process.env.TSESTREE_SINGLE_RUN = "true";
// TODO: To remove tslint, replace this with a ts.createProgram (probably)
const lintProgram = Linter.createProgram(tsconfigPath);

Expand Down Expand Up @@ -74,6 +76,8 @@ export async function lint(
const formatter = await eslint.loadFormatter("stylish");
const eresults = await eslint.lintFiles(esfiles);
output += formatter.format(eresults);
estree.clearProgramCache();
estree.clearCaches();
process.chdir(cwd);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/dtslint/src/rules/noRedundantJsdoc2Rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ function walk(ctx: Lint.WalkContext<void>): void {
const jsdocSeeTag = (ts.SyntaxKind as any).JSDocSeeTag || 0;
const jsdocDeprecatedTag = (ts.SyntaxKind as any).JSDocDeprecatedTag || 0;
const jsdocThrowsTag = (ts.SyntaxKind as any).JSDocThrowsTag || 0;
const jsdocOverrideTag = (ts.SyntaxKind as any).JSDocOverrideTag || 0;
switch (tag.kind) {
case jsdocSeeTag:
case jsdocDeprecatedTag:
case jsdocThrowsTag:
case jsdocOverrideTag:
case ts.SyntaxKind.JSDocAuthorTag:
// @deprecated and @see always have meaning
break;
Expand Down