Skip to content

Commit

Permalink
Fix end positions for selector-*-no-unknown (#6046)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattxwang committed Apr 30, 2022
1 parent ed6a9fc commit 13b889f
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/rules/selector-pseudo-class-no-unknown/__tests__/index.js
Expand Up @@ -124,72 +124,96 @@ testRule({
message: messages.rejected(':unknown'),
line: 1,
column: 2,
endLine: 1,
endColumn: 10,
},
{
code: 'a:Unknown { }',
message: messages.rejected(':Unknown'),
line: 1,
column: 2,
endLine: 1,
endColumn: 10,
},
{
code: 'a:uNkNoWn { }',
message: messages.rejected(':uNkNoWn'),
line: 1,
column: 2,
endLine: 1,
endColumn: 10,
},
{
code: 'a:UNKNOWN { }',
message: messages.rejected(':UNKNOWN'),
line: 1,
column: 2,
endLine: 1,
endColumn: 10,
},
{
code: 'a:pseudo-class { }',
message: messages.rejected(':pseudo-class'),
line: 1,
column: 2,
endLine: 1,
endColumn: 15,
},
{
code: 'body:not(div):noot(span) {}',
message: messages.rejected(':noot'),
line: 1,
column: 14,
endLine: 1,
endColumn: 19,
},
{
code: 'a:unknown::before { }',
message: messages.rejected(':unknown'),
line: 1,
column: 2,
endLine: 1,
endColumn: 10,
},
{
code: 'a,\nb > .foo:error { }',
message: messages.rejected(':error'),
line: 2,
column: 9,
endLine: 2,
endColumn: 15,
},
{
code: '::-webkit-scrollbar-button:horizontal:unknown {}',
message: messages.rejected(':unknown'),
line: 1,
column: 38,
endLine: 1,
endColumn: 46,
},
{
code: ':first { }',
message: messages.rejected(':first'),
line: 1,
column: 1,
endLine: 1,
endColumn: 7,
},
{
code: '@page :blank:unknown { }',
message: messages.rejected(':unknown'),
line: 1,
column: 13,
endLine: 1,
endColumn: 21,
},
{
code: '@page foo:unknown { }',
message: messages.rejected(':unknown'),
line: 1,
column: 10,
endLine: 1,
endColumn: 18,
},
{
code: ':horizontal:decrement {}',
Expand All @@ -198,11 +222,15 @@ testRule({
message: messages.rejected(':horizontal'),
line: 1,
column: 1,
endLine: 1,
endColumn: 12,
},
{
message: messages.rejected(':decrement'),
line: 1,
column: 12,
endLine: 1,
endColumn: 22,
},
],
},
Expand Down
1 change: 1 addition & 0 deletions lib/rules/selector-pseudo-class-no-unknown/index.js
Expand Up @@ -121,6 +121,7 @@ const rule = (primary, secondaryOptions) => {
index,
ruleName,
result,
word: value,
});
});
});
Expand Down
14 changes: 14 additions & 0 deletions lib/rules/selector-pseudo-element-no-unknown/__tests__/index.js
Expand Up @@ -115,42 +115,56 @@ testRule({
message: messages.rejected('::pseudo'),
line: 1,
column: 2,
endLine: 1,
endColumn: 10,
},
{
code: 'a::Pseudo { }',
message: messages.rejected('::Pseudo'),
line: 1,
column: 2,
endLine: 1,
endColumn: 10,
},
{
code: 'a::pSeUdO { }',
message: messages.rejected('::pSeUdO'),
line: 1,
column: 2,
endLine: 1,
endColumn: 10,
},
{
code: 'a::PSEUDO { }',
message: messages.rejected('::PSEUDO'),
line: 1,
column: 2,
endLine: 1,
endColumn: 10,
},
{
code: 'a::element { }',
message: messages.rejected('::element'),
line: 1,
column: 2,
endLine: 1,
endColumn: 11,
},
{
code: 'a:hover::element { }',
message: messages.rejected('::element'),
line: 1,
column: 8,
endLine: 1,
endColumn: 17,
},
{
code: 'a,\nb > .foo::error { }',
message: messages.rejected('::error'),
line: 2,
column: 9,
endLine: 2,
endColumn: 16,
},
],
});
Expand Down
1 change: 1 addition & 0 deletions lib/rules/selector-pseudo-element-no-unknown/index.js
Expand Up @@ -83,6 +83,7 @@ const rule = (primary, secondaryOptions) => {
index: pseudoNode.sourceIndex,
ruleName,
result,
word: value,
});
});
});
Expand Down
22 changes: 22 additions & 0 deletions lib/rules/selector-type-no-unknown/__tests__/index.js
Expand Up @@ -143,69 +143,91 @@ testRule({
message: messages.rejected('unknown'),
line: 1,
column: 1,
endLine: 1,
endColumn: 8,
},
{
code: 'uNkNoWn {}',
message: messages.rejected('uNkNoWn'),
line: 1,
column: 1,
endLine: 1,
endColumn: 8,
},
{
code: 'UNKNOWN {}',
message: messages.rejected('UNKNOWN'),
line: 1,
column: 1,
endLine: 1,
endColumn: 8,
},
{
code: 'ul unknown {}',
message: messages.rejected('unknown'),
line: 1,
column: 4,
endLine: 1,
endColumn: 11,
},
{
code: 'unknown[target] {}',
message: messages.rejected('unknown'),
line: 1,
column: 1,
endLine: 1,
endColumn: 8,
},
{
code: 'unknown:nth-child(even) {}',
message: messages.rejected('unknown'),
line: 1,
column: 1,
endLine: 1,
endColumn: 8,
},
{
code: '@media only screen and (min-width: 35em) { unknown {} }',
message: messages.rejected('unknown'),
line: 1,
column: 44,
endLine: 1,
endColumn: 51,
},
{
code: 'input:not(unknown) {}',
message: messages.rejected('unknown'),
line: 1,
column: 11,
endLine: 1,
endColumn: 18,
},
{
code: 'x-Foo {}',
description: 'invalid custom element',
message: messages.rejected('x-Foo'),
line: 1,
column: 1,
endLine: 1,
endColumn: 6,
},
{
code: 'X-foo {}',
description: 'invalid custom element',
message: messages.rejected('X-foo'),
line: 1,
column: 1,
endLine: 1,
endColumn: 6,
},
{
code: 'X-FOO {}',
description: 'invalid custom element',
message: messages.rejected('X-FOO'),
line: 1,
column: 1,
endLine: 1,
endColumn: 6,
},
],
});
Expand Down
1 change: 1 addition & 0 deletions lib/rules/selector-type-no-unknown/index.js
Expand Up @@ -105,6 +105,7 @@ const rule = (primary, secondaryOptions) => {
index: tagNode.sourceIndex,
ruleName,
result,
word: tagName,
});
});
});
Expand Down

0 comments on commit 13b889f

Please sign in to comment.