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

commaSpace - do not lint comments #392

Open charlierudolph opened 7 years ago

charlierudolph commented 7 years ago

Currently the commaSpace rule is being applied to comments

&:nth-of-type(2n+1) // matches 1,3,5,7 etc
eddiemonge commented 7 years ago

Have you tried

&:nth-of-type(2n+1) /* matches 1,3,5,7 etc */
eddiemonge commented 7 years ago

ping @charlierudolph

SimenB commented 7 years ago

Both should work, help appreciated!

PalleZingmark commented 6 years ago

I can see that we already strip out strings so we don't get false positives with commas in strings. Should be possible to use the same approach with line comments.

Example:

[...]

var removeQuotesRe = /(["'])(?:(?=(\\?))\2.)*?\1/g
var removeCommentRe = /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm

[...]

// just strip content between quotes and inline comments, leave rest of syntax intact
// this is so we don't get false positives with , in strings and inline comments
var trimmedLine = origLine.replace( removeQuotesRe, '""' ).trim()

if ( this.state.hasComment ) {
    trimmedLine = trimmedLine.replace( removeCommentRe, '$1' ).trim()
}

[...]