Skip to content

Commit

Permalink
Fix end positions for declaration-block-no-* that avoid errors (#6040)
Browse files Browse the repository at this point in the history
* Fix end positions for `declaration-block-no-duplicate-properties`

* Fix end positions for `declaration-block-no-duplicate-custom-properties`

* Fix end positions for `declaration-block-no-shorthand-property-overrides`
  • Loading branch information
mattxwang committed Apr 27, 2022
1 parent 6317202 commit b06f324
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 0 deletions.
Expand Up @@ -41,39 +41,71 @@ testRule({
{
code: 'a { --custom-property: 1; --custom-property: 2; }',
message: messages.rejected('--custom-property'),
line: 1,
column: 27,
endLine: 1,
endColumn: 44,
},
{
code: 'a { --custom-property: 1; color: pink; --custom-property: 1; }',
message: messages.rejected('--custom-property'),
line: 1,
column: 40,
endLine: 1,
endColumn: 57,
},
{
code: 'a { --custom-property: 1; --cUstOm-prOpErtY: 1; color: pink; --cUstOm-prOpErtY: 1; }',
message: messages.rejected('--cUstOm-prOpErtY'),
line: 1,
column: 62,
endLine: 1,
endColumn: 79,
},
{
code: 'a { --custom-property: pink; { &:hover { --custom-property: orange; --custom-property: black; } } }',
description: 'spec nested',
message: messages.rejected('--custom-property'),
line: 1,
column: 69,
endLine: 1,
endColumn: 86,
},
{
code: 'a { --custom-property: pink; @media { --custom-property: orange; --custom-property: black; } }',
description: 'nested',
message: messages.rejected('--custom-property'),
line: 1,
column: 66,
endLine: 1,
endColumn: 83,
},
{
code: '@media { --custom-property: orange; .foo { --custom-property: black; --custom-property: white; } }',
description: 'nested',
message: messages.rejected('--custom-property'),
line: 1,
column: 70,
endLine: 1,
endColumn: 87,
},
{
code: 'a { --custom-property: pink; @media { --custom-property: orange; &::before { --custom-property: black; --custom-property: white; } } }',
description: 'double nested',
message: messages.rejected('--custom-property'),
line: 1,
column: 104,
endLine: 1,
endColumn: 121,
},
{
code: 'a { --custom-property: pink; @media { --custom-property: orange; .foo { --custom-property: black; --custom-property: white; } } }',
description: 'double nested again',
message: messages.rejected('--custom-property'),
line: 1,
column: 99,
endLine: 1,
endColumn: 116,
},
],
});
Expand Down
Expand Up @@ -48,6 +48,7 @@ const rule = (primary) => {
node: decl,
result,
ruleName,
word: prop,
});

return;
Expand Down
Expand Up @@ -49,67 +49,127 @@ testRule({
{
code: 'a { color: pink; color: orange }',
message: messages.rejected('color'),
line: 1,
column: 18,
endLine: 1,
endColumn: 23,
},
{
code: 'a { cOlOr: pink; color: orange }',
message: messages.rejected('color'),
line: 1,
column: 18,
endLine: 1,
endColumn: 23,
},
{
code: 'a { color: pink; cOlOr: orange }',
message: messages.rejected('cOlOr'),
line: 1,
column: 18,
endLine: 1,
endColumn: 23,
},
{
code: 'a { cOlOr: pink; cOlOr: orange }',
message: messages.rejected('cOlOr'),
line: 1,
column: 18,
endLine: 1,
endColumn: 23,
},
{
code: 'a { COLOR: pink; color: orange }',
message: messages.rejected('color'),
line: 1,
column: 18,
endLine: 1,
endColumn: 23,
},
{
code: 'a { color: pink; COLOR: orange }',
message: messages.rejected('COLOR'),
line: 1,
column: 18,
endLine: 1,
endColumn: 23,
},
{
code: 'a { color: pink; background: orange; color: orange }',
message: messages.rejected('color'),
line: 1,
column: 38,
endLine: 1,
endColumn: 43,
},
{
code: 'a { color: pink; background: orange; background: pink; }',
message: messages.rejected('background'),
line: 1,
column: 38,
endLine: 1,
endColumn: 48,
},
{
code: 'a { color: pink; { &:hover { color: orange; color: black; } } }',
description: 'spec nested',
message: messages.rejected('color'),
line: 1,
column: 45,
endLine: 1,
endColumn: 50,
},
{
code: 'a { color: pink; @media { color: orange; color: black; } }',
description: 'nested',
message: messages.rejected('color'),
line: 1,
column: 42,
endLine: 1,
endColumn: 47,
},
{
code: '@media { color: orange; .foo { color: black; color: white; } }',
description: 'nested',
message: messages.rejected('color'),
line: 1,
column: 46,
endLine: 1,
endColumn: 51,
},
{
code: 'a { color: pink; @media { color: orange; &::before { color: black; color: white; } } }',
description: 'double nested',
message: messages.rejected('color'),
line: 1,
column: 68,
endLine: 1,
endColumn: 73,
},
{
code: 'a { color: pink; @media { color: orange; .foo { color: black; color: white; } } }',
description: 'double nested again',
message: messages.rejected('color'),
line: 1,
column: 63,
endLine: 1,
endColumn: 68,
},
{
code: 'a { -webkit-border-radius: 12px; -webkit-border-radius: 10px; }',
message: messages.rejected('-webkit-border-radius'),
line: 1,
column: 34,
endLine: 1,
endColumn: 55,
},
{
code: 'a { -WEBKIT-border-radius: 12px; -webkit-BORDER-radius: 10px; }',
message: messages.rejected('-webkit-BORDER-radius'),
line: 1,
column: 34,
endLine: 1,
endColumn: 55,
},
],
});
Expand Down
4 changes: 4 additions & 0 deletions lib/rules/declaration-block-no-duplicate-properties/index.js
Expand Up @@ -96,6 +96,7 @@ const rule = (primary, secondaryOptions) => {
node: decl,
result,
ruleName,
word: prop,
});

