closure-stylesheets icon indicating copy to clipboard operation
closure-stylesheets copied to clipboard

Closure Stylesheets needs a linter

Open dbarnett opened this issue 10 years ago • 3 comments
trafficstars

A linter for closure stylesheets could detect a lot of simple style issues like unsorted @requires, whitespace conventions, etc.

Probably there would be some obvious problems to point out globally and some Google style guidelines documented at https://github.com/google/styleguide that could be enabled via a flag.

dbarnett avatar Oct 15 '15 17:10 dbarnett

Yes, yes it does. Would you be willing to help out?

iflan avatar Oct 20 '15 17:10 iflan

If you could add some pointers here for how you'd recommend implementing it, it's not impossible I'd be able to help out.

dbarnett avatar Oct 20 '15 17:10 dbarnett

Awesome! :-)

I actually don't have any recommendation for how to implement it at the moment. Some of the linters that I've seen are just a bunch of regexps and they don't really care about understanding the code structure. Others try to leverage the power of a real parser to make more intelligent recommendations.

For the moment, because we have nothing, the bar for an initial linter would be pretty low. I'd be fine with something simple that looks for particular rule violations.

Just to take a couple examples (more or less at random) from the style guide:

Avoid user agent detection as well as CSS “hacks”—try a different approach first.

This one should be pretty easy to detect with some regexps. And for the Closure Stylesheet compiler, this is particularly important since it was built to enable the same stylesheet to be compiled and targeted to different browsers.

Use a semicolon after every declaration.

That should be pretty easy to spot with a regexp.

Use meaningful or generic ID and class names.

That's pretty much impossible to automate.

So, if you wanted to start out with something simple based on regexps or a simple parser, I think that could work. What do you think?

iflan avatar Oct 20 '15 18:10 iflan