airbnb / css

A mostly reasonable approach to CSS and Sass.
MIT License
6.93k stars 1.41k forks source link

Look into a config file for using http://stylelint.io/ #13

Closed andykenward closed 5 years ago

andykenward commented 8 years ago

Would be great to have a shared config file for stylelint.io with these rules.

It is written in JavaScript vs scss-lint that relies on Ruby.

Article about it

gaurav21r commented 8 years ago

+1 :+1:

timothyneiljohnson commented 8 years ago

+1 👍

ljharb commented 8 years ago

@timothyneiljohnson Now that Github has reactions, please use those to +1 in the future instead of adding comment noise. Thanks!

ntwb commented 8 years ago

From the README.md

  1. CSS
    • Formatting
      • Use soft tabs (2 spaces) for indentation: 'indentation': 2,
      • Do not use ID selectors: 'selector-no-id': true,
      • When using multiple selectors in a rule declaration, give each selector its own line: 'selector-list-comma-newline-after': 'always',
      • Put a space before the opening brace { in rule declarations: 'block-opening-brace-space-before': 'always',
      • In properties, put a space after, but not before, the : character: 'declaration-colon-space-after': 'always', and 'declaration-colon-space-before': 'never',
      • Put closing braces } of rule declarations on a new line: 'block-closing-brace-newline-before': 'always',
      • Put blank lines between rule declarations: 'rule-non-nested-empty-line-before': ['always', { ignore: ['after-comment'], }],
    • Comments
      • Prefer line comments (// in Sass-land) to block comments.
      • CSS: 'no-invalid-double-slash-comments': true, Ignored in Sass-land
      • Prefer comments on their own line. Avoid end-of-line comments: 'comment-empty-line-before': ['always', {ignore: ['stylelint-commands'],}],
      • Write detailed comments for code that isn't self-documenting:
      • Uses of z-index: n/a
      • Compatibility or browser-specific hacks: you might want to use no-browser-hacks rule with the warning severity
    • OOCSS and BEM
    • Border
  2. Sass
  3. Not Implemented for CSS formatting:
    • Prefer dashes over camelCasing in class names. Underscores and PascalCasing are okay if you are using BEM (see OOCSS and BEM below), use selector-class-pattern with a regular expression matching your pattern
  4. Suggestions, I've deliberately left out many rules and only covered as much as I could the Airbnb CSS / Sass Styleguide as it is written, I'd suggest reviewing these for additional rules:
ai commented 8 years ago

@lencioni Stylelint is already used by:

Using Stylelint is especially reasonable, because Stylelint copy ESLint architecture. If you like ESLint, you will love Stylelint too — same benefits.

michaelBenin commented 7 years ago

Hello, there hasn't been much action in this thread and I'm hoping to revive it. Is airbnb open to a pr for this?

ai commented 7 years ago

Stylelint become the most popular CSS linter from npm: http://www.npmtrends.com/csslint-vs-csscomb-vs-stylelint

ljharb commented 7 years ago

@michaelBenin yes, as long as it includes the right travis config so that it can be automatically verified :-)

ntwb commented 7 years ago

@michaelBenin The pull request is in #23, I'm happy to refresh it, update, add whatever Travis CI configuration is needed etc

andykenward commented 5 years ago

Going to close this as its been a few years.