Skip to content

Improve and introduce measures for consistent code style #4094

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Mattstir
Copy link
Contributor

@Mattstir Mattstir commented Aug 9, 2024

I'm highly passionate about clean code and a consistent code style, so I see this as a great opportunity to enhance WLED. 😉

By introducing ESLint, we can automatically enforce code style during each CI run (and hint at problems during a local npm build), ensuring that future changes adhere to the established guidelines. For now, I've aligned the rules with the suggestions in WLED's CONTRIBUTING.md and made them mandatory. This is now only a basic start, these rules can be easily expanded in the future to include more than just style.

I've also corrected the existing style issues in the .js files and js snippets in html files.

Note: This PR is purely stylistic with no logic changes. I hope you like it! 😄

Summary by CodeRabbit

  • New Features

    • Added linting to the build and CI process, ensuring code style consistency across JavaScript and HTML files.
  • Documentation

    • Updated contribution guidelines to include instructions for running lint checks and adhering to code style conventions.
  • Style

    • Applied consistent formatting and whitespace improvements throughout JavaScript and HTML files for better readability.
    • Minor adjustments to function signatures for parameter spacing.
  • Chores

    • Integrated ESLint configuration and related dependencies into the project.
    • Updated build and CI scripts to include linting steps.

@Mattstir
Copy link
Contributor Author

Mattstir commented Aug 9, 2024

Also note that each style rule got introduced in its own commit so we could easily revert one of them if not wanted ;)

@softhack007
Copy link
Collaborator

softhack007 commented Aug 9, 2024

@Mattstir interesting idea 😃

Two questions come to my mind:

  • are these rules only applied to JS and html? Because we already have a problem with flash size, and additional "beautification" in the embedded webpages could lead to increased flash size (bad).
  • do you have a list of the rules? Because I think it's better to first agree on the rule set, and then implement automated checks as a second step.

@Mattstir
Copy link
Contributor Author

Mattstir commented Aug 9, 2024

@softhack007 Thanks for your interest :D

  • With this pr applied to .js files and the js snippets that are inside the html files. Of course, bundle size is a very important issue and I was thinking about that when I added this. After each rule I added, I ran npm build, but nothing changed in the built files. So I assume that the minifying tool you guys use html-minifier-terser is already stripping whitespaces and comments (I haven't fully researched how you configure it now, but as I basically only changed whitespaces and these seem to be stripped again, I'm optimistic 🤩).

  • You can find the rules I added in the configuration file I added eslint.config.mjs.
    First, I extended the recommended rules from https://eslint.org/docs/latest/rules/ (see the rules that have ✅), but I switched some of them to off or just to warn not to flag any current code with errors.
    Then I added some style rules from https://eslint.style/rules

    "@stylistic/js/function-call-spacing": ["error", "never"],
    "@stylistic/js/key-spacing": "error",
    "@stylistic/js/keyword-spacing": "error",
    "@stylistic/js/no-extra-semi": "error",
    "@stylistic/js/no-whitespace-before-property": "error",
    "@stylistic/js/space-before-blocks": "error",
    "@stylistic/js/space-infix-ops": "error",
    "@stylistic/js/spaced-comment": "error"

I selected these based on the desired style in the CONTRIBUTING.md file.

@softhack007 softhack007 added discussion waiting for feedback addition information needed to better understand the issue labels Sep 28, 2024
@ingDIY
Copy link
Contributor

ingDIY commented Oct 17, 2024

I'm highly passionate about clean code and a consistent code style, so I see this as a great opportunity to enhance WLED. 😉

By introducing ESLint, we can automatically enforce code style during each CI run (and hint at problems during a local npm build), ensuring that future changes adhere to the established guidelines. For now, I've aligned the rules with the suggestions in WLED's CONTRIBUTING.md and made them mandatory. This is now only a basic start, these rules can be easily expanded in the future to include more than just style.

I've also corrected the existing style issues in the .js files and js snippets in html files.

Note: This PR is purely stylistic with no logic changes. I hope you like it! 😄

WOW code formatting and cleaning is something I also would like to implement in WLED, but also for C and H files.
we could use uncrustify.

