Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e536e39
Add reporter from @arthurfiorette
EzraBrooks Apr 28, 2025
8a881b4
Cleanup and test
EzraBrooks Apr 28, 2025
7e94c8c
refactor: githubActionsLogger
cylewaitforit Aug 22, 2025
45a1754
fix: clean up types
cylewaitforit Aug 22, 2025
60d8800
Merge branch 'main' into github-actions-reporter
cylewaitforit Aug 22, 2025
89ca55b
fix: types
cylewaitforit Aug 22, 2025
5c0e4af
tests: add tests against additional fixtures
cylewaitforit Aug 26, 2025
f64a0f4
Merge branch 'main' into github-actions-reporter
cylewaitforit Aug 26, 2025
57d1194
fix: kebab-case reporter name
cylewaitforit Sep 4, 2025
4afde72
Merge branch 'main' into github-actions-reporter
cylewaitforit Sep 4, 2025
7af3038
ci: use --reporter github-actions
cylewaitforit Sep 4, 2025
d33ba78
fix: use relative paths
cylewaitforit Sep 4, 2025
de0c959
Merge branch 'main' into github-actions-reporter
cylewaitforit Sep 7, 2025
a586eeb
test: add exact positions to assertions
cylewaitforit Sep 7, 2025
dbd4aa6
fix: get unused files severity and add symbol to message
cylewaitforit Sep 7, 2025
1437b79
fix: try 0 position for issues without position
cylewaitforit Sep 7, 2025
4805b32
Add co-author credit for GitHub Actions reporter
cylewaitforit Sep 7, 2025
0d4e97a
fix: use 1 based positions for items without position info
cylewaitforit Sep 7, 2025
ece51d1
feat: add configuration hints
cylewaitforit Sep 7, 2025
031eed5
feat: add emoji to title
cylewaitforit Sep 8, 2025
cd7b901
feat: add issue type titles
cylewaitforit Sep 8, 2025
494bb5d
feat: move type to title and add in file to message
cylewaitforit Sep 8, 2025
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
Prev Previous commit
Next Next commit
fix: try 0 position for issues without position
  • Loading branch information
