Skip to content

Commit

Permalink
ignore urange productions in unicode-range description
Browse files Browse the repository at this point in the history
  • Loading branch information
romainmenke committed Jun 5, 2023
1 parent 060a4d3 commit 184fbd5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/rules/unit-disallowed-list/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { messages, ruleName } = require('..');
testRule({
ruleName,

config: ['px', 'vmin'],
config: ['px', 'vmin', 'f'],

accept: [
{
Expand Down Expand Up @@ -118,6 +118,9 @@ testRule({
code: '@media (min-width: 10em)\n and (max-width: 20em) {}',
description: 'complex @media',
},
{
code: '@font-face { unicode-range: U+0100-024F; }',
},
],

reject: [
Expand Down Expand Up @@ -260,6 +263,24 @@ testRule({
endLine: 1,
endColumn: 24,
},
{
code: '@font-face { color: U+0100-024F; }',
message: messages.rejected('F'),
description: 'Unicode range value in something other than `unicode-range`',
line: 1,
column: 31,
endLine: 1,
endColumn: 32,
},
{
code: 'a { unicode-range: U+0100-024F; }',
message: messages.rejected('F'),
description: 'Unicode range value in something other than `@font-face`',
line: 1,
column: 30,
endLine: 1,
endColumn: 31,
},
],
});

Expand Down
3 changes: 3 additions & 0 deletions lib/rules/unit-disallowed-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const ruleMessages = require('../../utils/ruleMessages');
const validateObjectWithArrayProps = require('../../utils/validateObjectWithArrayProps');
const validateOptions = require('../../utils/validateOptions');
const { isRegExp, isString } = require('../../utils/validateTypes');
const isUnicodeRangeDescriptor = require('../../utils/isUnicodeRangeDescriptor');

const ruleName = 'unit-disallowed-list';

Expand Down Expand Up @@ -146,6 +147,8 @@ const rule = (primary, secondaryOptions) => {
});
});
root.walkDecls((decl) => {
if (isUnicodeRangeDescriptor(decl)) return;

const value = getDeclarationValue(decl);

if (!hasDimension(value)) return;
Expand Down

0 comments on commit 184fbd5

Please sign in to comment.