Skip to content

[qa:fix] Ensure prettier auto indents and checks example files#491

Merged
nemesifier merged 2 commits intomasterfrom
autoindent-examples
Jan 23, 2026
Merged

[qa:fix] Ensure prettier auto indents and checks example files#491
nemesifier merged 2 commits intomasterfrom
autoindent-examples

Conversation

@nemesifier
Copy link
Copy Markdown
Member

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.
  • N/A I have updated the documentation.

Description of Changes

The example files are not getting automatically checked by prettier, there were not only indentation errors but also 1 missing HTML closing tag. I made sure examples are automatically checked during QA checks.

@nemesifier nemesifier self-assigned this Jan 22, 2026
@nemesifier nemesifier added the javascript Pull requests that update Javascript code label Jan 22, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

Adds Prettier formatting and QA checks for HTML example templates and updates lint-staged to run Prettier on files matching public/example_templates/**/*.html. Many example HTML files normalize the DOCTYPE to <!doctype html>, adjust HTML/CSS formatting, and fix minor comments. netjsongraph-wifi-clients.html adds a call to attachClientsOverlay in onReady. netjsongraph-elementsLegend.html reorganizes the NetJSONGraph options object (moves el into graphConfig and repositions prepareData and category configs).

Sequence Diagram(s)

(Skipped — changes are formatting, lint/QA updates, and configuration/templating adjustments without a new multi-component sequential control flow.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

bug

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: configuring prettier to auto-indent and check example template files, which aligns with all the file modifications.
Description check ✅ Passed The description provides context (example files lacked prettier checks and had indentation errors) and explains the solution, meeting the template's Description of Changes requirement.

✏️ 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 e991e75 and ac56511.

📒 Files selected for processing (24)
  • 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-elementsLegend.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-overlay.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
✅ Files skipped from review due to trivial changes (2)
  • public/example_templates/netjsonmap-indoormap-overlay.html
  • public/example_templates/netjsongraph-multipleLinks.html
🚧 Files skipped from review as they are similar to previous changes (16)
  • public/example_templates/netjsongraph-graphGL.html
  • public/example_templates/netjsonmap-appendData2.html
  • public/example_templates/netjsonmap-animation.html
  • public/example_templates/netjsonmap-multipleTiles.html
  • public/example_templates/netjsonmap-nodeTiles.html
  • public/example_templates/netjson-switchRenderMode.html
  • public/example_templates/netjsonmap-plugins.html
  • public/example_templates/netjson-dateParse.html
  • public/example_templates/netjsongraph-wifi-clients.html
  • public/example_templates/netjson-switchGraphMode.html
  • package.json
  • public/example_templates/netjsongraph-nodeExpand.html
  • public/example_templates/netjson-searchElements.html
  • public/example_templates/netjsonmap-indoormap.html
  • public/example_templates/netjsonmap-appendData.html
  • public/example_templates/njg-geojson.html
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: openwisp/netjsongraph.js PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-22T22:37:11.257Z
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)
Learnt from: CR
Repo: openwisp/netjsongraph.js PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-22T22:37:11.257Z
Learning: Avoid arbitrary formatting changes outside of the code formatting tools (openwisp-qa-format and yarn lint:fix)
Learnt from: CR
Repo: openwisp/netjsongraph.js PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-22T22:37:11.257Z
Learning: Run QA checks using `./run-qa-checks` before committing code
📚 Learning: 2026-01-22T22:37:11.257Z
Learnt from: CR
Repo: openwisp/netjsongraph.js PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-22T22:37:11.257Z
Learning: Applies to test/netjsongraph.browser.test.js : Write browser tests in test/netjsongraph.browser.test.js using Chrome/ChromeDriver and run with `yarn test test/netjsongraph.browser.test.js`

Applied to files:

  • public/example_templates/netjsongraph.html
  • public/example_templates/netjsonmap.html
  • public/example_templates/netjson-multipleInterfaces.html
