Skip to content

Commit

Permalink
Merge pull request #350 from kristerkari/bugfix/map-keys-quotes-numer…
Browse files Browse the repository at this point in the history
…ic-keys

map-keys-quotes: don't require numbers to be quoted
  • Loading branch information
kristerkari committed Aug 2, 2019
2 parents a0e54d7 + 4ba37df commit 5f14d20
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
# HEAD

- Fixed: `map-keys-quotes` warning for unquoted numeric keys.

# 3.9.2

- Fixed: `selector-no-union-class-name` throwing an error when using nested `@`-rules.
Expand Down
36 changes: 35 additions & 1 deletion src/rules/map-keys-quotes/__tests__/index.js
@@ -1,4 +1,4 @@
import rule, { ruleName, messages } from "..";
import rule, { messages, ruleName } from "..";

testRule(rule, {
ruleName,
Expand All @@ -11,6 +11,40 @@ testRule(rule, {
$test: ("foo": 14px, "bar": 25px);
`,
description: "accepts strings without quotes"
},
{
code: `
$test: ('foo': 14px, 'bar': 25px);
`,
description: "accepts strings with quotes"
},
{
code: `
$colors: (
250: #eef9ff,
300: #bbe7ff,
350: #b7d3e6,
500: #1388db,
750: #0f6bac,
900: #2e4662
);
`,
description: "accepts numbers"
},
{
code: `
$colors: (
'primary': (
250: #eef9ff,
300: #bbe7ff,
350: #b7d3e6,
500: #1388db,
750: #0f6bac,
900: #2e4662,
)
);
`,
description: "accepts numbers (nested)"
}
],

Expand Down
4 changes: 2 additions & 2 deletions src/rules/map-keys-quotes/index.js
@@ -1,6 +1,6 @@
import valueParser from "postcss-value-parser";
import { utils } from "stylelint";
import { namespace } from "../../utils";
import valueParser from "postcss-value-parser";

export const ruleName = namespace("map-keys-quotes");

Expand Down Expand Up @@ -34,7 +34,7 @@ function rule(primary) {
const mapKeys = returnMapKeys(node.nodes);

mapKeys.forEach(map_key => {
if (map_key.type === "word") {
if (map_key.type === "word" && isNaN(map_key.value)) {
utils.report({
message: messages.expected,
node: decl,
Expand Down

0 comments on commit 5f14d20

Please sign in to comment.