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

Keyword arguments with hyphens incorrectly reported by DeclaredNameLinter #27

Closed
sds opened this issue Jun 7, 2013 · 0 comments
Closed
Labels

Comments

@sds
Copy link
Owner

sds commented Jun 7, 2013

When passing keyword arguments to a function or mixin, e.g.

@include line-clamp($line-count: 3, $line-height: 1.5em);

...scss-lint will incorrectly report lints for each keyword argument.

This is caused by the Sass parser (as of 3.2.9) normalizing the keyword arguments to their underscore-ized form when building the parse tree.

There are two possible solutions:

  • Monkey-patch Sass::Script::Variable#underscored_name to return the original name.
    • Fixes the problem and is quick to implement, but will break Sass compiling (not a problem since scss-lint doesn't compile SCSS for any of its lints...yet)
    • Introduces another bug where if a user calls a function with two variables that are the same except they differ in hyphen and underscore, e.g. func($line-height: 1, $line_height: 1) the parser won't report an error. Probably ok, as this is an extreme edge case.
    • Still sucks since we're monkey-patching rather than contributing upstream
  • Contribute an upstream fix to sass to change the keywords attribute of Funcall and MixinNode nodes so that it isn't a hash of String => Sass::Script::Node, but something that preserves the original name of the variable, like Sass::Script::Variable => Sass::Script::Node.
    • More complex to implement, forces us to change dependency from official sass gem to fork until it is merged upstream (and there is a chance it may not be merged upstream).

Will investigate when more time permits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant