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

Fixes #894 - added a CSS Linter #1509

Merged
merged 4 commits into from
Jun 10, 2017
Merged

Fixes #894 - added a CSS Linter #1509

merged 4 commits into from
Jun 10, 2017

Conversation

magsout
Copy link
Member

@magsout magsout commented Apr 14, 2017

A start for adding a CSS linter.

I don"t lint our css file yet. Because I think we need to talk before @zoepage @miketaylr @karlcow about thoses rules.

I suggest to go to https://maximgatilin.github.io/stylelint-config/ and you tried to create your own configuration. It takes around 5 minutes (about 42 rules) to see if at first we are agree or not.

After we can discuss to enhance this rules and fix all error.

@miketaylr
Copy link
Member

Very cool idea (also cool config builder!)

I don't have super strong feelings about most of this, but here's what I picked:

{
    "extends": "stylelint-config-standard",
    "rules": {
        "indentation": 2,
        "string-quotes": "double",
        "no-duplicate-selectors": true,
        "color-hex-case": "lower",
        "color-hex-length": "short",
        "selector-combinator-space-after": "always",
        "selector-attribute-quotes": "always",
        "selector-attribute-operator-space-before": "never",
        "selector-attribute-operator-space-after": "never",
        "selector-attribute-brackets-space-inside": "never",
        "declaration-block-trailing-semicolon": "always",
        "declaration-colon-space-before": "never",
        "declaration-colon-space-after": "always",
        "property-no-vendor-prefix": true,
        "value-no-vendor-prefix": true,
        "font-family-name-quotes": "always-unless-keyword",
        "comment-empty-line-before": "always",
        "at-rule-no-vendor-prefix": true,
        "rule-empty-line-before": "always-multi-line",
        "selector-pseudo-element-colon-notation": "double",
        "selector-pseudo-class-parentheses-space-inside": "never",
        "selector-no-vendor-prefix": true,
        "selector-no-universal": true,
        "media-feature-range-operator-space-before": "always",
        "media-feature-range-operator-space-after": "always",
        "media-feature-name-no-vendor-prefix": true,
        "media-feature-colon-space-before": "always",
        "media-feature-colon-space-after": "always"
    }
}

@zoepage
Copy link
Member

zoepage commented Apr 17, 2017

That's a great idea! :)
I'd love to add 1-2 comments, but my kid is sick. I hope, its ok if it takes 2-3 days. :/

@magsout
Copy link
Member Author

magsout commented Apr 18, 2017

@zoepage yeah, don't worry ❤️

@zoepage
Copy link
Member

zoepage commented Apr 20, 2017

Regarding the npm scripts:

"lint": "npm run lintJS && npm run lintCSS",
"lintJS": "eslint ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib && grunt travis-lint",
"lintCSS": "stylelint ./webcompat/static/css/development/**/*.css",
"fix": "npm run fixJS && npm run fixCSS",
"fixJS": "eslint --fix ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib",
"fixCSS": "stylelint ./webcompat/static/css/development/**/*.css --fix",

I'd suggest to change the naming convention here a little bit, so it should be easier to keep the overview.

"lint": "npm run lint:JS && npm run lint:CSS",
"lint:JS": "eslint ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib && grunt travis-lint",
"lint:CSS": "stylelint ./webcompat/static/css/development/**/*.css",
"fix": "npm run fix:JS && npm run fix:CSS",
"fix:JS": "eslint --fix ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib",
"fix:CSS": "stylelint ./webcompat/static/css/development/**/*.css --fix",

The : is treated as part of the string, which just provides little bit more structure here.

CSS style

I'd love to add selector-no-qualifying-type with an excluding option for ignoring type for input.
https://stylelint.io/user-guide/rules/selector-no-qualifying-type/

"media-feature-colon-space-before": "always", I'd appreciate false here, but not set to it. :)

Otherwise I second @miketaylr 's suggestion.

Thanks @magsout for the idea and work :)

Copy link
Member

@zoepage zoepage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karlcow
Copy link
Member

karlcow commented Apr 21, 2017

I'd love to add selector-no-qualifying-type with an excluding option for ignoring type for input.
https://stylelint.io/user-guide/rules/selector-no-qualifying-type/

if I understand the docs it means:

"selector-no-qualifying-type":  [ true, {"ignore": "attribute"} ],
"media-feature-colon-space-before": "never"

so many rules…

we could probably add

@zoepage
Copy link
Member

zoepage commented Apr 21, 2017

if I understand the docs it means:

"selector-no-qualifying-type":  [ true, {"ignore": "attribute"} ],
"media-feature-colon-space-before": "never"

Yes. Thanks for making that clear @karlcow

we could probably add
"declaration-block-no-duplicate-properties": true
"no-eol-whitespace": true

I agree.

@magsout
Copy link
Member Author

magsout commented Apr 28, 2017

@zoepage

The : is treated as part of the string, which just provides little bit more structure here.

good idea, much better 👍

@magsout
Copy link
Member Author

magsout commented Apr 28, 2017

@zoepage @karlcow @miketaylr I added your suggestions.

I proposed to fix all CSS and try to see if everything is ok..

@miketaylr
Copy link
Member

Let's go for it @magsout. Also, once that's done we should probably add a "Linting" section to https://github.com/webcompat/webcompat.com/blob/master/docs/pr-coding-guidelines.md (that can be in a follow up bug).

package.json Outdated
"lint": "npm run lint:JS && npm run lint:CSS",
"lint:JS": "eslint ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib && grunt travis-lint",
"lint:CSS": "stylelint ./webcompat/static/css/development/**/*.css",
"fix": "npm run fix:JS && npm run fix:CSS",

This comment was marked as abuse.

@magsout magsout force-pushed the issues/894 branch 2 times, most recently from 09d1b09 to 2f6f2ba Compare May 19, 2017 20:38
@magsout
Copy link
Member Author

magsout commented May 19, 2017

ok, ouch, done..

package.json Outdated
"fix": "eslint --fix ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib",
"lint": "npm run lint:JS && npm run lint:CSS",
"lint:JS": "eslint ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib && grunt travis-lint",
"lint:CSS": "stylelint ./webcompat/static/css/development/**/*.css",

This comment was marked as abuse.

package.json Outdated
"lint:CSS": "stylelint ./webcompat/static/css/development/**/*.css",
"fix": "npm run lint:fix:JS && npm run lint:fix:CSS",
"lint:fix:JS": "eslint --fix ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib",
"lint:fix:CSS": "stylelint ./webcompat/static/css/development/**/*.css --fix",

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@magsout
Copy link
Member Author

magsout commented Jun 9, 2017

@zoepage

4 commits:

  1. Add stylelint configuration
  2. Updated documentation
  3. lint all css-'s files
  4. updated lint-staged

@zoepage
Copy link
Member

zoepage commented Jun 9, 2017

@magsout SWEET! <3

Is there a reason for the linter not to check the prism.css in vendor? :)

@magsout
Copy link
Member Author

magsout commented Jun 9, 2017

@zoepage I think it's not our script, so we don't have to lint it, IMHO.

@zoepage
Copy link
Member

zoepage commented Jun 10, 2017

Tests fail, but not because of any changes made. So, I'll merge :)

Good job @magsout :)

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

Successfully merging this pull request may close these issues.

4 participants