Skip to content

[fix] Remove unused dependencies, add check to run-qa-checks #484#485

Merged
nemesifier merged 5 commits intoopenwisp:masterfrom
PRoIISHAAN:master
Jan 27, 2026
Merged

[fix] Remove unused dependencies, add check to run-qa-checks #484#485
nemesifier merged 5 commits intoopenwisp:masterfrom
PRoIISHAAN:master

Conversation

@PRoIISHAAN
Copy link
Contributor

@PRoIISHAAN PRoIISHAAN commented Jan 15, 2026

…equired knip files

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #484 .

Description of Changes

Removed unused dependencies
added knip
added knip.json and scripts/ci-knip.js

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

The PR introduces an automated unused dependency detection system to the CI/CD pipeline using the Knip tool. It adds a .nvmrc file to specify Node.js version management (lts/krypton), creates a knip.json configuration file to define scanning patterns and exclusions, updates the CI workflow to ensure Node.js is set up before subsequent steps, modifies package.json to redirect the main entry point to src/js/netjsongraph.js and adds knip and typescript as dev dependencies while removing acorn and husky. The run-qa-checks script is extended to invoke a new scripts/ci-knip.js script that executes Knip, parses results, and reports unused dependencies, unresolved imports, and unused files with exit code 1 on failure. A minor change exposes a map instance in an example HTML file for Selenium testing purposes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive The changes to public/example_templates/netjsonmap-indoormap-overlay.html (exposing window._geoMap) appear unrelated to the issue #484 objectives of removing unused dependencies and integrating knip. Clarify whether the window._geoMap change is intentional for this PR or should be in a separate PR addressing test infrastructure needs.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: removing unused dependencies and adding a knip check to run-qa-checks, which aligns with the primary objective in issue #484.
Description check ✅ Passed The description covers the key changes (removed unused dependencies, added knip, added knip.json and scripts/ci-knip.js) and follows the template with completed checklist items and issue reference.
Linked Issues check ✅ Passed All requirements from issue #484 are met: unused dependencies removed, knip integrated into run-qa-checks, knip.json configured, and scripts/ci-knip.js implements JSON parsing with appropriate exit codes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60f07a7 and de54c5d.

📒 Files selected for processing (1)
  • public/example_templates/netjsonmap-indoormap-overlay.html
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: openwisp/netjsongraph.js PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-22T22:37:11.271Z
Learning: Check for dependency vulnerabilities using `npm audit` or `yarn audit`
Learnt from: CR
Repo: openwisp/netjsongraph.js PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-22T22:37:11.271Z
Learning: Applies to **/*.{js,ts,css,scss,json} : Format code using `openwisp-qa-format` command with Python virtualenv enabled and `yarn lint:fix` (runs eslint --fix and prettier via lint-staged)
🔇 Additional comments (1)
public/example_templates/netjsonmap-indoormap-overlay.html (1)

153-155: LGTM — clear Selenium hook.

Exposing the instance here is straightforward and scoped to the example template.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
package.json (1)

13-21: Remove orphaned lint-staged configuration and precommit script.

husky has been removed from devDependencies and there is no .husky directory, so the lint-staged configuration (lines 18-21) and precommit script (line 13) will not execute. Either:

  1. Re-add husky and configure .husky/pre-commit to run lint-staged, or
  2. Remove the lint-staged configuration block and the precommit script entry.
🤖 Fix all issues with AI agents
In `@package.json`:
- Around line 81-84: Update package.json by removing "knip" and "typescript"
from the top-level "dependencies" object and add them to the "devDependencies"
object instead; ensure the exact package names "knip" and "typescript" remain
with their versions (e.g., "^5.81.0" and "^5.9.3") and run npm/yarn install to
verify lockfile updates.

In `@run-qa-checks`:
- Around line 15-16: Remove the trailing whitespace at the end of the "node
scripts/ci-knip.js" command in the run-qa-checks script so the line ends exactly
with "node scripts/ci-knip.js" (no extra spaces); update the file to strip that
trailing space and commit the change.

In `@scripts/ci-knip.js`:
- Around line 49-61: The Array.from(...).sort() calls are sorting dependency
objects by string coercion instead of their name property; update both
Array.from(issues.dependencies).sort() and
Array.from(issues.devDependencies).sort() to use a comparator that compares the
objects' name properties (e.g. (a,b) => a.name.localeCompare(b.name) with a safe
fallback if name is missing) so the entries are sorted by dependency name before
forEach logging.
🧹 Nitpick comments (1)
scripts/ci-knip.js (1)

100-114: Consider logging stderr for debugging non-JSON failures.

The error handling correctly attempts to parse JSON from error.stdout when knip finds issues (exits non-zero). However, when JSON parsing fails, additional context from error.stderr could help diagnose the root cause.

Optional enhancement
     } catch (parseError) {
       console.error("❌ Knip failed (could not parse JSON output):");
       console.error(error.message);
+      if (error.stderr) {
+        console.error("stderr:", error.stderr);
+      }
     }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c25569f and 0025e9e.

⛔ Files ignored due to path filters (2)
  • lib/js/echarts-gl.min.js is excluded by !**/*.min.js
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (29)
  • .github/workflows/ci.yml
  • .nvmrc
  • CHANGELOG.rst
  • examples/load_data_geo_extent/index.html
  • index.html
  • knip.json
  • package.json
  • public/example_templates/netjson-clustering.html
  • public/example_templates/netjson-dateParse.html
  • public/example_templates/netjson-multipleInterfaces.html
  • public/example_templates/netjson-searchElements.html
  • public/example_templates/netjson-switchGraphMode.html
  • public/example_templates/netjson-switchRenderMode.html
  • public/example_templates/netjsongraph-graphGL.html
  • public/example_templates/netjsongraph-multipleLinks.html
  • public/example_templates/netjsongraph-nodeExpand.html
  • public/example_templates/netjsongraph-wifi-clients.html
  • public/example_templates/netjsongraph.html
  • public/example_templates/netjsonmap-animation.html
  • public/example_templates/netjsonmap-appendData.html
  • public/example_templates/netjsonmap-appendData2.html
  • public/example_templates/netjsonmap-indoormap.html
  • public/example_templates/netjsonmap-multipleTiles.html
  • public/example_templates/netjsonmap-nodeTiles.html
  • public/example_templates/netjsonmap-plugins.html
  • public/example_templates/netjsonmap.html
  • public/example_templates/njg-geojson.html
  • run-qa-checks
  • scripts/ci-knip.js
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-04T08:00:40.936Z
Learnt from: dee077
Repo: openwisp/netjsongraph.js PR: 417
File: src/js/netjsongraph.util.js:1302-1341
Timestamp: 2026-01-04T08:00:40.936Z
Learning: In the netjsongraph.js codebase, the `== null` pattern is intentionally used to check for both null and undefined values in a single comparison, which is a well-established JavaScript idiom and should not be flagged for replacement with strict equality checks.

