-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
Fixed: value-keyword-case
is now ignore counter-reset property and counter, counters and attr functions.
#2407
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -4,6 +4,7 @@ const keywordSets = require("../../reference/keywordSets") | |||
const declarationValueIndex = require("../../utils/declarationValueIndex") | ||||
const getUnitFromValueNode = require("../../utils/getUnitFromValueNode") | ||||
const isCounterIncrementCustomIdentValue = require("../../utils/isCounterIncrementCustomIdentValue") | ||||
const isCounterResetCustomIdentValue = require("../../utils/isCounterResetCustomIdentValue") | ||||
const isStandardSyntaxValue = require("../../utils/isStandardSyntaxValue") | ||||
const matchesStringOrRegExp = require("../../utils/matchesStringOrRegExp") | ||||
const report = require("../../utils/report") | ||||
|
@@ -64,7 +65,7 @@ const rule = function (expectation, options) { | |||
} | ||||
|
||||
// Ignore keywords within `url` and `var` function | ||||
if (node.type === "function" && (valueLowerCase === "url" || valueLowerCase === "var")) { | ||||
if (node.type === "function" && (valueLowerCase === "url" || valueLowerCase === "var" || valueLowerCase === "counter" || valueLowerCase === "counters" || valueLowerCase === "attr")) { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @davidtheclark I thought that I would correct this behavior in one commit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine. In the future please make sure to point this out in the comment about your PR, so we remember to place it in the Changelog. Is it tested? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @davidtheclark yep
|
||||
return false | ||||
} | ||||
|
||||
|
@@ -90,6 +91,9 @@ const rule = function (expectation, options) { | |||
if (prop === "counter-increment" && isCounterIncrementCustomIdentValue(valueLowerCase)) { | ||||
return | ||||
} | ||||
if (prop === "counter-reset" && isCounterResetCustomIdentValue(valueLowerCase)) { | ||||
return | ||||
} | ||||
if (prop === "grid-row" && !keywordSets.gridRowKeywords.has(valueLowerCase)) { | ||||
return | ||||
} | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use strict" | ||
|
||
const isCounterResetCustomIdentValue = require("../isCounterResetCustomIdentValue") | ||
|
||
it("isCustomIdents", () => { | ||
expect(isCounterResetCustomIdentValue("counter")).toBeTruthy() | ||
expect(isCounterResetCustomIdentValue("cOuNtEr")).toBeTruthy() | ||
expect(isCounterResetCustomIdentValue("COUNTER")).toBeTruthy() | ||
expect(isCounterResetCustomIdentValue("counter-name")).toBeTruthy() | ||
expect(isCounterResetCustomIdentValue("counter1")).toBeTruthy() | ||
expect(isCounterResetCustomIdentValue("counter2")).toBeTruthy() | ||
expect(isCounterResetCustomIdentValue("none")).toBeFalsy() | ||
expect(isCounterResetCustomIdentValue("inherit")).toBeFalsy() | ||
expect(isCounterResetCustomIdentValue("initial")).toBeFalsy() | ||
expect(isCounterResetCustomIdentValue("unset")).toBeFalsy() | ||
expect(isCounterResetCustomIdentValue("-1")).toBeFalsy() | ||
expect(isCounterResetCustomIdentValue("1")).toBeFalsy() | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* @flow */ | ||
"use strict" | ||
|
||
const keywordSets = require("../reference/keywordSets") | ||
const _ = require("lodash") | ||
|
||
/** | ||
* Check value is a custom ident | ||
*/ | ||
|
||
module.exports = function (value/*: string*/)/*: boolean*/ { | ||
const valueLowerCase = value.toLowerCase() | ||
|
||
if (keywordSets.counterResetKeywords.has(valueLowerCase) || _.isFinite(parseInt(valueLowerCase))) { | ||
return false | ||
} | ||
|
||
return true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you've already tested the line about
toLowerCase
(with thevalue-string
tests above), I don't think we need to multiply every test with alternate cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidtheclark difference functions to ignore
attr
andcounter