📚 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/netjsongraph.html
  • public/example_templates/netjsonmap.html
  • public/example_templates/netjson-multipleInterfaces.html
📚 Learning: 2026-01-20T00:56:47.084Z
Learnt from: dee077
Repo: openwisp/netjsongraph.js PR: 417
File: src/js/netjsongraph.core.js:132-145
Timestamp: 2026-01-20T00:56:47.084Z
Learning: In the netjsongraph.js codebase, the data model does not support parallel links (multiple links between the same pair of nodes), so storing a single link per "source~target" key in nodeLinkIndex is appropriate and won't overwrite any links.

Applied to files:

  • public/example_templates/netjsongraph.html
  • public/example_templates/netjsonmap.html
  • public/example_templates/netjson-multipleInterfaces.html
  • public/example_templates/netjsongraph-elementsLegend.html
📚 Learning: 2026-01-22T22:37:11.257Z
Learnt from: CR
Repo: openwisp/netjsongraph.js PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-22T22:37:11.257Z
Learning: Avoid arbitrary formatting changes outside of the code formatting tools (openwisp-qa-format and yarn lint:fix)

Applied to files:

  • run-qa-checks
📚 Learning: 2026-01-22T22:37:11.257Z
Learnt from: CR
Repo: openwisp/netjsongraph.js PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-22T22:37:11.257Z
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)

Applied to files:

  • run-qa-checks
📚 Learning: 2026-01-22T22:37:11.257Z
Learnt from: CR
Repo: openwisp/netjsongraph.js PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-22T22:37:11.257Z
Learning: Run QA checks using `./run-qa-checks` before committing code

Applied to files:

  • run-qa-checks
⏰ 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 (6)
public/example_templates/netjson-clustering.html (1)

73-99: Formatting-only change looks good.
No functional differences spotted in the options object.

public/example_templates/netjsonmap.html (1)

1-1: LGTM!

The lowercase <!doctype html> is the canonical HTML5 form and matches Prettier's default formatting. This is consistent with the PR objective of ensuring Prettier auto-formats example files.

run-qa-checks (1)

7-9: LGTM!

Good addition of Prettier HTML formatting checks with a helpful error message guiding developers on how to fix issues. The prettier --check command validates without modifying files, which is appropriate for CI/QA checks.

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

1-1: LGTM!

The lowercase <!doctype html> is valid HTML5 and is Prettier's default normalization. This aligns with the PR objective to ensure consistent formatting across example templates. Based on learnings, this follows the project's approach of using yarn lint:fix which runs Prettier via lint-staged.

public/example_templates/netjsongraph.html (1)

1-1: LGTM!

The lowercase <!doctype html> is valid HTML5 and matches Prettier's default formatting convention. No functional changes introduced.

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

1-227: LGTM!

The file has been properly reformatted by Prettier:

  • DOCTYPE normalized to lowercase (valid HTML5)
  • Consistent indentation throughout CSS and JavaScript
  • The previously flagged duplicate font-family declaration has been resolved (only font-family: Arial, sans-serif; remains at line 37)
  • NetJSONGraph configuration structure is intact with no functional changes

✏️ 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
Copy Markdown

@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: 1

🤖 Fix all issues with AI agents
In `@public/example_templates/netjsongraph-elementsLegend.html`:
- Around line 37-38: Remove the duplicate font-family declaration so the
stylesheet doesn't contain dead code: in the CSS block that currently lists
"font-family: Arial, sans-serif;" followed immediately by "font-family:
sans-serif;", delete one of the two lines (keep the intended rule, e.g.,
"font-family: Arial, sans-serif;" if you want Arial fallback or "font-family:
sans-serif;" if only a generic family is needed) so only a single font-family
declaration remains.
🧹 Nitpick comments (3)
public/example_templates/netjson-searchElements.html (1)

11-15: Consider consolidating duplicate .njg-searchBtn rules.

