You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: preserve equals signs in CLI variable values - #4575
Split CLI variable assignments at the first separator so --modify-var and --global-var retain the complete value. Adds CLI coverage for attribute selectors, multiple equals signs, variable precedence, ordinary values and empty strings.
Why:
lessc --modify-var="shell_selector='html[theme=dark]'" truncates the value at the second = and fails to compile. This addresses the variable-value truncation in #3388.
pnpm test:node and lint pass on Node 24. The browser portion of pnpm test could not run because the Playwright browser executable is unavailable.
Checklist:
Documentation — N/A, existing variable syntax is unchanged
Added/updated unit tests
Code complete
Summary by CodeRabbit
Bug Fixes
Fixed command-line variable parsing so values retain any additional = characters.
Options without an = are now handled correctly, and empty values remain supported.
Variable overrides now produce the expected CSS, including when source declarations take precedence.
No actionable comments were generated in the recent review.
Walkthrough
The lessc variable option parser now splits at the first = and handles options without one. The test harness adds six CLI cases that check exit status and exact CSS output.
Changes: CLI variable option parsing and tests
Layer / File(s)
Summary
Parse and test CLI variable options packages/less/bin/lessc, packages/less/test/less-test.js, packages/less/test/index.js
The parser preserves additional = characters in values and uses the full option as the name when no = is present. Six CLI cases check variable option outputs and exit status.
Variable values that contain equals signs, such as attribute selectors passed to --modify-var, are now preserved. The change is narrow, comes with tests, and is easy to revert, so merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "fix: preserve equals signs in CLI variable values" matches the main change. The summary shows parseVariableOption now splits at the first '=' so values with later '=' characters (for exampl…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix: preserve equals signs in CLI variable values" matches the main change. The summary shows parseVariableOption now splits at the first '=' so values with later '=' characters (for example attribute selectors such as html[theme=dark]) are kept intact for --modify-var and --global-var. The added testCliVariableOptions tests cover the same behavior, so the title is specific and accurate.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
packages/less/test/index.js
Oops! Something went wrong! :(
ESLint: 7.32.0
TypeError: Failed to load plugin '@typescript-eslint' declared in 'packages/less/.eslintrc.cjs#overrides[0]': Cannot read properties of undefined (reading 'Undefined')
Referenced from: /packages/less/.eslintrc.cjs
at Object. (/.eslint-tmp/node_modules/.pnpm/@typescript-eslint+eslint-plugin@4.33.0_@typescript-eslint[email protected][email protected]__ca4ca277770b9683d36ba7fd429d0937/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unnecessary-condition.js:36:34)
at Module._compile (/.eslint-tmp/node_modules/.pnpm/[email protected]/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object..js (node:internal/modules/cjs/loader:2060:10)
at Module.load (node:internal/modules/cjs/loader:1651:32)
at Module.load (node:internal/modules/cjs/loader:1443:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:261:19)
at Module.require (node:internal/modules/cjs/loader:1674:12)
at require (/.eslint-tmp/node_modules/.pnpm/[email protected]/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object. (/.eslint-tmp/node_modules/.pnpm/@typescript-eslint[email protected]@typescript-eslint[email protected][email protected]__ca4ca277770b9683d36ba7fd429d0937/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js:74:52)
at Module._compile (/.eslint-tmp/node_modules/.pnpm/[email protected]/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
packages/less/test/less-test.js
ESLint skipped: the matched ESLint configuration already failed (plugin-compatibility).
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.
Reviewing files that changed from the base of the PR and between 7133316 and eb3699c.
Files selected for processing: 3
packages/less/bin/lessc
packages/less/test/index.js
packages/less/test/less-test.js
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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
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.
What:
Split CLI variable assignments at the first separator so
--modify-varand--global-varretain the complete value. Adds CLI coverage for attribute selectors, multiple equals signs, variable precedence, ordinary values and empty strings.Why:
lessc --modify-var="shell_selector='html[theme=dark]'"truncates the value at the second=and fails to compile. This addresses the variable-value truncation in #3388.pnpm test:nodeand lint pass on Node 24. The browser portion ofpnpm testcould not run because the Playwright browser executable is unavailable.Checklist:
Summary by CodeRabbit
=characters.=are now handled correctly, and empty values remain supported.