scss-lint icon indicating copy to clipboard operation
scss-lint copied to clipboard

PropertyUnits should report warnings when units are missing

Open ptarjan opened this issue 10 years ago • 6 comments

Right now, scss-lint is totally fine with

.foo {
  padding: 30;
}

Can we please reject that?

ptarjan avatar Jun 25 '15 16:06 ptarjan

Hey @ptarjan, that CSS looks perfectly valid to me from a syntactical perspective. If you are referring to the lack of units on padding, this kind of checking can get complicated since it's hard for scss-lint to know all the situations where specifying units would make sense (especially when you need to also work around interpolation).

There might be a solution where we can get the PropertyUnits linter to report a warning when no units are provided for certain properties. I'd be open to a pull request adding that functionality, otherwise I'll get to it when I can.

sds avatar Jun 25 '15 18:06 sds

Yes that's exactly what I meant, the missing units.

ptarjan avatar Jun 25 '15 22:06 ptarjan

Does PropertyUnits not already have this functionality? I'm looking at the

    border: ['px'] # Only pixels

line here

srawlins avatar Jul 08 '15 23:07 srawlins

An nice. Then I'm proposing that by default all the allowed CSS units should be in there.

ptarjan avatar Jul 09 '15 09:07 ptarjan

@ptarjan is there a documented list of CSS properties and their allowed units you could point to? That would make implementing this request pretty trivial.

sds avatar Jul 15 '15 06:07 sds

Sadly I don't, I'd be Googling for it like you would. Can you start small with the obvious ones and then grow it as we notice problems? I'd start with padding (and all the 4 -top, -right variants), margin (and variants) font-size, height, and width.

ptarjan avatar Jul 15 '15 19:07 ptarjan