Skip to content

Commit

Permalink
Merge pull request microsoft#4104 from dmichon-msft/heft-rc-fix-doubl…
Browse files Browse the repository at this point in the history
…e-lint

[heft-next] Fix double invocation of linter
  • Loading branch information
dmichon-msft authored May 8, 2023
2 parents dbcec58 + afdbd91 commit 62f147a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions build-tests/heft-webpack4-everything-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"strictNullChecks": true,
"noUnusedLocals": true,
"types": ["heft-jest", "webpack-env"],
"incremental": true,

"module": "esnext",
"moduleResolution": "node",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-lint-plugin",
"comment": "Sort rule timings by duration, descending.",
"type": "none"
}
],
"packageName": "@rushstack/heft-lint-plugin"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-typescript-plugin",
"comment": "Fix double-execution of `accessor.onChangedFilesHook`.",
"type": "none"
}
],
"packageName": "@rushstack/heft-typescript-plugin"
}
9 changes: 7 additions & 2 deletions heft-plugins/heft-lint-plugin/src/Eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,14 @@ export class Eslint extends LinterBase<TEslint.ESLint.LintResult> {

protected lintingFinished(lintFailures: TEslint.ESLint.LintResult[]): void {
let omittedRuleCount: number = 0;
for (const [ruleName, duration] of this._eslintTimings.entries()) {
const timings: [string, number][] = Array.from(this._eslintTimings).sort(
(x: [string, number], y: [string, number]) => {
return y[1] - x[1];
}
);
for (const [ruleName, duration] of timings) {
if (duration > 0) {
this._terminal.writeVerboseLine(`Rule "${ruleName}" duration: ${duration}ms`);
this._terminal.writeVerboseLine(`Rule "${ruleName}" duration: ${duration.toFixed(3)} ms`);
} else {
omittedRuleCount++;
}
Expand Down
4 changes: 3 additions & 1 deletion heft-plugins/heft-typescript-plugin/src/TypeScriptBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,9 @@ export class TypeScriptBuilder {
let innerProgram: TTypescript.Program;

if (tsconfig.options.incremental) {
builderProgram = this._getCreateBuilderProgram(ts)(
// Use ts.createEmitAndSemanticDiagnositcsBuilderProgram directly because the customizations performed by
// _getCreateBuilderProgram duplicate those performed in this function for non-incremental build.
builderProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram(
tsconfig.fileNames,
tsconfig.options,
compilerHost,
Expand Down

0 comments on commit 62f147a

Please sign in to comment.