I'll follow this thread!

@netmindz netmindz changed the base branch from 0_15 to main December 16, 2024 13:33
Copy link

Hey! This pull request has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs.
Thank you for contributing to WLED! ❤️

@github-actions github-actions bot added the stale This issue will be closed soon because of prolonged inactivity label Apr 16, 2025
Copy link

coderabbitai bot commented Apr 16, 2025

Walkthrough

This change set introduces project-wide JavaScript linting and enforces consistent code style using ESLint. A new ESLint configuration file is added, and the development workflow is updated to include linting steps in both the GitHub Actions workflow and the package.json scripts. Several ESLint-related packages are added as development dependencies. The contribution guidelines are updated to instruct contributors on running lint checks. Across numerous JavaScript and HTML files, code formatting is standardized, primarily through whitespace and spacing adjustments, without altering logic or functionality. A few files explicitly disable ESLint checks via comments.

Changes

Files/Paths Change Summary
.github/workflows/wled-ci.yml Renamed CI job from "Test cdata.js" to "Test & Lint"; added a separate linting step (npm run lint) after testing.
package.json Added "lint" script and modified "build" to run lint before build; introduced "devDependencies" for ESLint and related plugins.
eslint.config.mjs Added new ESLint configuration file with project-specific rules, plugin usage, and file targeting for both JavaScript and HTML files.
CONTRIBUTING.md Updated contribution guidelines to mention JavaScript linting via npm lint or npm run build.
wled00/data/iro.js
wled00/data/rangetouch.js
Added file-level ESLint disable comments at the top of each file.
tools/fps_test.htm
tools/json_test.htm
wled00/data/cpal/cpal.htm
wled00/data/dmxmap.htm
wled00/data/edit.htm
wled00/data/index.js
wled00/data/liveview.htm
wled00/data/liveviewws2D.htm
wled00/data/msg.htm
wled00/data/pixart/boxdraw.js
wled00/data/pixart/getPixelValues.js
wled00/data/pixart/pixart.js
wled00/data/pixart/statics.js
wled00/data/settings.htm
wled00/data/settings_2D.htm
wled00/data/settings_dmx.htm
wled00/data/settings_leds.htm
wled00/data/settings_sec.htm
wled00/data/settings_sync.htm
wled00/data/settings_time.htm
wled00/data/settings_ui.htm
wled00/data/settings_um.htm
wled00/data/settings_wifi.htm
wled00/data/update.htm
Applied consistent code style and formatting changes: added spaces around operators, after commas, and inside parentheses; adjusted function signatures for spacing; reformatted comments for readability. No logic or control flow changes, except for a minor addition of a missing function call in settings_leds.htm to update the UI. In msg.htm, corrected function statement termination.
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Nitpick comments (3)
eslint.config.mjs (2)

3-3: Add missing semicolon for consistency.

The import statement for the HTML plugin is missing a semicolon, while the other import statements have semicolons.

-import html from "eslint-plugin-html"
+import html from "eslint-plugin-html";

6-6: Fix typo in comment.

There's a small typo in the comment.

-// to not complelty change up the whole style at once and introduce huge rebasing problems disable a handfull of recommended rules for now
+// to not completely change up the whole style at once and introduce huge rebasing problems disable a handful of recommended rules for now
CONTRIBUTING.md (1)

24-24: Fix typos in the JavaScript linting guidance.

There are a couple of typos in the new linting guidance.

