1.0.0-alpha.9e8651d0 • Published 6 years ago

stylelint-config-kyt v1.0.0-alpha.9e8651d0

Weekly downloads
843
License
Apache-2.0
Repository
github
Last release
6 years ago

kyt Stylelint Linter and CSS/Sass Style Guide

This is an extension of config-standard with some overrides for CSS/Sass Modules.

Table of Contents

  1. Install
  2. CSS + Sass Guide
  3. Changelog

Install

If you want to install this linter extension, follow these install instructions.

  1. Install the stylelint-config-kyt npm package:
    npm i --save-dev stylelint stylelint-config-kyt stylelint-config-standard
  2. Add a .stylelintrc file to your project's root
  3. Add configuration:
{
  "extends": "stylelint-config-nyt",
  "rules": {}
}

CSS + Sass Guide

The following guide is best used with the kyt linter against CSS/Sass Modules.

Formatting

  • Use soft tabs (2 spaces) for indentation.
  • Always use camelCasing in class names.
  • Do not use ID selectors.
  • Do not use element selectors in CSS Modules files.
  • When using multiple selectors in a rule declaration, give each selector its own line.
  • Put a space before the opening brace { in rule declarations.
  • In properties, put a space after, but not before, the : character.
  • Put closing braces } of rule declarations on a new line
  • Put blank lines between rule declarations and nested pseudo-selectors.

Bad

.avatar {
  border-radius: 50%;
  border: 2px solid white;
}
.no,
.nope,
.not_good {
  // ...
}
#lol-no {
  // ...
}

Good

.avatar {
  border-radius: 50%;
  border: 2px solid white;
}

.one,
.selector,
.perLine {
  // ...
}

Comments

  • Prefer line comments (// in Sass-land) to block comments.
  • Prefer comments on their own line.
  • Write detailed comments for code that isn't self-documenting:
    • Uses of z-index
    • Compatibility or browser-specific hacks

ID selectors

While it is possible to select elements by ID in CSS, it should generally be considered an anti-pattern. ID selectors introduce an unnecessarily high level of specificity to your rule declarations, and they are not reusable.

You should never define an ID selector in a CSS Module.

Syntax

  • Use the .scss syntax, never the original .sass syntax
  • Order your regular CSS and @include declarations logically (see below)

Ordering of property declarations

  1. @include or composes declarations
  2. Property declarations in alphabetical order

    .btnGreen {
      @include transition(background 0.5s ease);
      background: green;
      color: red;
      font-weight: bold;
      // ...
    }
  3. Nested pseudo-selectors

    Nested pseudo-selectors go last, and nothing goes after them.

    .btn {
      @include color(red);
      font-weight: bold;
    
      &:hover {
        cursor: pointer;
      }
    }

Variables

Prefer camelCased variable names (e.g. $myVariable).

Mixins

  • 1 space after the mixin name before the opening parens
  • 1 space after colons and between params
  • Commas are used as separators unless passing in a comma separated list as an argument, in these cases use a semicolon Default values can be used when it's convenient
1.4.8-alpha.111

2 years ago

1.4.8-alpha.112

2 years ago

1.4.8-alpha.98

2 years ago

1.4.8-alpha.96

2 years ago

1.4.8-alpha.103

2 years ago

1.4.8-alpha.102

2 years ago

1.4.8-alpha.99

2 years ago

1.4.7

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.0

5 years ago

1.2.3

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

6 years ago

1.0.0-beta.40.1

6 years ago

1.0.0-beta.40.0

6 years ago

1.0.0-beta.39

6 years ago

1.0.0-beta.38

6 years ago

1.0.0-beta.37

6 years ago

1.0.0-beta.36

6 years ago

1.0.0-beta.35

6 years ago

1.0.0-beta.34

6 years ago

1.0.0-beta.33

6 years ago

1.0.0-beta.32

6 years ago

1.0.0-beta.31

6 years ago

1.0.0-beta.30

6 years ago

1.0.0-beta.29

6 years ago

1.0.0-beta.26

6 years ago

1.0.0-beta.27

6 years ago

1.0.0-beta.24

6 years ago

1.0.0-beta.5

6 years ago

1.0.0-beta.4

6 years ago

1.0.0-beta.1

6 years ago

1.0.0-beta.0

6 years ago

1.0.0-alpha.18

6 years ago

1.0.0-alpha.17

6 years ago

1.0.0-hot.17

6 years ago

1.0.0-hot.18

6 years ago

1.0.0-hot.16

6 years ago

1.0.0-hot.15

6 years ago

1.0.0-alpha.10

6 years ago

1.0.0-alpha.11

6 years ago

0.9.1-alpha.0

6 years ago

1.0.0-alpha.0

6 years ago

1.0.0-alpha.15

8 years ago

1.0.0-alpha.14

8 years ago

1.0.0-alpha.13

8 years ago

1.0.0-alpha.12

8 years ago

1.0.0-alpha.7

8 years ago

1.0.0-alpha.6

8 years ago

1.0.0-alpha.4

8 years ago

1.0.0-alpha.3

8 years ago

1.0.0-alpha.8

8 years ago

1.0.0-alpha.2

8 years ago

1.0.0-alpha.1

8 years ago

0.3.3-alpha.2

8 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.3.0-beta.1

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.1

9 years ago

0.0.1-alpha.2

9 years ago

0.0.1-alpha.1

9 years ago