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

Refactor atrule statement in unit-no-unknown #5515

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
9 changes: 0 additions & 9 deletions lib/rules/unit-no-unknown/__tests__/index.js
Expand Up @@ -480,15 +480,6 @@ testRule({
description: 'ignore variable names',
},
],

reject: [
{
code: '@variable: 10pix',
message: messages.rejected('pix'),
line: 1,
column: 12,
},
],
});

testRule({
Expand Down
5 changes: 3 additions & 2 deletions lib/rules/unit-no-unknown/index.js
Expand Up @@ -5,6 +5,7 @@
const atRuleParamIndex = require('../../utils/atRuleParamIndex');
const declarationValueIndex = require('../../utils/declarationValueIndex');
const getUnitFromValueNode = require('../../utils/getUnitFromValueNode');
const isStandardSyntaxAtRule = require('../../utils/isStandardSyntaxAtRule');
const isStandardSyntaxDeclaration = require('../../utils/isStandardSyntaxDeclaration');
const keywordSets = require('../../reference/keywordSets');
const mediaParser = require('postcss-media-query-parser').default;
Expand Down Expand Up @@ -128,8 +129,8 @@ function rule(actual, options) {
});
}

root.walkAtRules((atRule) => {
if (!/^media$/i.test(atRule.name) && !atRule.variable) {
root.walkAtRules(/^media$/i, (atRule) => {
if (!isStandardSyntaxAtRule(atRule)) {
return;
}

Expand Down