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

Fix false positives for longhand grid-column/row-* properties in value-keyword-case #4611

Merged
merged 2 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Ignore area case (#4605)
  • Loading branch information
fanich37 committed Feb 20, 2020
commit 0fb5cc5322ae677e27a1c0a43590a9df560bce87
11 changes: 11 additions & 0 deletions lib/rules/value-keyword-case/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ testRule(rule, {
code: 'a { color: ThreeDShadow; }',
description: 'another system color',
},
{
code: 'a { grid-column-start: span camelCaseArea; }',
fanich37 marked this conversation as resolved.
Show resolved Hide resolved
description: 'ignore area case',
},
],

reject: [
Expand Down Expand Up @@ -658,6 +662,13 @@ testRule(rule, {
line: 1,
column: 23,
},
{
code: 'a { grid-column-start: sPan camelCaseArea; }',
fixed: 'a { grid-column-start: span camelCaseArea; }',
message: messages.expected('sPan', 'span'),
line: 1,
column: 24,
},
],
});

Expand Down
8 changes: 5 additions & 3 deletions lib/rules/value-keyword-case/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const messages = ruleMessages(ruleName, {

// Operators are interpreted as "words" by the value parser, so we want to make sure to ignore them.
const ignoredCharacters = new Set(['+', '-', '/', '*', '%']);
const gridRowProps = new Set(['grid-row', 'grid-row-start', 'grid-row-end']);
const gridColumnProps = new Set(['grid-column', 'grid-column-start', 'grid-column-end']);

const mapLowercaseKeywordsToCamelCase = new Map();

Expand Down Expand Up @@ -52,7 +54,7 @@ function rule(expectation, options, context) {
}

root.walkDecls((decl) => {
const prop = decl.prop;
const prop = decl.prop.toLowerCase();
const value = decl.value;

const parsed = valueParser(decl.raws.value ? decl.raws.value.raw : decl.value);
Expand Down Expand Up @@ -124,11 +126,11 @@ function rule(expectation, options, context) {
return;
}

if (prop === 'grid-row' && !keywordSets.gridRowKeywords.has(valueLowerCase)) {
if (gridRowProps.has(prop) && !keywordSets.gridRowKeywords.has(valueLowerCase)) {
return;
}

if (prop === 'grid-column' && !keywordSets.gridColumnKeywords.has(valueLowerCase)) {
if (gridColumnProps.has(prop) && !keywordSets.gridColumnKeywords.has(valueLowerCase)) {
return;
}

Expand Down