cylewaitforit committed Sep 7, 2025
commit 1437b79c38e0c920419ff54bc4d955070d8f18e0
16 changes: 8 additions & 8 deletions packages/knip/src/reporters/githubActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const createGitHubActionsLogger = () => {
}
) => {
const params = [`file=${options.file}`];
if (options.startLine) params.push(`line=${options.startLine}`);
if (options.endLine) params.push(`endLine=${options.endLine}`);
if (options.startColumn) params.push(`col=${options.startColumn}`);
if (options.endColumn) params.push(`endColumn=${options.endColumn}`);
if (options.startLine != null) params.push(`line=${options.startLine}`);
if (options.endLine != null) params.push(`endLine=${options.endLine}`);
if (options.startColumn != null) params.push(`col=${options.startColumn}`);
if (options.endColumn != null) params.push(`endColumn=${options.endColumn}`);

const paramString = params.join(',');
console.log(`::${level} ${paramString}::${message}`);
Expand Down Expand Up @@ -63,10 +63,10 @@ export default ({ report, issues, cwd }: ReporterOptions) => {

log(message, {
file: relative(cwd, issueItem.filePath),
startLine: issueItem.line,
endLine: issueItem.line,
endColumn: issueItem.col,
startColumn: issueItem.col,
startLine: issueItem.line ?? 0,
endLine: issueItem.line ?? 0,
startColumn: issueItem.col ?? 0,
endColumn: issueItem.col ?? 0,
});
}
}
Expand Down
30 changes: 15 additions & 15 deletions packages/knip/test/cli/cli-reporter-githubActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const moduleCwd = resolve('fixtures/module-resolution-non-std');
test('knip --reporter github-actions (files, unlisted & unresolved)', () => {
assert.equal(
exec('knip --reporter github-actions', { cwd: moduleCwd }).stdout,
`::error file=src/unused.ts::Unused files: src/unused.ts
::error file=src/index.ts::Unlisted dependencies: unresolved
::error file=src/index.ts::Unlisted dependencies: @org/unresolved
`::error file=src/unused.ts,line=0,endLine=0,col=0,endColumn=0::Unused files: src/unused.ts
::error file=src/index.ts,line=0,endLine=0,col=0,endColumn=0::Unlisted dependencies: unresolved
::error file=src/index.ts,line=0,endLine=0,col=0,endColumn=0::Unlisted dependencies: @org/unresolved
::error file=src/index.ts,line=8,endLine=8,col=23,endColumn=23::Unresolved imports: ./unresolved`
);
});
Expand All @@ -20,20 +20,20 @@ const rulesCwd = resolve('fixtures/rules');
test('knip --reporter github-actions (rules: unused export, unused dep, unresolved)', () => {
assert.equal(
exec('knip --reporter github-actions', { cwd: rulesCwd }).stdout,
`::warning file=unused.ts::Unused files: unused.ts
::warning file=package.json::Unused dependencies: unused
::warning file=package.json::Unused devDependencies: @dev/unused
::warning file=package.json::Referenced optional peerDependencies: optional-peer-dep
::warning file=index.ts::Unlisted dependencies: unlisted
::warning file=package.json::Unlisted binaries: unlisted
`::warning file=unused.ts,line=0,endLine=0,col=0,endColumn=0::Unused files: unused.ts
::warning file=package.json,line=0,endLine=0,col=0,endColumn=0::Unused dependencies: unused
::warning file=package.json,line=0,endLine=0,col=0,endColumn=0::Unused devDependencies: @dev/unused
::warning file=package.json,line=0,endLine=0,col=0,endColumn=0::Referenced optional peerDependencies: optional-peer-dep
::warning file=index.ts,line=0,endLine=0,col=0,endColumn=0::Unlisted dependencies: unlisted
::warning file=package.json,line=0,endLine=0,col=0,endColumn=0::Unlisted binaries: unlisted
::warning file=index.ts,line=3,endLine=3,col=28,endColumn=28::Unresolved imports: ./unresolved
::warning file=ns.ts,line=2,endLine=2,col=14,endColumn=14::Unused exports: unused
::warning file=exports.ts,line=2,endLine=2,col=14,endColumn=14::Unused exports: unused
::warning file=ns.ts,line=5,endLine=5,col=13,endColumn=13::Unused exported types: UnusedType
::warning file=exports.ts,line=5,endLine=5,col=13,endColumn=13::Unused exported types: UnusedType
::warning file=exports.ts,line=15,endLine=15,col=3,endColumn=3::Unused exported enum members: unused
::warning file=exports.ts,line=10,endLine=10,col=3,endColumn=3::Unused exported class members: unused
::warning file=exports.ts::Duplicate exports: used|default`
::warning file=exports.ts,line=0,endLine=0,col=0,endColumn=0::Duplicate exports: used|default`
);
});

Expand All @@ -42,15 +42,15 @@ const workspacesCwd = resolve('fixtures/workspaces');
test('knip --reporter github-actions (workspaces: unused export, unused dep, unlisted dep)', () => {
assert.equal(
exec('knip --reporter github-actions', { cwd: workspacesCwd }).stdout,
`::error file=docs/dangling.ts::Unused files: docs/dangling.ts
`::error file=docs/dangling.ts,line=0,endLine=0,col=0,endColumn=0::Unused files: docs/dangling.ts
::error file=package.json,line=6,endLine=6,col=6,endColumn=6::Unused dependencies: minimist
::error file=package.json,line=8,endLine=8,col=6,endColumn=6::Unused dependencies: zod
::error file=apps/backend/package.json,line=7,endLine=7,col=6,endColumn=6::Unused dependencies: picomatch
::error file=apps/backend/package.json,line=8,endLine=8,col=6,endColumn=6::Unused dependencies: next
::error file=packages/tools/tsconfig.json::Unlisted dependencies: @fixtures/workspaces__tsconfig
::error file=apps/frontend/index.ts::Unlisted dependencies: vanilla-js
::error file=apps/backend/index.ts::Unlisted dependencies: js-yaml
::error file=apps/backend/index.ts::Unlisted dependencies: globby
::error file=packages/tools/tsconfig.json,line=0,endLine=0,col=0,endColumn=0::Unlisted dependencies: @fixtures/workspaces__tsconfig
::error file=apps/frontend/index.ts,line=0,endLine=0,col=0,endColumn=0::Unlisted dependencies: vanilla-js
::error file=apps/backend/index.ts,line=0,endLine=0,col=0,endColumn=0::Unlisted dependencies: js-yaml
::error file=apps/backend/index.ts,line=0,endLine=0,col=0,endColumn=0::Unlisted dependencies: globby
::error file=packages/tools/utils.ts,line=3,endLine=3,col=14,endColumn=14::Unused exports: helperFn
::error file=packages/shared/types.ts,line=4,endLine=4,col=13,endColumn=13::Unused exported types: UnusedEnum`
);
Expand Down
Loading