rrdelaney / jadelint

:dragon: A linter for the Jade templating language
https://rrdelaney.github.io/jadelint
MIT License
6 stars 1 forks source link

Rule: consistent use of single/double quotes #12

Closed patwork closed 9 years ago

patwork commented 9 years ago

A simple one: should choose one type of quotes (single/double option?) and stick to it (document wide):

//- Invalid
a(href="/kill", title='me')

//- Invalid
a(href="/johhny.html")
    img(src='mnemonic.png')

//- Valid (with option "single"?)
a(href='/', title='root')
    img(src='beer.jpg')

//- Valid (with option "double"?)
a(href="/just", title="do")
    img(src="it.svg")
rrdelaney commented 9 years ago

I'll implement this with the option to specify quote style

rrdelaney commented 9 years ago

Began working on this in https://github.com/rrdelaney/jadelint/commit/08827e65d7e70a9dec55920320ce2e6a764ed597

patwork commented 9 years ago

cool, hope there will be no problems with var str = 'this "is" funny' like tricks

rrdelaney commented 9 years ago

This is done. Instead of globally enforcing the rule, it now works like

//- Invalid
a(a="a" b='b')

//- Valid
a(a="a" b="b")
c(c='c' d='d')

You can enforce only one to be used in the .jadelintrc with the setting

{
  "UseConsistentQuotes": {
    "force": "<quote style>"
  }
}

For example, if the line was "force": "'", a(href="a") would be illegal anywhere.

If you have anymore questions, I created a bitter for jadelint.