return;
Expand All @@ -111,6 +112,7 @@ const rule = (primary, secondaryOptions) => {
node: decl,
result,
ruleName,
word: prop,
});

return;
Expand All @@ -124,6 +126,7 @@ const rule = (primary, secondaryOptions) => {
node: decl,
result,
ruleName,
word: prop,
});

return;
Expand All @@ -141,6 +144,7 @@ const rule = (primary, secondaryOptions) => {
node: decl,
result,
ruleName,
word: prop,
});
}

Expand Down
Expand Up @@ -41,47 +41,91 @@ testRule({
{
code: 'a { padding-left: 10px; padding: 20px; }',
message: messages.rejected('padding', 'padding-left'),
line: 1,
column: 25,
endLine: 1,
endColumn: 32,
},
{
code: 'a { pAdDiNg-lEfT: 10Px; pAdDiNg: 20Px; }',
message: messages.rejected('pAdDiNg', 'pAdDiNg-lEfT'),
line: 1,
column: 25,
endLine: 1,
endColumn: 32,
},
{
code: 'a { PADDING-LEFT: 10PX; PADDING: 20PX; }',
message: messages.rejected('PADDING', 'PADDING-LEFT'),
line: 1,
column: 25,
endLine: 1,
endColumn: 32,
},
{
code: 'a { padding-left: 10px; { b { padding-top: 10px; padding: 20px; }}}',
description: 'override within nested rule',
message: messages.rejected('padding', 'padding-top'),
line: 1,
column: 50,
endLine: 1,
endColumn: 57,
},
{
code: 'a { border-top-width: 1px; top: 0; bottom: 3px; border: 2px solid blue; }',
message: messages.rejected('border', 'border-top-width'),
line: 1,
column: 49,
endLine: 1,
endColumn: 55,
},
{
code: 'a { transition-property: opacity; transition: opacity 1s linear; }',
message: messages.rejected('transition', 'transition-property'),
line: 1,
column: 35,
endLine: 1,
endColumn: 45,
},
{
code: 'a { background-repeat: no-repeat; background: url(lion.png); }',
message: messages.rejected('background', 'background-repeat'),
line: 1,
column: 35,
endLine: 1,
endColumn: 45,
},
{
code: '@media (color) { background-repeat: no-repeat; background: url(lion.png); }',
message: messages.rejected('background', 'background-repeat'),
line: 1,
column: 48,
endLine: 1,
endColumn: 58,
},
{
code: 'a { @media (color) { background-repeat: no-repeat; background: url(lion.png); }}',
message: messages.rejected('background', 'background-repeat'),
line: 1,
column: 52,
endLine: 1,
endColumn: 62,
},
{
code: 'a { -webkit-transition-property: opacity; -webkit-transition: opacity 1s linear; }',
message: messages.rejected('-webkit-transition', '-webkit-transition-property'),
line: 1,
column: 43,
endLine: 1,
endColumn: 61,
},
{
code: 'a { -WEBKIT-transition-property: opacity; -webKIT-transition: opacity 1s linear; }',
message: messages.rejected('-webKIT-transition', '-WEBKIT-transition-property'),
line: 1,
column: 43,
endLine: 1,
endColumn: 61,
},
],
});
Expand Down
Expand Up @@ -53,6 +53,7 @@ const rule = (primary) => {
result,
node: decl,
message: messages.rejected(prop, declarations[prefix + longhandProp] || ''),
word: prop,
});
}
});
Expand Down

0 comments on commit b06f324

Please sign in to comment.