The .njg-searchBtn class is defined twice. The second definition (lines 32-35) overrides the first (lines 11-15), making the padding declaration in the first definition ineffective. Consider merging these into a single rule to improve maintainability.

♻️ Proposed consolidation

Remove the duplicate definition and keep a single consolidated rule:

 .njg-searchBtn {
   border: none;
   border-radius: 5px;
   padding: 4px 8px;
 }
 
 .njg-searchInput {
   padding: 4px;
   border-radius: 5px;
   border: none;
   max-width: 70%;
 }
 
 .njg-searchContainer {
   margin: 0 auto;
   width: 80%;
   text-align: center;
   left: 0;
   right: 0;
 }
-
- .njg-searchBtn {
-   border: none;
-   border-radius: 5px;
- }

Also applies to: 32-35

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

205-221: Prefer forEach() over map() for side-effect-only operations.

map() creates a new array that is discarded here. Since you're only mutating existing objects without using return values, forEach() is more idiomatic and avoids unnecessary array allocation.

Suggested fix
         prepareData: (data) => {
-          data.nodes.map((node) => {
+          data.nodes.forEach((node) => {
             if (node.properties.gateway) {
               node.category = "gateway";
             } else {
               node.category = "default";
             }
           });
-          data.links.map((link) => {
+          data.links.forEach((link) => {
             if (
               link.properties.type === "wireless" ||
               link.properties.type === "ethernet"
             ) {
               link.category = link.properties.type;
             }
           });
         },
public/example_templates/netjsongraph-wifi-clients.html (1)

122-134: Guard overlay attachment in case the plugin isn’t bundled.
If this example is opened with a build that omits the clients overlay plugin, Line 124 will throw and prevent rendering. A simple feature check keeps the template resilient.

🛠️ Suggested guard
       onReady() {
         // Attach reusable overlay plugin shipped with the bundle
-        this.attachClientsOverlay({
-          radius: 5,
-          gap: 3,
-          minZoomLevel: 1,
-        });
+        if (typeof this.attachClientsOverlay === "function") {
+          this.attachClientsOverlay({
+            radius: 5,
+            gap: 3,
+            minZoomLevel: 1,
+          });
+        } else {
+          console.warn("Clients overlay plugin not available in this build.");
+        }
       },
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 362c9c4 and 7989e39.

📒 Files selected for processing (23)
  • 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-elementsLegend.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
🧰 Additional context used
🧠 Learnings (2)
📚 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-multipleInterfaces.html
  • public/example_templates/netjsongraph-graphGL.html
  • public/example_templates/netjsonmap-appendData.html
  • public/example_templates/netjsongraph-nodeExpand.html
  • public/example_templates/netjson-dateParse.html
  • public/example_templates/netjsonmap-nodeTiles.html
  • public/example_templates/netjson-switchGraphMode.html
  • public/example_templates/netjsonmap.html
  • public/example_templates/netjsonmap-appendData2.html
  • public/example_templates/netjson-searchElements.html
  • public/example_templates/netjsongraph.html
  • public/example_templates/netjsonmap-multipleTiles.html
  • public/example_templates/netjsongraph-multipleLinks.html
  • public/example_templates/netjson-switchRenderMode.html
📚 Learning: 2026-01-20T00:56:47.084Z
Learnt from: dee077
Repo: openwisp/netjsongraph.js PR: 417
File: src/js/netjsongraph.core.js:132-145
Timestamp: 2026-01-20T00:56:47.084Z
Learning: In the netjsongraph.js codebase, the data model does not support parallel links (multiple links between the same pair of nodes), so storing a single link per "source~target" key in nodeLinkIndex is appropriate and won't overwrite any links.

Applied to files:

  • public/example_templates/netjson-multipleInterfaces.html
  • public/example_templates/netjsongraph-graphGL.html
  • public/example_templates/netjsonmap-appendData.html
  • public/example_templates/netjsongraph-nodeExpand.html
  • public/example_templates/netjson-dateParse.html
  • public/example_templates/netjsonmap-nodeTiles.html
  • public/example_templates/netjson-switchGraphMode.html
  • public/example_templates/netjsonmap.html
  • public/example_templates/netjsonmap-appendData2.html
  • public/example_templates/netjson-searchElements.html
  • public/example_templates/netjsongraph.html
  • public/example_templates/netjsonmap-multipleTiles.html
  • public/example_templates/netjsongraph-multipleLinks.html
  • public/example_templates/netjson-switchRenderMode.html
🔇 Additional comments (28)
public/example_templates/netjson-searchElements.html (1)

1-1: LGTM! DOCTYPE formatting standardized.

The lowercase DOCTYPE declaration is valid HTML5 and aligns with Prettier's formatting preferences for consistency across template files.

public/example_templates/netjsongraph-elementsLegend.html (3)

1-9: LGTM!

Proper HTML5 document structure with lowercase doctype, lang attribute, and well-formatted meta tags.


90-98: LGTM!

Legend markup is well-structured with semantic HTML elements.


227-228: LGTM!

Closing tags are properly formatted.

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

1-1: Consistent HTML5 doctype casing.

Looks good as a formatting-only normalization.

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

1-1: Consistent HTML5 doctype casing.

No functional changes here—LGTM.

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

1-1: Consistent HTML5 doctype casing.

Formatting-only update looks fine.

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

1-1: Consistent HTML5 doctype casing.

No concerns with this formatting change.

public/example_templates/netjsongraph.html (1)

1-1: Consistent HTML5 doctype casing.

LGTM as a style-only normalization.

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

1-1: Consistent HTML5 doctype casing.

No issues here.

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

1-1: LGTM!

The lowercase <!doctype html> is valid HTML5 and aligns with Prettier's default formatting. This standardization across template files is appropriate.

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

1-1: LGTM!

Doctype casing normalization consistent with repository-wide Prettier formatting standards.

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

1-1: LGTM!

Doctype casing normalization aligns with Prettier's HTML formatting defaults.

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

1-1: LGTM!

Consistent doctype casing normalization applied across template files.

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

1-1: LGTM!

Doctype formatting normalized to match Prettier's HTML output standards.

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

1-1: LGTM!

Consistent doctype casing normalization completes the HTML template formatting standardization.

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

1-1: Doctype normalization looks good.

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

73-95: Formatting-only update is fine.

public/example_templates/netjsonmap.html (1)

1-1: Doctype normalization looks good.

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

1-1: Doctype normalization looks good.

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

1-1: Doctype normalization looks good.

run-qa-checks (1)

7-8: No changes needed — prettier is available on PATH in CI.

The CI workflow (ci.yml) explicitly installs prettier globally via sudo npm install -g prettier before running ./run-qa-checks, ensuring prettier is on the PATH. The script executes as designed in its intended environment.

Likely an incorrect or invalid review comment.

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

1-1: Lowercase doctype is fine.

No functional impact; consistent formatting is good.

package.json (1)

18-25: Lint-staged HTML formatting looks good.

Adds consistent Prettier coverage for example templates.

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

1-1: Consistent doctype casing looks good.


10-20: CSS formatting is clean and readable.


72-91: Legend markup expansion is clear and maintainable.


104-120: Graph config formatting is tidy and consistent.

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

Comment thread public/example_templates/netjsongraph-elementsLegend.html Outdated
@github-project-automation github-project-automation Bot moved this from To do (general) to In progress in OpenWISP Contributor's Board Jan 22, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jan 22, 2026
@nemesifier nemesifier merged commit bedbfbb into master Jan 23, 2026
7 checks passed
@nemesifier nemesifier deleted the autoindent-examples branch January 23, 2026 17:50
@github-project-automation github-project-automation Bot moved this from In progress to Done in OpenWISP Contributor's Board Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug javascript Pull requests that update Javascript code

Projects

Development

Successfully merging this pull request may close these issues.

1 participant