-For javscript content you can use `npm lint` (or just the normal `npm run build` that also executes lint) to make sure you ather to our style.
+For JavaScript content you can use `npm lint` (or just the normal `npm run build` that also executes lint) to make sure you adhere to our style.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18e0ec9 and 17a6fa5.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (30)
  • .github/workflows/wled-ci.yml (2 hunks)
  • CONTRIBUTING.md (1 hunks)
  • eslint.config.mjs (1 hunks)
  • package.json (2 hunks)
  • tools/fps_test.htm (5 hunks)
  • tools/json_test.htm (1 hunks)
  • wled00/data/cpal/cpal.htm (17 hunks)
  • wled00/data/dmxmap.htm (1 hunks)
  • wled00/data/edit.htm (9 hunks)
  • wled00/data/index.js (100 hunks)
  • wled00/data/iro.js (1 hunks)
  • wled00/data/liveview.htm (3 hunks)
  • wled00/data/liveviewws2D.htm (3 hunks)
  • wled00/data/msg.htm (1 hunks)
  • wled00/data/pixart/boxdraw.js (2 hunks)
  • wled00/data/pixart/getPixelValues.js (12 hunks)
  • wled00/data/pixart/pixart.js (15 hunks)
  • wled00/data/pixart/statics.js (2 hunks)
  • wled00/data/rangetouch.js (1 hunks)
  • wled00/data/settings.htm (3 hunks)
  • wled00/data/settings_2D.htm (8 hunks)
  • wled00/data/settings_dmx.htm (4 hunks)
  • wled00/data/settings_leds.htm (21 hunks)
  • wled00/data/settings_sec.htm (4 hunks)
  • wled00/data/settings_sync.htm (4 hunks)
  • wled00/data/settings_time.htm (5 hunks)
  • wled00/data/settings_ui.htm (8 hunks)
  • wled00/data/settings_um.htm (13 hunks)
  • wled00/data/settings_wifi.htm (6 hunks)
  • wled00/data/update.htm (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
wled00/data/pixart/pixart.js

[error] 231-231: Comparing to itself is potentially pointless.

(lint/suspicious/noSelfCompare)

wled00/data/index.js

[error] 859-859: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 1899-1899: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2427-2427: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2428-2428: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🪛 GitHub Check: Build Enviornments (esp32s3_4M_qspi)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32s3dev_8MB_opi)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32_wrover)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32s3dev_16MB_opi)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp01_1m_full_160)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32c3dev)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (lolin_s2_mini)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32dev)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32dev_audioreactive)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32_eth)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp8266_2m_160)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (nodemcuv2_160)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp01_1m_full)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp8266_2m)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (nodemcuv2)
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Test & Lint
wled00/data/edit.htm

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🔇 Additional comments (57)
eslint.config.mjs (2)

7-31: Good configuration setup with graduated approach to linting.

The common rules configuration is well-structured, with a thoughtful approach of disabling some rules and downgrading others to warnings initially. This allows for a gradual introduction of stricter linting without creating an immediate burden on the codebase. The stylistic rules chosen align with the style preferences in CONTRIBUTING.md.


33-82: Well-organized configuration with appropriate separation of concerns.

The export configuration is well-structured with separate configurations for different file types and locations. The use of common rules across configurations reduces duplication and ensures consistency.

wled00/data/rangetouch.js (1)

1-1: Good approach for third-party library.

Disabling ESLint for this third-party library is appropriate. It allows for integrating the ESLint workflow without requiring modifications to external code.

wled00/data/iro.js (1)

1-1: Good approach for third-party library.

Disabling ESLint for this third-party library is appropriate. It allows for integrating the ESLint workflow without requiring modifications to external code.

wled00/data/msg.htm (1)

8-8: Semicolon placement improved for style consistency.

The semicolon is now correctly placed inside the function body, aligning with standard JavaScript style and ESLint rules. No logic is affected.

.github/workflows/wled-ci.yml (1)

84-95: Linting integrated into CI workflow.

Adding npm run lint to the workflow ensures code style is enforced automatically. This is a best practice for code quality.

wled00/data/pixart/statics.js (1)

1-1: Comment formatting improved for consistency.

Spaces after // improve readability and match style guidelines. No logic is affected.

Also applies to: 26-26, 33-33

tools/json_test.htm (1)

85-95: Whitespace and spacing improved for style compliance.

Spaces after if and around operators improve readability and comply with linting rules. No logic is affected.

wled00/data/pixart/boxdraw.js (1)

12-55: Whitespace and formatting improved for readability.

Spacing and comment formatting changes enhance readability and comply with linting rules. No logic is affected.

wled00/data/update.htm (1)

8-9: Stylistic improvements approved.

Whitespace and comment formatting changes improve readability and align with project style guidelines. No logic is affected.

