SimenB / stylint

Improve your Stylus code with Stylint
https://simenb.github.io/stylint/
GNU General Public License v2.0
348 stars 62 forks source link

Multiline properties #395

Open sigorilla opened 7 years ago

sigorilla commented 7 years ago

Hi!

Stylint doesn't correctly validate multiline values of properties:

Code:

div {
    transition: border-color .1s ease-out 0s,
        background .1s ease-out 0s,
        left .15s ease-out 0s;
}

Output:

4:4  error  missing colon between property and value  colons
gedrick commented 7 years ago

I had the same issue when validating a huge codebase, my solution was as follows:

in file /src/checks/valid.js

insert @ line 17

var multiLineDeclaration = /([\w].*)[,|{]$/ //8

insert @sigorilla line 83

// if no match yet, perhaps this is part of a multi-line declaration
if ( !isValid ) {
    isValid = multiLineDeclaration.test( line );
}

Since the valid method doesn't have access to previous lines, we can't recursively look back to see if it's a part of a list of properties spanning multiple lines, unfortunately.

It's far from perfect and I just did this while digging around, but not worth putting into a PR until it's more robust...