Repository navigation
Support scientific notation in CSS numeric values - #582
Open
Pradeep Ramola (pradeep-ramola) wants to merge 1 commit into
Open
Pradeep Ramola (pradeep-ramola) wants to merge 1 commit into
Pradeep Ramola (pradeep-ramola) wants to merge 1 commit into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Scientific notation is part of CSS number syntax, but the scanner currently treats exponent text as a dimension unit or splits a signed exponent into multiple tokens. For example:
1e2is treated as an unknown dimension instead of a number.1E+2pxis split instead of remaining a single length token.NumericValue.getValue()mistakes exponent text for the unit.rgb(1e2 0 0)andhsl(5e-1turn 100% 50%)are not reported byfindDocumentColors.Spec: https://www.w3.org/TR/css-values-4/#numbers
Change
Incomplete exponents and ordinary
em/exunits retain their existing token boundaries. The existing mantissa scanning and color-channel range handling are unchanged. This PR is based directly on main and does not include or require #579 or #581.Tests
Added 60 cases across CSS, LESS, and SCSS:
zeroUnitslint recognizes0e0px.The initial 57-case regression run on unchanged upstream had 54 failures and 3 passing controls. Three additional invalid-color control tests were added afterward.
Verification on Windows after a clean
npm ci:npm run compile: TypeScript compilation and 7 lint checks passed.node --enable-source-maps --test: 484 passed, no failures/skips.git diff --check: passed.Test files were enumerated explicitly to avoid the single-quoted npm glob selecting no tests in this Windows shell. Full VS Code editor UI integration and Sass/Less compiler execution were not run; coverage uses this repository's language-service implementations.
AI assistance was used to investigate, implement, test, and draft this contribution.