tools/fps_test.htm (1)

71-79: Whitespace and formatting changes approved.

All modifications are stylistic, improving code readability and consistency without affecting logic.

Also applies to: 85-86, 91-92, 94-95, 99-100, 104-104, 122-122, 128-128, 168-169, 179-179, 184-184

wled00/data/settings_wifi.htm (1)

14-15: Stylistic changes approved.

Whitespace and comment formatting changes enhance readability and maintain consistency with project style guidelines. No logic is affected.

Also applies to: 38-39, 57-57, 71-79, 85-85, 111-112, 115-116, 118-119, 122-125, 127-127, 129-129, 131-131, 137-138, 149-149, 170-170, 150-150

wled00/data/liveview.htm (1)

54-55: Whitespace and comment formatting changes approved.

All changes are stylistic, improving code readability and consistency without affecting logic.

Also applies to: 70-70, 72-72, 76-76, 80-83, 91-93

wled00/data/dmxmap.htm (1)

4-22: Stylistic whitespace changes approved.

Whitespace and formatting improvements enhance readability and maintain consistency with project style guidelines. No logic is affected.

wled00/data/pixart/getPixelValues.js (1)

5-319: Formatting and style improvements look good.

All changes are purely stylistic (spacing, comments, alignment) and do not affect logic or functionality. The code is now more consistent and readable.

wled00/data/liveviewws2D.htm (1)

21-81: Whitespace and formatting changes are correct.

The changes are limited to style and do not affect any logic or behavior. Code readability is improved.

wled00/data/settings_2D.htm (1)

8-304: Consistent formatting and style improvements.

All changes are stylistic and do not affect logic or functionality. The code is now more readable and consistent.

wled00/data/index.js (1)

1-3244: Formatting and whitespace changes are correct.

All changes are stylistic and do not affect logic or functionality. The code is now more consistent and readable. Static analysis hints (e.g., optional chaining, avoiding delete) can be considered in a future refactor, but are not required for this style-focused PR.

🧰 Tools
🪛 Biome (1.9.4)

[error] 406-406: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 412-412: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 420-420: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 420-420: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 420-420: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 620-620: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 859-859: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 1351-1351: Unexpected control character in a regular expression.

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)


[error] 1899-1899: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 1970-1971: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2427-2427: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2428-2428: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2483-2484: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2484-2485: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2485-2486: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2486-2487: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 2768-2769: Comparing to itself is potentially pointless.

(lint/suspicious/noSelfCompare)


[error] 3067-3068: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 2933-2933: This variable is used before its declaration.

The variable is declared here:

(lint/correctness/noInvalidUseBeforeDeclaration)


[error] 2940-2940: Shouldn't redeclare 'v'. Consider to delete it or rename it.

'v' is defined here:

(lint/suspicious/noRedeclare)


[error] 2944-2944: Shouldn't redeclare 'l2'. Consider to delete it or rename it.

'l2' is defined here:

(lint/suspicious/noRedeclare)


[error] 2947-2947: Shouldn't redeclare 'i'. Consider to delete it or rename it.

'i' is defined here:

(lint/suspicious/noRedeclare)


[error] 62-62: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.

(lint/suspicious/noGlobalIsFinite)

wled00/data/settings_sec.htm (2)

24-44: Whitespace and formatting changes are correct.

The changes are limited to style and do not affect any logic or behavior. Code readability is improved.


47-49: Whitespace and formatting changes are correct.

The changes are limited to style and do not affect any logic or behavior. Code readability is improved.

wled00/data/settings_time.htm (6)

8-11: Improved variable declarations spacing.

The variable declarations now have consistent spacing after the assignment operator, following standard JavaScript style conventions.


46-46: Enhanced slice operation readability.

The slice operation now has proper spacing around operators and parameters, making the code more readable.


63-65: Improved conditional expression formatting.

The conditional expressions now have consistent spacing around comparison operators and improved formatting.


70-84: Improved template string formatting.

Template string literals now have consistent spacing, making the code more readable and maintaining consistent style.


107-115: Enhanced loop and conditional formatting.