Applied to files:

  • public/example_templates/netjson-switchRenderMode.html
  • public/example_templates/netjsonmap-multipleTiles.html
  • public/example_templates/netjson-searchElements.html
  • public/example_templates/netjsongraph-nodeExpand.html
  • public/example_templates/netjson-switchGraphMode.html
  • public/example_templates/netjson-multipleInterfaces.html
  • public/example_templates/netjsonmap-nodeTiles.html
  • public/example_templates/netjsongraph-multipleLinks.html
  • index.html
  • public/example_templates/netjson-dateParse.html
  • public/example_templates/netjsongraph-graphGL.html
  • public/example_templates/netjsonmap-appendData.html
  • public/example_templates/netjsonmap.html
  • public/example_templates/netjsonmap-appendData2.html
  • public/example_templates/netjsongraph.html
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Tests and Coverage
🔇 Additional comments (31)
public/example_templates/netjsonmap-animation.html (1)

1-1: LGTM — Doctype casing normalization.

The HTML5 DOCTYPE declaration is case-insensitive, so this lowercase normalization is valid and maintains consistency across template files.

public/example_templates/netjsonmap-plugins.html (1)

1-1: LGTM! DOCTYPE normalization for consistency.

The lowercase DOCTYPE declaration is valid HTML5 and aligns with the consistency improvements applied across multiple example templates.

public/example_templates/netjsonmap-appendData2.html (1)

1-1: LGTM!

The DOCTYPE normalization to lowercase is valid and contributes to consistency across the HTML templates. Both forms are functionally equivalent in HTML5.

public/example_templates/netjsongraph-nodeExpand.html (1)

1-1: LGTM! Valid HTML5 doctype normalization.

The change from uppercase to lowercase doctype declaration is valid—both forms are equivalent in HTML5. This normalization improves consistency across template files.

public/example_templates/netjsongraph.html (1)

1-1: LGTM! Doctype normalization applied.

The DOCTYPE declaration has been normalized to lowercase, which is valid HTML5 syntax. This formatting change has no functional impact.

examples/load_data_geo_extent/index.html (1)

1-1: LGTM! Doctype normalization applied.

The DOCTYPE declaration has been normalized to lowercase, consistent with the broader formatting updates across HTML templates in this PR.

public/example_templates/netjsonmap-nodeTiles.html (1)

1-1: LGTM! Doctype normalization applied.

The DOCTYPE declaration has been normalized to lowercase. This formatting change aligns with the HTML template consistency updates throughout the repository.

public/example_templates/netjson-switchRenderMode.html (1)

1-1: LGTM! Doctype normalization applied.

The DOCTYPE declaration has been normalized to lowercase, maintaining consistency with other HTML templates in this PR.

public/example_templates/netjsongraph-graphGL.html (1)

1-1: LGTM! Doctype normalization applied.

The DOCTYPE declaration has been normalized to lowercase. This formatting change is consistent with the HTML template normalization across the repository.

public/example_templates/netjson-switchGraphMode.html (1)

