Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quotation style enforcement? #47

Closed
awayken opened this issue Mar 13, 2015 · 17 comments
Closed

Quotation style enforcement? #47

awayken opened this issue Mar 13, 2015 · 17 comments
Milestone

Comments

@awayken
Copy link
Contributor

awayken commented Mar 13, 2015

A feature that I like from JSHint is the ability to enforce quotation types. I try to enforce double quotes in my CSS/Stylus and single quotes in my JavaScript. Is that something others would find valuable in Stylint?

That said, it looks like JSHint is moving away from enforcing this rule altogether: http://jshint.com/docs/options/#quotmark

@rossPatton
Copy link
Collaborator

Yeah, it looks like jshint is letting jscs handle issues of code style in the future.

Personally, I see stylint as being a linter for both code correctness and code style, so a rule for enforcing quotation marks makes sense to me.

@rossPatton
Copy link
Collaborator

if you pull the latest, this feature should be available now, could use some testing

@awayken
Copy link
Contributor Author

awayken commented Mar 16, 2015

Leave it to me to find some edge cases. 😉

I found some inconsistency when checking quotes in selectors. Hopefully the example below makes the issue clear.

quotes.styl

// Passes but shouldn't
[class*="--button"] {
    border: 1px solid $primary-color;
}

// Last line passes but shouldn't
// Other lines fail as expected
[class*="--button"],
[class*="--bigbutton"],
input[type="text"],
input[type="button"] {
    border: 1px solid $primary-color;
}

quotes.json

{
    "alphabetical": true,
    "borderNone": true,
    "brackets": false,
    "colons": false,
    "colors": false,
    "commaSpace": true,
    "commentSpace": false,
    "cssLiteral": false,
    "depthLimit": false,
    "duplicates": true,
    "efficient": true,
    "enforceBlockStyle": false,
    "enforceVarStyle": false,
    "extendPref": false,
    "globalDupe": false,
    "indentSpaces": 4,
    "leadingZero": true,
    "maxWarnings": 10,
    "maxWarningsKill": false,
    "mixed": false,
    "namingConvention": false,
    "parenSpace": false,
    "placeholders": true,
    "quotePref": "single",
    "semicolons": false,
    "universal": true,
    "valid": false,
    "whitespace": true,
    "zeroUnits": true,
    "zIndexDuplicates": false,
    "zIndexNormalize": false
}

Output:

Warning:  preferred quote style is single quotes
File: quotes.styl
Line: 14: [class*="--button"],

Warning:  preferred quote style is single quotes
File: quotes.styl
Line: 15: [class*="--bigbutton"],

Warning:  preferred quote style is single quotes
File: quotes.styl
Line: 16: input[type="text"],

@awayken
Copy link
Contributor Author

awayken commented Mar 16, 2015

There seems to be a problem checking for quote preference when setting argument defaults. If I specify quotePref: "single", the following still passes:

show-content( $content = "Hello!" ) {
    &::before {
        content: $content;
    }
}

@rossPatton
Copy link
Collaborator

interesting that you're hitting these issues - i've tested all of the cases here with all the quotePref settings and they all appear to be behaving as expected, ie, i can't replicate the issue

someone else want to test this?

@rossPatton rossPatton modified the milestone: 0.9.3 Mar 21, 2015
@awayken
Copy link
Contributor Author

awayken commented Mar 23, 2015

@rossPatton I'm testing with version Stylint version: 0.9.2. If you create files and use the settings as I have them above, do you see the issue like I do?

@rossPatton
Copy link
Collaborator

Yeah, i always test by running stylint against real stylus files, and then again with unit tests.

In both cases I didn't have this issue.

I'll take another look, and make sure i'm testing with 0.9.2 instead of the latest on my local, and post an update here.

@jackbrewer
Copy link
Contributor

I'm using master and am seeing the same output as pasted above: only 3 warnings reported for the file, even though 5 exist.

I noticed if I add additional classes to the selectors, I can get all 5 to report warnings as expected.

[class*="--button"],
.additional-class {
    border: 1px solid $primary-color;
}

[class*="--button"],
[class*="--bigbutton"],
input[type="text"],
input[type="button"],
.another-additional-class {
    border: 1px solid $primary-color;
}

Also, when using my preferred minimal syntax, all 5 warnings are reported as expected, without needing the additional classes:

[class*="--button"]
  border 1px solid $primary-color

[class*="--button"]
[class*="--bigbutton"]
input[type="text"]
input[type="button"]
  border 1px solid $primary-color

Maybe something to do with attribute selectors next to curly braces?

@rossPatton
Copy link
Collaborator

@jackbrewer i can take another look, thanks for providing more examples.

could you try pulling develop and testing against that as well?

@jackbrewer
Copy link
Contributor

Same output as master – 3 warning for the original stylus, full 5 warnings with the modifications from my above message. Tested on latest develop (d3a01bc)

@rossPatton
Copy link
Collaborator

Thanks!

@rossPatton rossPatton modified the milestones: 0.9.3, 0.9.4 Mar 24, 2015
@awayken
Copy link
Contributor Author

awayken commented Apr 15, 2015

Not sure if this is helpful, but I pulled the latest develop (3163885), and I still see issues.

@rossPatton
Copy link
Collaborator

@awayken yeaaah, that's to be expected, i haven't really gotten to this one yet. soon though, i intend this fix to be in 0.9.5

@rossPatton
Copy link
Collaborator

@awayken aaand this should be fixed now (in develop). Lemme know!

@awayken
Copy link
Contributor Author

awayken commented Apr 16, 2015

The only case that still doesn't error is in the function declaration.

show-content( $content = "Hello!" ) {
    &::before {
        content: $content;
    }
}

I'm using fa1ee81.

@rossPatton
Copy link
Collaborator

@awayken should be good now. it's now fixed in 0.9.5

@awayken
Copy link
Contributor Author

awayken commented Apr 21, 2015

👍 Looks good to me. Just tested with 26e58b7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants