Skip to content

Commit 090055e

Browse files
committed
Initial commit
1 parent 1e08878 commit 090055e

11 files changed

+411
-1
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 2
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sudo: false
2+
3+
language: node_js
4+
node_js:
5+
- stable

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Head
2+
3+
* Initial release

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 stylelint
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+120-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,121 @@
11
# stylelint-config-standard
2-
The standard shareable config for stylelint
2+
[![NPM version](http://img.shields.io/npm/v/stylelint-config-standard.svg)](https://www.npmjs.org/package/stylelint-config-standard) [![Travis Build Status](https://img.shields.io/travis/stylelint/stylelint-config-standard/master.svg?label=unix%20build)](https://travis-ci.org/stylelint/stylelint-config-standard) [![AppVeyor Build Status](https://img.shields.io/appveyor/ci/stylelint/stylelint-config-standard/master.svg?label=windows%20build)](https://ci.appveyor.com/project/stylelint/stylelint-config-standard)
3+
4+
> The standard shareable config for stylelint.
5+
6+
Use it as is or as a foundation for your own config.
7+
8+
It is derived from the common rules found within a handful of CSS styleguides, including: [The Idiomatic CSS Principles](https://github.com/necolas/idiomatic-css),
9+
[Github's PrimerCSS Guidelines](http://primercss.io/guidelines/#scss),
10+
[Google's CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.xml#CSS_Formatting_Rules), [Airbnb's Styleguide](https://github.com/airbnb/css#css), and [@mdo's Code Guide](http://codeguide.co/#css).
11+
12+
It favours flexibility over strictness for things like multi-line declarations and single-line rulesets, and tries to avoid potentially divisive rules.
13+
14+
## Example
15+
16+
```css
17+
/**
18+
* Multi-line comment
19+
*/
20+
21+
.selector-1,
22+
.selector-2,
23+
.selector-3[type="text"] {
24+
background: linear-gradient(#fff, rgba(0, 0, 0, 0.8));
25+
box-sizing: border-box;
26+
display: block;
27+
color: #333;
28+
}
29+
30+
.selector-a,
31+
.selector-b {
32+
padding: 10px !important;
33+
top: calc(calc(1em * 2) / 3);
34+
}
35+
36+
.selector-x { width: 10%; }
37+
.selector-y { width: 20%; }
38+
.selector-z { width: 30%; }
39+
40+
/* Single-line comment */
41+
42+
@media (min-width >= 60em) {
43+
.selector {
44+
transform: translate(1, 1) scale(3);
45+
}
46+
}
47+
48+
@media (min-orientation: portrait), projection and (color) {
49+
.selector-i + .selector-ii {
50+
background: color(rgb(0, 0, 0) lightness(50%));
51+
font-family: helvetica, arial, sans-serif;
52+
}
53+
}
54+
55+
@media screen and (min-device-pixel-ratio: 2),
56+
screen and (min-resolution: 192dpi),
57+
screen and (min-resolution: 2dppx) {
58+
59+
.selector {
60+
background-image:
61+
repeating-linear-gradient(
62+
-45deg,
63+
transparent,
64+
#fff 25px,
65+
rgba(255, 255, 255, 1) 50px
66+
);
67+
margin: 10px;
68+
margin-bottom: 5px;
69+
box-shadow:
70+
0 1px 1px #000,
71+
0 1px 0 #fff,
72+
2px 2px 1px 1px #ccc inset;
73+
height: 10rem;
74+
}
75+
76+
.selector::after {
77+
content: "";
78+
background-image: url("x.svg");
79+
}
80+
}
81+
82+
```
83+
84+
_Note: the config is tested against this example, as such the example contains plenty of CSS syntax, formatting and features._
85+
86+
## Installation
87+
88+
```console
89+
$ npm install stylelint-config-standard
90+
```
91+
92+
## Usage
93+
94+
Set your stylelint config to:
95+
96+
```json
97+
{
98+
"extends": "stylelint-config-standard"
99+
}
100+
```
101+
102+
### Extending the config
103+
104+
Simply add a `"rules"` key to your config and add your overrides there.
105+
106+
For example, to change the `indentation` to tabs and turn off the `number-leading-zero` rule:
107+
108+
109+
```json
110+
{
111+
"extends": "stylelint-config-standard",
112+
"rules": {
113+
"indentation": "tab",
114+
"number-leading-zero": null
115+
}
116+
}
117+
```
118+
119+
## [Changelog](CHANGELOG.md)
120+
121+
## [License](LICENSE)

__tests__/index.js

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import config from "../"
2+
import stylelint from "stylelint"
3+
import test from "tape"
4+
5+
test("basic properties of config", t => {
6+
t.ok(isObject(config.rules), "rules is object")
7+
t.end()
8+
})
9+
10+
function isObject(obj) {
11+
return typeof obj === "object" && obj !== null
12+
}
13+
14+
const invalidCss = (
15+
`a {
16+
top: .2em;
17+
}
18+
19+
`)
20+
21+
stylelint.lint({
22+
code: invalidCss,
23+
config: config,
24+
})
25+
.then(function (data) {
26+
const { errored, results } = data
27+
const { warnings } = results[0]
28+
test("expected warnings", t => {
29+
t.ok(errored, "errored")
30+
t.equal(warnings.length, 1, "flags one warning")
31+
t.equal(warnings[0].text, "Expected a leading zero (number-leading-zero)", "correct warning text")
32+
t.end()
33+
})
34+
})
35+
.catch(function (err) {
36+
console.error(err.stack)
37+
})
38+
39+
const validCss = (
40+
`/**
41+
* Multi-line comment
42+
*/
43+
44+
.selector-1,
45+
.selector-2,
46+
.selector-3[type="text"] {
47+
background: linear-gradient(#fff, rgba(0, 0, 0, 0.8));
48+
box-sizing: border-box;
49+
display: block;
50+
color: #333;
51+
}
52+
53+
.selector-a,
54+
.selector-b {
55+
padding: 10px !important;
56+
top: calc(calc(1em * 2) / 3);
57+
}
58+
59+
.selector-x { width: 10%; }
60+
.selector-y { width: 20%; }
61+
.selector-z { width: 30%; }
62+
63+
/* Single-line comment */
64+
65+
@media (min-width >= 60em) {
66+
.selector {
67+
transform: translate(1, 1) scale(3);
68+
}
69+
}
70+
71+
@media (min-orientation: portrait), projection and (color) {
72+
.selector-i + .selector-ii {
73+
background: color(rgb(0, 0, 0) lightness(50%));
74+
font-family: helvetica, arial, sans-serif;
75+
}
76+
}
77+
78+
@media screen and (min-device-pixel-ratio: 2),
79+
screen and (min-resolution: 192dpi),
80+
screen and (min-resolution: 2dppx) {
81+
82+
.selector {
83+
background-image:
84+
repeating-linear-gradient(
85+
-45deg,
86+
transparent,
87+
#fff 25px,
88+
rgba(255, 255, 255, 1) 50px
89+
);
90+
margin: 10px;
91+
margin-bottom: 5px;
92+
box-shadow:
93+
0 1px 1px #000,
94+
0 1px 0 #fff,
95+
2px 2px 1px 1px #ccc inset;
96+
height: 10rem;
97+
}
98+
99+
.selector::after {
100+
content: "→";
101+
background-image: url("x.svg");
102+
}
103+
}
104+
105+
`)
106+
107+
stylelint.lint({
108+
code: validCss,
109+
config: config,
110+
})
111+
.then(function (data) {
112+
const { errored, results } = data
113+
const { warnings } = results[0]
114+
test("expected no warnings", t => {
115+
t.notOk(errored, "no errored")
116+
t.equal(warnings.length, 0, "flags no warnings")
117+
t.end()
118+
})
119+
})
120+
.catch(function (err) {
121+
console.error(err.stack)
122+
})

appveyor.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# http://www.appveyor.com/docs/appveyor-yml
2+
3+
environment:
4+
matrix:
5+
- nodejs_version: 5
6+
7+
version: "{build}"
8+
build: off
9+
deploy: off
10+
cache: [node_modules]
11+
12+
install:
13+
- ps: Install-Product node $env:nodejs_version
14+
- npm install
15+
16+
test_script:
17+
- node --version
18+
- npm --version
19+
- ps: "npm test # PowerShell"
20+
- cmd: "npm test"

index.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
module.exports = {
2+
"rules": {
3+
"at-rule-empty-line-before": [ "always", {
4+
except: ["blockless-group"],
5+
} ],
6+
"block-closing-brace-newline-after": "always",
7+
"block-closing-brace-newline-before": "always-multi-line",
8+
"block-closing-brace-space-before": "always-single-line",
9+
"block-opening-brace-newline-after": "always-multi-line",
10+
"block-opening-brace-space-after": "always-single-line",
11+
"block-opening-brace-space-before": "always",
12+
"color-hex-case": "lower",
13+
"color-hex-length": "short",
14+
"color-no-invalid-hex": true,
15+
"comment-empty-line-before": "always",
16+
"comment-whitespace-inside": "always",
17+
"declaration-bang-space-after": "never",
18+
"declaration-bang-space-before": "always",
19+
"declaration-block-semicolon-newline-after": "always-multi-line",
20+
"declaration-block-semicolon-space-after": "always-single-line",
21+
"declaration-block-semicolon-space-before": "never",
22+
"declaration-block-single-line-max-declarations": 1,
23+
"declaration-colon-newline-after": "always-multi-line",
24+
"declaration-colon-space-after": "always-single-line",
25+
"declaration-colon-space-before": "never",
26+
"function-calc-no-unspaced-operator": true,
27+
"function-comma-newline-after": "always-multi-line",
28+
"function-comma-space-after": "always-single-line",
29+
"function-comma-space-before": "never",
30+
"function-parentheses-newline-inside": "always-multi-line",
31+
"function-parentheses-space-inside": "never-single-line",
32+
"function-whitespace-after": "always",
33+
"function-url-quotes": "double",
34+
"indentation": 2,
35+
"max-empty-lines": 1,
36+
"media-feature-colon-space-after": "always",
37+
"media-feature-colon-space-before": "never",
38+
"media-feature-range-operator-space-after": "always",
39+
"media-feature-range-operator-space-before": "always",
40+
"media-query-list-comma-newline-after": "always-multi-line",
41+
"media-query-list-comma-space-after": "always-single-line",
42+
"media-query-list-comma-space-before": "never",
43+
"media-query-parentheses-space-inside": "never",
44+
"no-eol-whitespace": true,
45+
"no-missing-eof-newline": true,
46+
"number-leading-zero": "always",
47+
"number-no-trailing-zeros": true,
48+
"number-zero-length-no-unit": true,
49+
"rule-no-shorthand-property-overrides": true,
50+
"rule-non-nested-empty-line-before": "always-multi-line",
51+
"rule-trailing-semicolon": "always",
52+
"selector-combinator-space-after": "always",
53+
"selector-combinator-space-before": "always",
54+
"selector-list-comma-newline-after": "always",
55+
"selector-list-comma-space-before": "never",
56+
"selector-pseudo-element-colon-notation": "double",
57+
"string-quotes": "double",
58+
"value-list-comma-newline-after": "always-multi-line",
59+
"value-list-comma-space-after": "always-single-line",
60+
"value-list-comma-space-before": "never",
61+
},
62+
}

0 commit comments

Comments
 (0)