Skip to content
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

fix no-unit-unknown rule for variable usage #4163

Merged
merged 1 commit into from Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/rules/unit-no-unknown/__tests__/index.js
Expand Up @@ -441,6 +441,10 @@ testRule(rule, {
{
code: "a { width: 1em; \n// width: 10pix\n }",
description: "ignore wrong unit within comments"
},
{
code: "@56789a: #56789a;\na { color: @56789a; }",
description: "ignore variable names"
}
],

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/getUnitFromValueNode.js
Expand Up @@ -25,7 +25,7 @@ module.exports = function(node /*: Object*/) /*: ?string*/ {

if (
node.type !== "word" ||
!isStandardSyntaxValue(value) ||
!isStandardSyntaxValue(node.value) ||
Copy link
Member

Choose a reason for hiding this comment

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

/cc @hudochenkov it is break other case, for example .selector { property: 20px\9; } - regression

Copy link
Member

Choose a reason for hiding this comment

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

But it's a hack for IE8.

All tests were passed.

Copy link
Member

Choose a reason for hiding this comment

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

@hudochenkov yes, based on code test should be failed 😕 https://github.com/laysent/stylelint/blob/0c68261c43123df7e0ffaabbdc350a8a480fb43a/lib/utils/getUnitFromValueNode.js#L29, maybe postcss-value-parser recognize this as other type for node, i will look on this today

!_.isFinite(parseInt(value)) ||
node.value[0] === "#"
) {
Expand Down