Skip to content

Commit cde6309

Browse files
committed
feat(utils): add type guards and URL source formatting
1 parent ef5a5be commit cde6309

File tree

18 files changed

+280
-134
lines changed

18 files changed

+280
-134
lines changed

examples/plugins/src/file-size/docs/file-size-unmodified.audit.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ A `Issue` with severity `info` is present and names to the given file.
2424
<tr>
2525
<th>Severity</th>
2626
<th>Message</th>
27-
<th>Source file</th>
28-
<th>Line(s)</th>
27+
<th>Source</th>
28+
<th>Location</th>
2929
</tr>
3030
<tr>
3131
<td>ℹ️ <i>info</i></td>
@@ -45,8 +45,8 @@ The file sizes of the given file, the budget as well as the size difference is m
4545
<tr>
4646
<th>Severity</th>
4747
<th>Message</th>
48-
<th>Source file</th>
49-
<th>Line(s)</th>
48+
<th>Source</th>
49+
<th>Location</th>
5050
</tr>
5151
<tr>
5252
<td>🚨 <i>error</i></td>

examples/plugins/src/package-json/docs/dependencies.audit.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ An `Issue` with severity `info` is present and names to the given file.
2424
<tr>
2525
<th>Severity</th>
2626
<th>Message</th>
27-
<th>Source file</th>
28-
<th>Line(s)</th>
27+
<th>Source</th>
28+
<th>Location</th>
2929
</tr>
3030
<tr>
3131
<td>ℹ️ <i>info</i></td>
@@ -44,8 +44,8 @@ A `Issue` with severity `info` is present and names to the given file.
4444
<tr>
4545
<th>Severity</th>
4646
<th>Message</th>
47-
<th>Source file</th>
48-
<th>Line(s)</th>
47+
<th>Source</th>
48+
<th>Location</th>
4949
</tr>
5050
<tr>
5151
<td>ℹ️ <i>info</i></td>
@@ -65,8 +65,8 @@ The dependencies of the given file, the target version as well as the given vers
6565
<tr>
6666
<th>Severity</th>
6767
<th>Message</th>
68-
<th>Source file</th>
69-
<th>Line(s)</th>
68+
<th>Source</th>
69+
<th>Location</th>
7070
</tr>
7171
<tr>
7272
<td>🚨 <i>error</i></td>

