Skip to content

Commit b0b66da

Browse files
committed
Fix issue where messageId was being reported instead of ruleId
1 parent 89eb05a commit b0b66da

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

stack/rush-stack-compiler-shared/src/shared/EslintRunner.ts

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,49 @@ import {
1212
WriteFileIssueFunction
1313
} from './RushStackCompilerBase';
1414

15-
interface IEslintFileOutput {
15+
interface IEslintFileResult {
16+
// Example: "/full/path/to/File.ts"
1617
filePath: string;
18+
19+
// Full content of the source file
20+
source: string;
21+
1722
messages: IEslintMessage[];
23+
1824
errorCount: number;
1925
warningCount: number;
2026
fixableErrorCount: number;
2127
fixableWarningCount: number;
22-
source: string;
28+
}
29+
30+
enum EslintSeverity {
31+
Off = 0,
32+
Warn = 1,
33+
Error = 2
2334
}
2435

2536
interface IEslintMessage {
26-
ruleId: string;
27-
severity: number;
28-
message: string;
37+
// The line number starts at 1
2938
line: number;
30-
column: number;
31-
nodeType: string;
32-
messageId: string;
3339
endLine: number;
40+
41+
// The column number starts at 1
42+
column: number;
3443
endColumn: number;
44+
45+
// Example: "no-bitwise"
46+
ruleId: string;
47+
48+
// Example: "unexpected"
49+
messageId: string;
50+
51+
// Example: "Unexpected use of '&'."
52+
message: string;
53+
54+
severity: EslintSeverity;
55+
56+
// Example: "BinaryExpression"
57+
nodeType: string | null;
3558
}
3659

3760
export class EslintRunner extends RushStackCompilerBase<ILintRunnerConfig> {
@@ -66,16 +89,16 @@ export class EslintRunner extends RushStackCompilerBase<ILintRunnerConfig> {
6689

6790
// ESLint errors are logged to stdout
6891
try {
69-
const eslintOutput: IEslintFileOutput[] = JSON.parse(dataStr);
70-
for (const eslintFileOutput of eslintOutput) {
92+
const eslintFileResults: IEslintFileResult[] = JSON.parse(dataStr);
93+
for (const eslintFileResult of eslintFileResults) {
7194
const pathFromRoot: string = path.relative(this._standardBuildFolders.projectFolderPath,
72-
eslintFileOutput.filePath);
73-
for (const message of eslintFileOutput.messages) {
95+
eslintFileResult.filePath);
96+
for (const message of eslintFileResult.messages) {
7497
eslintErrorLogFn(
7598
pathFromRoot,
7699
message.line,
77100
message.column,
78-
message.messageId,
101+
message.ruleId,
79102
message.message
80103
);
81104
}

0 commit comments

Comments
 (0)