For loops and conditional expressions now have proper spacing, improving readability and maintaining consistent styling.


121-128: Standardized assignment operations spacing.

Assignment operations and expressions now have proper spacing, following JavaScript best practices.

wled00/data/settings_um.htm (8)

34-36: Improved comment and code formatting.

The conditional statement and comment now have proper spacing, following ESLint guidelines for code style.


57-57: Enhanced ternary operator spacing.

The ternary condition now has proper spacing around the operators, improving readability.


74-75: Standardized function spacing and formatting.

Functions now have consistent spacing between parameters and surrounding code blocks.


112-117: Improved string comparison and conditional checks.

String operations and conditional checks now have proper spacing, following JavaScript best practices.


129-133: Enhanced function declaration formatting.

Function declarations now have consistent spacing around default parameters and string concatenation operations.


159-166: Standardized indentation and input field generation.

The input field generation code now has proper spacing and consistent formatting around string operations.


177-180: Improved string concatenation formatting.

String concatenation operations now have proper spacing, making the code more readable.


260-280: Enhanced equality checks and parameter spacing.

Equality checks and function parameters now have consistent spacing, improving code readability.

wled00/data/cpal/cpal.htm (11)

195-196: Improved comment formatting.

The comment now has proper spacing after the comment delimiter, following ESLint guidelines.


203-204: Added spacing for array declaration comment.

The array declaration comment now has proper spacing, improving code readability.


214-233: Enhanced comment blocks and function spacing.

Comment blocks now have consistent spacing and formatting. Function header comments are properly formatted.


303-307: Improved conditional statement formatting.

The conditional statement now has proper spacing around operators, enhancing readability.


339-352: Enhanced function declaration and comment blocks.

Function declarations and comment blocks now have proper spacing and consistent formatting according to ESLint guidelines.


390-400: Standardized calculation expressions.

Mathematical expressions and array indexing now have consistent spacing, improving code readability.


493-510: Improved comment block formatting.

Comment blocks now have proper spacing and consistent structure, enhancing code readability.


524-530: Enhanced HTTP request formatting.

HTTP request code now has consistent spacing around string concatenation and variable references.


547-561: Improved comment formatting for palette handling.

The comments explaining palette handling now have proper spacing and consistent formatting.


657-663: Standardized conditional checks and string operations.

Conditional checks and string operations now have proper spacing around operators.


671-676: Enhanced conditional logic formatting.

The conditional logic for buttons now has proper spacing and consistent formatting.

wled00/data/settings_sync.htm (4)

7-12: Improved function and variable declarations.

Variable declarations and function definitions now have consistent spacing, following the ESLint guidelines implemented in this PR.


35-54: Enhanced loop constructs and assignment operations.

For loops and variable assignments now have proper spacing around operators and consistent formatting.


55-57: Standardized function declarations and ternary operations.

Function declarations and ternary operations now have consistent spacing and proper formatting.


68-68: Improved string manipulation formatting.

The string manipulation code now has proper spacing around slice operations and method chaining.

wled00/data/pixart/pixart.js (2)

1-8: Code style improvements in comments

The spacing after comment delimiters and around operators has been standardized to improve readability.


16-21: Consistent spacing and formatting improvements

Spacing has been standardized around operators, before blocks, after comments, and in function calls for better readability, meeting the ESLint code style requirements.

Also applies to: 39-41, 82-82, 101-102, 109-110, 129-134, 144-148, 147-156, 159-159, 176-178, 216-217, 230-235, 250-265, 271-273, 281-285, 292-295, 310-319, 325-330, 333-333, 361-364

wled00/data/settings.htm (1)

8-10: Consistent spacing and formatting improvements

The changes add proper spacing around variable declarations, function definitions, and string slicing expressions to improve code readability and conform to the project's ESLint configuration.

Also applies to: 41-42

wled00/data/edit.htm (1)

143-149: Consistent spacing and formatting improvements

Spacing has been standardized around braces, operators, function parameters, and in various control structures to improve code readability, meeting the ESLint code style requirements.

