Skip to content

Commit

Permalink
Fix false negatives for grid shorthands in named-grid-areas-no-invalid (
Browse files Browse the repository at this point in the history
  • Loading branch information
jeddy3 committed Sep 6, 2021
1 parent c1713ea commit 30bb6fa
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
51 changes: 39 additions & 12 deletions lib/rules/named-grid-areas-no-invalid/__tests__/index.js
Expand Up @@ -17,16 +17,16 @@ testRule({
},
{
code: stripIndent`
a {
a {
grid-template-areas: "head head"
"nav main"
"nav foot";
}`,
},
{
code: stripIndent`
a {
grid-template-areas:
a {
grid-template-areas:
/* "" */ "head head"
"nav main" /* "a b c" */
"nav foot" /* "" */;
Expand All @@ -52,8 +52,17 @@ testRule({
},
{
code: stripIndent`
a {
grid-template-areas: /* "comment" */ none /* "comment " */;
a {
grid-template-areas: /* "comment" */ none /* "comment " */;
}`,
},
{
code: stripIndent`
a {
grid-template:
"a a a" 40px
"b c c" 40px
"b c c" 40px / 1fr 1fr 1fr;
}`,
},
],
Expand All @@ -80,10 +89,10 @@ testRule({
},
{
code: stripIndent`
a {
a {
grid-template-areas: "header header header header"
"main main . sidebar"
"footer footer footer header";
"footer footer footer header";
}`,
message: messages.expectedRectangle('header'),
line: 2,
Expand All @@ -103,12 +112,12 @@ testRule({
},
{
code: stripIndent`
a { grid-template-areas:
"";
a { grid-template-areas:
"";
}`,
message: messages.expectedToken(),
line: 2,
column: 4,
column: 2,
},
{
code: 'a { grid-template-areas: "" "" ""; }',
Expand All @@ -120,9 +129,9 @@ testRule({
},
{
code: stripIndent`
a {
a {
grid-template-areas: /* none */
"" /* none */;
"" /* none */;
}`,
message: messages.expectedToken(),
line: 3,
Expand All @@ -134,5 +143,23 @@ testRule({
line: 1,
column: 26,
},
{
code: stripIndent`
a {
grid-template:
"a a" 40px
"b c c" 40px
"b c c" 40px / 1fr 1fr 1fr;
}`,
message: messages.expectedSameNumber(),
line: 3,
column: 3,
},
{
code: `a { grid: "" 200px "b" min-content; }`,
message: messages.expectedToken(),
line: 1,
column: 11,
},
],
});
2 changes: 1 addition & 1 deletion lib/rules/named-grid-areas-no-invalid/index.js
Expand Up @@ -25,7 +25,7 @@ const rule = (primary) => {
return;
}

root.walkDecls(/^grid-template-areas$/i, (decl) => {
root.walkDecls(/^(?:grid|grid-template|grid-template-areas)$/i, (decl) => {
const { value } = decl;

if (value.toLowerCase().trim() === 'none') return;
Expand Down

0 comments on commit 30bb6fa

Please sign in to comment.