examples/plugins/src/package-json/docs/license.audit.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ A `Issue` with severity `info` is present and names to the given file.
2424
<tr>
2525
<th>Severity</th>
2626
<th>Message</th>
27-
<th>Source file</th>
28-
<th>Line(s)</th>
27+
<th>Source</th>
28+
<th>Location</th>
2929
</tr>
3030
<tr>
3131
<td>ℹ️ <i>info</i></td>
@@ -44,8 +44,8 @@ A `Issue` with severity `info` is present and names to the given file.
4444
<tr>
4545
<th>Severity</th>
4646
<th>Message</th>
47-
<th>Source file</th>
48-
<th>Line(s)</th>
47+
<th>Source</th>
48+
<th>Location</th>
4949
</tr>
5050
<tr>
5151
<td>ℹ️ <i>info</i></td>
@@ -65,8 +65,8 @@ The `license` of the given file, the target `license` as well as the given `lice
6565
<tr>
6666
<th>Severity</th>
6767
<th>Message</th>
68-
<th>Source file</th>
69-
<th>Line(s)</th>
68+
<th>Source</th>
69+
<th>Location</th>
7070
</tr>
7171
<tr>
7272
<td>🚨 <i>error</i></td>

examples/plugins/src/package-json/docs/type.audit.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ A `Issue` with severity `info` is present and names to the given file.
2828
<tr>
2929
<th>Severity</th>
3030
<th>Message</th>
31-
<th>Source file</th>
32-
<th>Line(s)</th>
31+
<th>Source</th>
32+
<th>Location</th>
3333
</tr>
3434
<tr>
3535
<td>ℹ️ <i>info</i></td>
@@ -48,8 +48,8 @@ A `Issue` with severity `info` is present and names to the given file.
4848
<tr>
4949
<th>Severity</th>
5050
<th>Message</th>
51-
<th>Source file</th>
52-
<th>Line(s)</th>
51+
<th>Source</th>
52+
<th>Location</th>
5353
</tr>
5454
<tr>
5555
<td>ℹ️ <i>info</i></td>
@@ -69,8 +69,8 @@ The `type` of the given file, the target `type` as well as the given `type` are
6969
<tr>
7070
<th>Severity</th>
7171
<th>Message</th>
72-
<th>Source file</th>
73-
<th>Line(s)</th>
72+
<th>Source</th>
73+
<th>Location</th>
7474
</tr>
7575
<tr>
7676
<td>🚨 <i>error</i></td>

packages/ci/mocks/fixtures/outputs/report-before.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
#### Issues
1111

12-
| Severity | Message | Source file | Line(s) |
13-
| :----------: | :------------------------------------ | :------------------------ | :-----: |
14-
| ⚠️ _warning_ | Use .ts file extension instead of .js | [`index.js`](../index.js) | |
12+
| Severity | Message | Source | Location |
13+
| :----------: | :------------------------------------ | :------------------------ | :------: |
14+
| ⚠️ _warning_ | Use .ts file extension instead of .js | [`index.js`](../index.js) | |
1515

1616
</details>
1717

packages/cli/docs/custom-plugins.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,8 @@ The `report.md` file should contain a similar content like the following:
559559
<tr>
560560
<th>Severity</th>
561561
<th>Message</th>
562-
<th>Source file</th>
563-
<th>Line(s)</th>
562+
<th>Source</th>
563+
<th>Location</th>
564564
</tr>
565565
<tr>
566566
<td>🚨 <i>error</i></td>

packages/plugin-typescript/docs/audits-and-groups.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ Errors that occur during type checking and type inference.
3333

3434
#### Issues
3535

36-
| Severity | Message | Source file | Line(s) |
37-
| :--------: | :----------------------------------------------------------------------------------- | :------------------------------------------------------------------------ | :-----: |
38-
| 🚨 _error_ | TS2307: Cannot find module './non-existent' or its corresponding type declarations. | [`path/to/module-resolution.ts`](../path/to/module-resolution.ts) | 2 |
39-
| 🚨 _error_ | TS2349: This expression is not callable.<br /> Type 'Number' has no call signatures. | [`path/to/strict-function-types.ts`](../path/to/strict-function-types.ts) | 3 |
40-
| 🚨 _error_ | TS2304: Cannot find name 'NonExistentType'. | [`path/to/cannot-find-module.ts`](../path/to/cannot-find-module.ts) | 1 |
36+
| Severity | Message | Source | Location |
37+
| :--------: | :----------------------------------------------------------------------------------- | :------------------------------------------------------------------------ | :------: |
38+
| 🚨 _error_ | TS2307: Cannot find module './non-existent' or its corresponding type declarations. | [`path/to/module-resolution.ts`](../path/to/module-resolution.ts) | 2 |
39+
| 🚨 _error_ | TS2349: This expression is not callable.<br /> Type 'Number' has no call signatures. | [`path/to/strict-function-types.ts`](../path/to/strict-function-types.ts) | 3 |
40+
| 🚨 _error_ | TS2304: Cannot find name 'NonExistentType'. | [`path/to/cannot-find-module.ts`](../path/to/cannot-find-module.ts) | 1 |
4141

4242
---
4343

@@ -54,9 +54,9 @@ Errors that occur during parsing and lexing of TypeScript source code.
5454

5555
#### Issues
5656

57-
| Severity | Message | Source file | Line(s) |
58-
| :--------: | :------------------------------------ | :------------------------------------------------------ | :-----: |
59-
| 🚨 _error_ | TS1136: Property assignment expected. | [`path/to/syntax-error.ts`](../path/to/syntax-error.ts) | 1 |
57+
| Severity | Message | Source | Location |
58+
| :--------: | :------------------------------------ | :------------------------------------------------------ | :------: |
59+
| 🚨 _error_ | TS1136: Property assignment expected. | [`path/to/syntax-error.ts`](../path/to/syntax-error.ts) | 1 |
6060

6161
---
6262

@@ -73,9 +73,9 @@ Errors that occur when parsing TypeScript configuration files.
7373

7474
#### Issues
7575

76-
| Severity | Message | Source file | Line(s) |
77-
| :--------: | :----------------------------------------- | :-------------------------------------------------- | :-----: |
78-
| 🚨 _error_ | TS5023: Unknown compiler option 'invalid'. | [`path/to/tsconfig.json`](../path/to/tsconfig.json) | 1 |
76+
| Severity | Message | Source | Location |
77+
| :--------: | :----------------------------------------- | :-------------------------------------------------- | :------: |
78+
| 🚨 _error_ | TS5023: Unknown compiler option 'invalid'. | [`path/to/tsconfig.json`](../path/to/tsconfig.json) | 1 |
7979

8080
---
8181

@@ -92,9 +92,9 @@ Errors that occur during TypeScript language service operations.
9292

9393
#### Issues
9494

95-
| Severity | Message | Source file | Line(s) |
96-
| :--------: | :------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------ | :-----: |
97-
| 🚨 _error_ | TS4112: This member cannot have an 'override' modifier because its containing class 'Standalone' does not extend another class. | [`path/to/incorrect-modifier.ts`](../path/to/incorrect-modifier.ts) | 2 |
95+
| Severity | Message | Source | Location |
96+
| :--------: | :------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------ | :------: |
97+
| 🚨 _error_ | TS4112: This member cannot have an 'override' modifier because its containing class 'Standalone' does not extend another class. | [`path/to/incorrect-modifier.ts`](../path/to/incorrect-modifier.ts) | 2 |
9898

9999
---
100100

@@ -111,9 +111,9 @@ Errors that occur during TypeScript internal operations.
111111

112112
#### Issues
113113

114-
| Severity | Message | Source file | Line(s) |
115-
| :--------: | :------------------------------- | :---------------------------------------------------------- | :-----: |
116-
| 🚨 _error_ | TS9001: Internal compiler error. | [`path/to/internal-error.ts`](../path/to/internal-error.ts) | 4 |
114+
| Severity | Message | Source | Location |
115+
| :--------: | :------------------------------- | :---------------------------------------------------------- | :------: |
116+
| 🚨 _error_ | TS9001: Internal compiler error. | [`path/to/internal-error.ts`](../path/to/internal-error.ts) | 4 |
117117

118118
---
119119

@@ -130,9 +130,9 @@ Errors related to no implicit any compiler option.
130130

131131
#### Issues
132132

133-
| Severity | Message | Source file | Line(s) |
134-
| :--------: | :-------------------------------------------------- | :------------------------------------------------------ | :-----: |
135-
| 🚨 _error_ | TS7006: Parameter 'x' implicitly has an 'any' type. | [`path/to/implicit-any.ts`](../path/to/implicit-any.ts) | 5 |
133+
| Severity | Message | Source | Location |
134+
| :--------: | :-------------------------------------------------- | :------------------------------------------------------ | :------: |
135+
| 🚨 _error_ | TS7006: Parameter 'x' implicitly has an 'any' type. | [`path/to/implicit-any.ts`](../path/to/implicit-any.ts) | 5 |
136136

137137
---
138138

@@ -149,9 +149,9 @@ Errors that do not match any known TypeScript error code.
149149

150150
#### Issues
151151

152-
| Severity | Message | Source file | Line(s) |
153-
| :--------: | :-------------------------------------- | :-------------------------------------------------------- | :-----: |
154-
| 🚨 _error_ | TS9999: Unknown error code encountered. | [`path/to/unknown-error.ts`](../path/to/unknown-error.ts) | 6 |
152+
| Severity | Message | Source | Location |
153+
| :--------: | :-------------------------------------- | :-------------------------------------------------------- | :------: |
154+
| 🚨 _error_ | TS9999: Unknown error code encountered. | [`path/to/unknown-error.ts`](../path/to/unknown-error.ts) | 6 |
155155

156156
---
157157

packages/utils/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ export {
125125
listGroupsFromAllPlugins,
126126
} from './lib/reports/flatten-plugins.js';
127127
export { formatIssueSeverities, wrapTags } from './lib/reports/formatting.js';
128+
export {
129+
isFileIssue,
130+
isFileSource,
131+
isUrlSource,
132+
} from './lib/reports/type-guards.js';
128133
export { generateMdReport } from './lib/reports/generate-md-report.js';
129134
export {
130135
generateMdReportsDiff,

packages/utils/src/lib/reports/__snapshots__/generate-md-report.unit.test.ts.snap

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ exports[`auditDetails > should render complete details section 1`] = `
2626
2727
#### Issues
2828
29-
| Severity | Message | Source file | Line(s) |
30-
| :--------: | :---------------------------------------------- | :------------------ | :-----: |
31-
| 🚨 _error_ | Use design system components instead of classes | \`list.component.ts\` | 400-200 |
32-
| 🚨 _error_ | File size is 20KB too big | \`list.component.ts\` | |
29+
| Severity | Message | Source | Location |
30+
| :--------: | :---------------------------------------------- | :------------------ | :------: |
31+
| 🚨 _error_ | Use design system components instead of classes | \`list.component.ts\` | 400-200 |
32+
| 🚨 _error_ | File size is 20KB too big | \`list.component.ts\` | |
3333
3434
</details>
3535
"
@@ -38,11 +38,11 @@ exports[`auditDetails > should render complete details section 1`] = `
3838
exports[`auditDetailsIssues > should render complete section 1`] = `
3939
"#### Issues
4040
41-
| Severity | Message | Source file | Line(s) |
42-
| :----------: | :--------------------------------- | :------------- | :-----: |
43-
| ℹ️ _info_ | File \`index.js\` is 56Kb. | \`index.js\` | |
44-
| ⚠️ _warning_ | Package license is has to be "MIT" | \`package.json\` | 4 |
45-
| 🚨 _error_ | no unused vars | \`index.js\` | 400-200 |
41+
| Severity | Message | Source | Location |
42+
| :----------: | :--------------------------------- | :------------- | :------: |
43+
| ℹ️ _info_ | File \`index.js\` is 56Kb. | \`index.js\` | |
44+
| ⚠️ _warning_ | Package license is has to be "MIT" | \`package.json\` | 4 |
45+
| 🚨 _error_ | no unused vars | \`index.js\` | 400-200 |
4646
"
4747
`;
4848

@@ -130,11 +130,11 @@ Search engines are unable to include your pages in search results if they don't
130130
131131
#### Issues
132132
133-
| Severity | Message | Source file | Line(s) |
134-
| :----------: | :--------------------------------- | :------------- | :-----: |
135-
| ℹ️ _info_ | File \`index.js\` is 56Kb. | \`index.js\` | |
136-
| ⚠️ _warning_ | Package license is has to be "MIT" | \`package.json\` | 4 |
137-
| 🚨 _error_ | no unused vars | \`index.js\` | 400-200 |
133+
| Severity | Message | Source | Location |
134+
| :----------: | :--------------------------------- | :------------- | :------: |
135+
| ℹ️ _info_ | File \`index.js\` is 56Kb. | \`index.js\` | |
136+
| ⚠️ _warning_ | Package license is has to be "MIT" | \`package.json\` | 4 |
137+
| 🚨 _error_ | no unused vars | \`index.js\` | 400-200 |
138138
139139
</details>
140140

0 commit comments

Comments
 (0)