Comments (4)
The Less compiler is a light transformation on top of CSS. Apart from structural and lexical syntax that affects the output, the Less compiler effectively does not concern itself with the individual CSS rules. This matches the way browsers process CSS. (Unlike JavaScript, browsers treat CSS as a declarative format where values are not evaluated or executed at the time of processing. They merely produce a tree of key-value pairs effectively. Thus there is no such thing as an "exception" in CSS. So long as they can be syntactically understood or skipped over, the values are only interpreted later when individual DOM elements are painted to the screen and each have their styles computed.)
Browsers often introduce experimental and non-standard features that may only exist for a few versions. CSS tolerates these without issue, and Less.php allows you to use any of these. That is your own decision.
If your examples would cause other code in the same stylesheet to confuse Less.php, then please do let us know as that would be a bug. I suspect that is not the case. They should be inconsequential from the prespectice of Less compilation, and even in the output toward the browser have no negative effect. The browser ignores them, the same way it ignores rules that are only supported by a different browser.
If you would like to apply "linting" to CSS and look for code that likely contains developer mistakes, then I would recommend using Stylelint as a testing step (e.g. in CI). Stylelint maintains a long list of properties names, keywords, and value structures that it knows are supported in certain browsers, and you can tell it which browsers you'd like to support, it will then warn you about CSS rules that would be invalid/unknown/ignored in those browsers.
from less.php.
Hi @Krinkle,
thanks for the detailed answer.
We have migrated to scss (dart-sass) as this does check if it is valid CSS or not and is much better (only dart-sass needed).
from less.php.
@DanielRuf No problem. I hope that works out for you.
I would still encourage you to consider Stylelint since compilers generally only check the grammar checking for their own transformations. This is no different for dart-sass, which does happen to catch two of the above examples (because it has to transform them in some cases). It does not validate anything beyond that.
// input.scss
.foo {
margin-top: 99luftballons;
margin-top: breaking-time-and-space;;;;
unreal-radius: "invalid";
}
# [email protected]
No errors or warnings.
# [email protected]
No errors or warnings.
# [email protected]
No errors or warnings.
# [email protected] stylelint-config-recommended
# .stylelintrc
{ "extends": "stylelint-config-recommended" }
# stylelint input.scss
2:14 ✖ Unexpected unknown unit "luftballons" unit-no-unknown
3:38 ✖ Unexpected extra semicolon no-extra-semicolons
3:39 ✖ Unexpected extra semicolon no-extra-semicolons
3:40 ✖ Unexpected extra semicolon no-extra-semicolons
4:2 ✖ Unexpected unknown property "unreal-radius" property-no-unknown
from less.php.
Thanks, we'll consider that (using a linter for extra checks besides the checks which are already done in the IDE, probably by some default linter).
from less.php.
Related Issues (20)
- PHP 8.2 Creation of dynamic property warning HOT 2
- Tree_Javascript or Tree_JavaScript? HOT 6
- Allowed memory limit exceeded when unserializing cache. HOT 4
- Support CSS `@property` rule (Less.js 3.0.0) HOT 2
- Block comments in @font-face are moved to bottom of selector HOT 3
- Regression in v4.2.0 HOT 6
- Regression: CSS output differs from Less.js for mixin selector HOT 3
- Undefined array key "currentUri" in [...]Mapped.php Line 68 when using @import (inline) HOT 1
- Trying to access array offset on value of type null HOT 1
- Support logical if() function (Less.js 3.0) HOT 3
- Parser Exception parsing "filter: alpha(opacity=0);" HOT 2
- Cannot assign em or rem value to less variable. HOT 2
- Support @container queries (Less.js 4.2.0) HOT 1
- Import from google font HOT 3
- Deprecation warning in PHP 8.2 HOT 6
- if $cached_name is the same as the $compiled name, should not regenerate HOT 1
- Error in Compiling HOT 2
- @container queries support? HOT 2
- Support CSS4 space-separated syntax for rgba() function (Less.js 3.8.1) HOT 1
- Autoloading can fail due to incorrect class name casing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from less.php.