Also applies to: 156-168, 171-208, 213-237, 251-251, 269-271, 428-432, 433-442, 444-448, 450-455, 457-459, 465-504, 506-508, 509-513, 514-522, 523-525, 527-529, 568-574

wled00/data/settings_ui.htm (1)

13-47: Consistent spacing and formatting improvements

The changes add proper spacing in object definitions, conditional expressions, ternary operators, string concatenation, and event handlers to improve code readability and conform to the project's ESLint configuration.

Also applies to: 59-65, 81-89, 91-104, 174-174, 186-190, 211-211, 230-233, 270-272

package.json (1)

11-12: ESLint integration and dependency additions look great.

The addition of lint scripts and ESLint-related devDependencies is correct and follows best practices for enforcing code style and quality.

Also applies to: 32-37

wled00/data/settings_dmx.htm (1)

8-82: Whitespace and formatting improvements are correct and safe.

All changes are stylistic and do not affect logic or behavior. The code is now more readable and consistent.

wled00/data/settings_leds.htm (1)

8-927: Formatting and minor logic fix are correct and beneficial.

Whitespace and style changes improve readability and maintainability. The added call to enABL() in setABL() is a positive fix for UI consistency.

files: [
"tools/**/*.js",
"wled00/data/**/*.js",
"eslint.config.js"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update file name to match actual filename.

The file name referenced in the configuration doesn't match the actual filename (mjs vs js).

-            "eslint.config.js"
+            "eslint.config.mjs"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"eslint.config.js"
"eslint.config.mjs"

//REMOVED, Any image appear to work as long as it can be drawn to the canvas. Leaving code in for future use, possibly
if (1==1 || base64gifPattern.test(string) || base64pngPattern.test(string) || base64jpgPattern.test(string) || base64webpPattern.test(string)) {
// REMOVED, Any image appear to work as long as it can be drawn to the canvas. Leaving code in for future use, possibly
if (1 == 1 || base64gifPattern.test(string) || base64pngPattern.test(string) || base64jpgPattern.test(string) || base64webpPattern.test(string)) {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the redundant comparison in conditional check

There's a condition 1 == 1 which is always true. This appears to be a placeholder for validation logic that was commented out.

Consider replacing this with a more meaningful check or remove the comparison entirely:

-  if (1 == 1 || base64gifPattern.test(string) || base64pngPattern.test(string) || base64jpgPattern.test(string) || base64webpPattern.test(string)) {
+  // Since validation patterns are commented out, always return true as mentioned in the comment
+  return true;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (1 == 1 || base64gifPattern.test(string) || base64pngPattern.test(string) || base64jpgPattern.test(string) || base64webpPattern.test(string)) {
// Since validation patterns are commented out, always return true as mentioned in the comment
return true;
🧰 Tools
🪛 Biome (1.9.4)

[error] 231-231: Comparing to itself is potentially pointless.

(lint/suspicious/noSelfCompare)

this.running = true;
if(!req instanceof Object) return;
if (!req instanceof Object) return;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect instanceof operator negation

The current negation of the instanceof operator is incorrectly placed, which changes the intended logic of the condition.

The negation should be applied to the entire expression, not just to the left operand:

-    if (!req instanceof Object) return;
+    if (!(req instanceof Object)) return;

This is a critical issue as the current code will execute the return statement if req is falsy, regardless of its type, rather than checking if it's not an Object instance.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!req instanceof Object) return;
if (!(req instanceof Object)) return;
🧰 Tools
🪛 GitHub Check: Build Enviornments (esp32s3_4M_qspi)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32s3dev_8MB_opi)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32_wrover)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32s3dev_16MB_opi)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp01_1m_full_160)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32c3dev)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (lolin_s2_mini)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32dev)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32dev_audioreactive)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp32_eth)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp8266_2m_160)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (nodemcuv2_160)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp01_1m_full)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (esp8266_2m)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Build Enviornments (nodemcuv2)

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

🪛 GitHub Check: Test & Lint

[warning] 158-158:
Unexpected negating the left operand of 'instanceof' operator

@github-actions github-actions bot removed the stale This issue will be closed soon because of prolonged inactivity label Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion waiting for feedback addition information needed to better understand the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants