sass / linter

An experimental Sass linter written using the Dart Sass AST
MIT License
39 stars 6 forks source link

Add a lint rule for unquoted strings in map keys #12

Closed nex3 closed 6 years ago

nex3 commented 6 years ago

It's generally a bad practice to use unquoted strings as map keys. Some tokens (like green) parse as colors rather than strings, which means that if the keys are used in selector names, they won't necessarily emit as text (for example, green is emitted as #0f0 in compressed mode). It would be good to have a lint that encourages users to quote their map keys.

mik01aj commented 6 years ago

Do you mean checking usages of map-get, or map creation, or both?

Also, do these examples match your expectations?

$theme: (primary: #f00, secondary: #00f); // linter error
$theme: ('primary': #f00, 'secondary': #00f); // ok
$theme: ("primary": #f00, "secondary": #00f); // ok
map-get($theme, primary); // linter error
map-get($theme, 'primary'); // ok
nex3 commented 6 years ago

Do you mean checking usages of map-get, or map creation, or both?

Just map creation.