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

map-keys-quotes: don't require numbers to be quoted #350

Merged
merged 2 commits into from Aug 2, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 without quotes"
kristerkari marked this conversation as resolved.
Show resolved Hide resolved
},
{
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