1-1: LGTM!

The lowercase DOCTYPE declaration is valid per HTML5 spec and aligns with modern conventions. This stylistic normalization is consistent across the template files.

public/example_templates/netjsonmap-indoormap.html (1)

1-1: LGTM!

Consistent DOCTYPE normalization matching the other template files.

public/example_templates/netjson-dateParse.html (1)

1-1: LGTM!

Consistent DOCTYPE normalization.

public/example_templates/netjson-multipleInterfaces.html (1)

1-1: LGTM!

Consistent DOCTYPE normalization.

public/example_templates/netjsonmap-appendData.html (1)

1-1: LGTM!

Consistent DOCTYPE normalization completing the standardization across example templates.

public/example_templates/netjsonmap-multipleTiles.html (1)

1-1: LGTM!

Lowercase <!doctype html> is the canonical HTML5 form and functionally equivalent to the uppercase variant.

public/example_templates/netjson-searchElements.html (1)

1-1: LGTM!

Consistent doctype normalization across templates.

public/example_templates/njg-geojson.html (1)

1-1: LGTM!

Consistent doctype normalization.

public/example_templates/netjsonmap.html (1)

1-1: LGTM!

Consistent doctype normalization.

public/example_templates/netjsongraph-multipleLinks.html (1)

1-1: LGTM!

Consistent doctype normalization.

.nvmrc (1)

1-1: LGTM!

Using lts/krypton (Node.js 22.x) is a valid and recent LTS choice. The .nvmrc file correctly specifies the Node.js version for tooling and CI.

.github/workflows/ci.yml (2)

21-25: LGTM!

The Node.js setup step correctly references the .nvmrc file and is properly placed before the yarn cache retrieval step.


58-62: LGTM!

Consistent Node.js setup in the build job, mirroring the qa-checks job configuration.

knip.json (1)

1-6: The knip.json configuration is sufficient as-is. Knip automatically detects entry points from package.json fields (main/bin/exports/scripts), and this project's entry point is already defined via "main": "src/js/netjsongraph.js". Explicitly adding an entry field would be redundant and contradicts Knip's documented best practice of relying on automatic detection before manual configuration.

Likely an incorrect or invalid review comment.

public/example_templates/netjson-clustering.html (1)

73-95: LGTM!

The reformatted NetJSONGraph constructor maintains identical functionality while improving readability. The configuration options are well-organized and the commented examples for nodeCategories provide helpful customization guidance.

CHANGELOG.rst (1)

1-97: LGTM!

The changelog formatting is now consistent with standard reStructuredText conventions. Section headers use proper decoration characters, and version entries are well-organized with clear feature, changes, and bugfix sections.

index.html (3)

1-1: LGTM!

Lowercase <!doctype html> is the recommended HTML5 standard form.


36-42: LGTM!

CSS formatting improvements: multi-line transition declaration and double-quoted font-family value improve readability and maintain consistency.


248-269: LGTM!

The theme toggle logic is correct. String quote standardization to double quotes is consistent throughout the file.

scripts/ci-knip.js (2)

3-10: LGTM!

Good use of Sets for deduplication of dependencies, devDependencies, unresolved imports, and unused files. The array for unusedExports appropriately preserves file context for each export.


89-99: LGTM!

The execution flow correctly runs knip with JSON reporter and handles the success path. Using execSync with explicit stdio pipes ensures proper output capture.

public/example_templates/netjsongraph-wifi-clients.html (1)

122-129: The attachClientsOverlay method is properly defined and the configuration parameters are valid.

The new onReady hook correctly integrates the clients overlay plugin. The method is properly bound to the NetJSONGraph instance and accepts all the provided options: radius: 5, gap: 3, and minZoomLevel: 1. These values are all valid and compatible with the function's implementation.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 15, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 15, 2026
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I will test asap.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 19, 2026
@PRoIISHAAN
Copy link
Contributor Author

@nemesifier I think you have merged this PR, why has it not been marked as merged, shall I close this PR myself?

@nemesifier
Copy link
Member

@nemesifier I think you have merged this PR, why has it not been marked as merged, shall I close this PR myself?

I haven't merged this yet.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PRoIISHAAN could you please rebase this on the latest master?

@coderabbitai coderabbitai bot added the javascript Pull requests that update Javascript code label Jan 23, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 23, 2026
@PRoIISHAAN
Copy link
Contributor Author

rebase done

@PRoIISHAAN PRoIISHAAN requested a review from nemesifier January 23, 2026 18:49
@nemesifier nemesifier merged commit 51f375c into openwisp:master Jan 27, 2026
4 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in OpenWISP Contributor's Board Jan 27, 2026
@nemesifier
Copy link
Member

Thanks @PRoIISHAAN 🙏

@coderabbitai coderabbitai bot mentioned this pull request Feb 2, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement javascript Pull requests that update Javascript code

Projects

Development

Successfully merging this pull request may close these issues.

[bug] Remove unused dependencies, add check to run-qa-checks

2 participants