Giter Site home page Giter Site logo

Quotation style enforcement? about stylint HOT 17 CLOSED

simenb avatar simenb commented on July 19, 2024
Quotation style enforcement?

from stylint.

Comments (17)

rossPatton avatar rossPatton commented on July 19, 2024

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.

from stylint.

rossPatton avatar rossPatton commented on July 19, 2024

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

from stylint.

awayken avatar awayken commented on July 19, 2024

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"],

from stylint.

awayken avatar awayken commented on July 19, 2024

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;
    }
}

from stylint.

rossPatton avatar rossPatton commented on July 19, 2024

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?

from stylint.

awayken avatar awayken commented on July 19, 2024

@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?

from stylint.

rossPatton avatar rossPatton commented on July 19, 2024

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.

from stylint.

jackbrewer avatar jackbrewer commented on July 19, 2024

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?

from stylint.

rossPatton avatar rossPatton commented on July 19, 2024

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

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

from stylint.

jackbrewer avatar jackbrewer commented on July 19, 2024

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)

from stylint.

rossPatton avatar rossPatton commented on July 19, 2024

Thanks!

from stylint.

awayken avatar awayken commented on July 19, 2024

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

from stylint.

rossPatton avatar rossPatton commented on July 19, 2024

@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

from stylint.

rossPatton avatar rossPatton commented on July 19, 2024

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

from stylint.

awayken avatar awayken commented on July 19, 2024

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

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

I'm using fa1ee81.

from stylint.

rossPatton avatar rossPatton commented on July 19, 2024

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

from stylint.

awayken avatar awayken commented on July 19, 2024

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

from stylint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.