-
-
Notifications
You must be signed in to change notification settings - Fork 111
[fix] Remove unused dependencies, add check to run-qa-checks #484 #485
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aa110c0
[change] Changed the run-qa-check to also run knip script and added r…
0d2c496
[fix] Fixed formatting issues and made coderabbit suggestions
60f07a7
Merge branch 'master' into master
nemesifier fd64f2c
[chores] Added back bookmarkable actions to clustering example
nemesifier de54c5d
[chores] Minor improvement
nemesifier 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
Some comments aren't visible on the classic Files Changed page.
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
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 @@ | ||
| lts/krypton |
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,6 @@ | ||
| { | ||
| "$schema": "https://unpkg.com/knip@5/schema.json", | ||
| "project": ["src/**/*.js", "test/**/*.js"], | ||
| "ignore": ["examples/**", "lib/js/**", "public/**", "scripts/**"], | ||
| "ignoreBinaries": ["wait-on"] | ||
| } |
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| const {execSync} = require("child_process"); | ||
|
|
||
| function parseAndReportKnipResults(result) { | ||
| const issues = { | ||
| dependencies: new Set(), | ||
| devDependencies: new Set(), | ||
| unresolved: new Set(), | ||
| unusedFiles: new Set(), | ||
| unusedExports: [], | ||
| }; | ||
|
|
||
| let hasIssues = false; | ||
|
|
||
| // Check for unused files | ||
| if (result.files && result.files.length > 0) { | ||
| result.files.forEach((file) => issues.unusedFiles.add(file)); | ||
| hasIssues = true; | ||
| } | ||
|
|
||
| // Parse each file's issues | ||
| if (result.issues && result.issues.length > 0) { | ||
| result.issues.forEach((fileIssue) => { | ||
| if (fileIssue.dependencies && fileIssue.dependencies.length > 0) { | ||
| fileIssue.dependencies.forEach((dep) => issues.dependencies.add(dep)); | ||
| hasIssues = true; | ||
| } | ||
| if (fileIssue.devDependencies && fileIssue.devDependencies.length > 0) { | ||
| fileIssue.devDependencies.forEach((dep) => issues.devDependencies.add(dep)); | ||
| hasIssues = true; | ||
| } | ||
| if (fileIssue.unresolved && fileIssue.unresolved.length > 0) { | ||
| fileIssue.unresolved.forEach((item) => issues.unresolved.add(item.name)); | ||
| hasIssues = true; | ||
| } | ||
| if (fileIssue.exports && fileIssue.exports.length > 0) { | ||
| fileIssue.exports.forEach((exp) => { | ||
| issues.unusedExports.push({ | ||
| file: fileIssue.file, | ||
| name: exp.name, | ||
| }); | ||
| }); | ||
| hasIssues = true; | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| if (hasIssues) { | ||
| console.error("❌ Knip found issues:\n"); | ||
| if (issues.dependencies.size > 0) { | ||
| console.error("Unused dependencies:"); | ||
| Array.from(issues.dependencies) | ||
| .sort() | ||
| .forEach((d) => console.error(` - ${d.name}`)); | ||
| console.error(""); | ||
| } | ||
| if (issues.devDependencies.size > 0) { | ||
| console.error("Unused devDependencies:"); | ||
| Array.from(issues.devDependencies) | ||
| .sort() | ||
| .forEach((d) => console.error(` - ${d.name}`)); | ||
| console.error(""); | ||
| } | ||
| if (issues.unresolved.size > 0) { | ||
| console.error("Unresolved imports:"); | ||
| Array.from(issues.unresolved) | ||
| .sort() | ||
| .forEach((d) => console.error(` - ${d}`)); | ||
| console.error(""); | ||
| } | ||
| if (issues.unusedFiles.size > 0) { | ||
| console.error("Unused files:"); | ||
| Array.from(issues.unusedFiles) | ||
| .sort() | ||
| .forEach((f) => console.error(` - ${f}`)); | ||
| console.error(""); | ||
| } | ||
| if (issues.unusedExports.length > 0) { | ||
| console.error("Unused exports:"); | ||
| issues.unusedExports | ||
| .sort((a, b) => a.file.localeCompare(b.file)) | ||
| .forEach((exp) => console.error(` - ${exp.name} (${exp.file})`)); | ||
| console.error(""); | ||
| } | ||
| return true; // has issues | ||
| } | ||
| return false; // no issues | ||
| } | ||
|
|
||
| try { | ||
| const output = execSync("npx knip --reporter json", { | ||
| encoding: "utf-8", | ||
| stdio: ["pipe", "pipe", "pipe"], | ||
| }); | ||
| const result = JSON.parse(output); | ||
| const hasIssues = parseAndReportKnipResults(result); | ||
| if (hasIssues) { | ||
| process.exit(1); | ||
| } | ||
| console.log("✅ Knip passed: no issues found"); | ||
| } catch (error) { | ||
| if (error.stdout) { | ||
| try { | ||
| const result = JSON.parse(error.stdout); | ||
| parseAndReportKnipResults(result); | ||
| } catch (parseError) { | ||
| console.error("❌ Knip failed (could not parse JSON output):"); | ||
| console.error(error.message); | ||
| } | ||
| } else { | ||
| console.error("❌ Knip failed:"); | ||
| console.error(error.message); | ||
| } | ||
| process.exit(1); | ||
| } | ||
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.