-
Notifications
You must be signed in to change notification settings - Fork 653
[lint] Ensure correctness of SARIF output logs #5443
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
Merged
+267
−48
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2f3bb8e
[eslint-bulk] Report bulk suppressions as suppressions
dmichon-msft 4af13ae
[heft-lint] Include suppressed results
dmichon-msft 6cc88d6
Enable sarif log for local rigs, add test
dmichon-msft 2bc17ab
Fix lint cache
dmichon-msft 408473e
Fix typo in TSLint
dmichon-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "extends": "local-node-rig/profiles/default/config/heft.json", | ||
|
|
||
| "phasesByName": { | ||
| "build": { | ||
| "tasksByName": { | ||
| "lint": { | ||
| "taskPlugin": { | ||
| // Clear the SARIF emitter | ||
| "options": null | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "extends": "local-node-rig/profiles/default/config/heft.json", | ||
|
|
||
| "phasesByName": { | ||
| "build": { | ||
| "tasksByName": { | ||
| "lint": { | ||
| "taskPlugin": { | ||
| // Clear the SARIF emitter | ||
| "options": null | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "suppressions": [ | ||
| { | ||
| "file": "src/index.ts", | ||
| "scopeId": ".", | ||
| "rule": "@typescript-eslint/naming-convention" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
build-tests/eslint-9-test/src/__snapshots__/sarif.test.ts.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`Sarif Logs has the expected content 1`] = ` | ||
| Object { | ||
| "$schema": "http://json.schemastore.org/sarif-2.1.0-rtm.5", | ||
| "runs": Array [ | ||
| Object { | ||
| "artifacts": Array [ | ||
| Object { | ||
| "location": Object { | ||
| "uri": "src/index.ts", | ||
| }, | ||
| }, | ||
| Object { | ||
| "location": Object { | ||
| "uri": "src/sarif.test.ts", | ||
| }, | ||
| }, | ||
| ], | ||
| "results": Array [ | ||
| Object { | ||
| "level": "warning", | ||
| "locations": Array [ | ||
| Object { | ||
| "physicalLocation": Object { | ||
| "artifactLocation": Object { | ||
| "index": 0, | ||
| "uri": "src/index.ts", | ||
| }, | ||
| "region": Object { | ||
| "endColumn": 24, | ||
| "endLine": 6, | ||
| "startColumn": 3, | ||
| "startLine": 6, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| "message": Object { | ||
| "text": "Expected _bar to have a type annotation.", | ||
| }, | ||
| "ruleId": "@typescript-eslint/typedef", | ||
| "ruleIndex": 0, | ||
| "suppressions": Array [ | ||
| Object { | ||
| "justification": "", | ||
| "kind": "inSource", | ||
| }, | ||
| ], | ||
| }, | ||
| Object { | ||
| "level": "warning", | ||
| "locations": Array [ | ||
| Object { | ||
| "physicalLocation": Object { | ||
| "artifactLocation": Object { | ||
| "index": 0, | ||
| "uri": "src/index.ts", | ||
| }, | ||
| "region": Object { | ||
| "endColumn": 30, | ||
| "endLine": 10, | ||
| "startColumn": 14, | ||
| "startLine": 10, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| "message": Object { | ||
| "text": "Variable name \`Bad_Name\` must match one of the following formats: camelCase, UPPER_CASE, PascalCase", | ||
| }, | ||
| "ruleId": "@typescript-eslint/naming-convention", | ||
| "ruleIndex": 1, | ||
| "suppressions": Array [ | ||
| Object { | ||
| "justification": "", | ||
| "kind": "external", | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| "tool": Object { | ||
| "driver": Object { | ||
| "informationUri": "https://eslint.org", | ||
| "name": "ESLint", | ||
| "rules": Array [ | ||
| Object { | ||
| "helpUri": "https://typescript-eslint.io/rules/typedef", | ||
| "id": "@typescript-eslint/typedef", | ||
| "properties": Object {}, | ||
| "shortDescription": Object { | ||
| "text": "Require type annotations in certain places", | ||
| }, | ||
| }, | ||
| Object { | ||
| "helpUri": "https://typescript-eslint.io/rules/naming-convention", | ||
| "id": "@typescript-eslint/naming-convention", | ||
| "properties": Object {}, | ||
| "shortDescription": Object { | ||
| "text": "Enforce naming conventions for everything across a codebase", | ||
| }, | ||
| }, | ||
| ], | ||
| "version": "9.37.0", | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| "version": "2.1.0", | ||
| } | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| import * as fs from 'node:fs'; | ||
| import * as path from 'node:path'; | ||
|
|
||
| const sarifLogPath: string = path.resolve(__dirname, '../temp/build/lint/lint.sarif'); | ||
|
|
||
| describe('Sarif Logs', () => { | ||
| it('has the expected content', () => { | ||
| const logContent = fs.readFileSync(sarifLogPath, 'utf-8'); | ||
| const parsedLog = JSON.parse(logContent); | ||
| expect(parsedLog).toMatchSnapshot(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,5 @@ | ||
| { | ||
| "$schema": "http://json.schemastore.org/tsconfig", | ||
|
|
||
| "compilerOptions": { | ||
| "outDir": "lib", | ||
| "rootDir": "src", | ||
|
|
||
| "forceConsistentCasingInFileNames": true, | ||
| "declaration": true, | ||
| "sourceMap": true, | ||
| "declarationMap": true, | ||
| "inlineSources": true, | ||
| "experimentalDecorators": true, | ||
| "strictNullChecks": true, | ||
| "noUnusedLocals": true, | ||
|
|
||
| "module": "esnext", | ||
| "moduleResolution": "node", | ||
| "target": "es5", | ||
| "lib": ["es5"] | ||
| }, | ||
| "include": ["src/**/*.ts", "src/**/*.tsx"], | ||
| "exclude": ["node_modules", "lib"] | ||
| "extends": "./node_modules/local-node-rig/profiles/default/tsconfig-base.json" | ||
| } |
10 changes: 10 additions & 0 deletions
10
common/changes/@rushstack/eslint-patch/fix-sarif-logs_2025-11-11-23-06.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@rushstack/eslint-patch", | ||
| "comment": "In ESLint >= 9.37, report bulk suppressed messages as suppressed messages rather than removing them completely.", | ||
| "type": "minor" | ||
| } | ||
| ], | ||
| "packageName": "@rushstack/eslint-patch" | ||
| } |
10 changes: 10 additions & 0 deletions
10
common/changes/@rushstack/heft-lint-plugin/fix-sarif-logs_2025-11-11-23-06.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@rushstack/heft-lint-plugin", | ||
| "comment": "Forward suppressed messages to formatters.", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "@rushstack/heft-lint-plugin" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,19 @@ | ||
| { | ||
| "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json", | ||
|
|
||
| "extends": "@rushstack/heft-node-rig/profiles/default/config/heft.json" | ||
| "extends": "@rushstack/heft-node-rig/profiles/default/config/heft.json", | ||
|
|
||
| "phasesByName": { | ||
| "build": { | ||
| "tasksByName": { | ||
| "lint": { | ||
| "taskPlugin": { | ||
| "options": { | ||
| "sarifLogPath": "temp/build/lint/lint.sarif" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,19 @@ | ||
| { | ||
| "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json", | ||
|
|
||
| "extends": "@rushstack/heft-web-rig/profiles/app/config/heft.json" | ||
| "extends": "@rushstack/heft-web-rig/profiles/app/config/heft.json", | ||
|
|
||
| "phasesByName": { | ||
| "build": { | ||
| "tasksByName": { | ||
| "lint": { | ||
| "taskPlugin": { | ||
| "options": { | ||
| "sarifLogPath": "temp/build/lint/lint.sarif" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.