Permalink
Browse files

Initial commit

  • Loading branch information...
1 parent 1e08878 commit 090055e51b7b179ce7f2fa1be16a0d8cd472d6e4 @jeddy3 jeddy3 committed Jan 11, 2016
Showing with 411 additions and 1 deletion.
  1. +13 −0 .editorconfig
  2. +1 −0 .gitattributes
  3. +1 −0 .gitignore
  4. +5 −0 .travis.yml
  5. +3 −0 CHANGELOG.md
  6. +21 −0 LICENSE
  7. +120 −1 README.md
  8. +122 −0 __tests__/index.js
  9. +20 −0 appveyor.yml
  10. +62 −0 index.js
  11. +43 −0 package.json
View
@@ -0,0 +1,13 @@
+# editorconfig.org
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 2
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+trim_trailing_whitespace = false
View
@@ -0,0 +1 @@
+* text eol=lf
View
@@ -0,0 +1 @@
+node_modules
View
@@ -0,0 +1,5 @@
+sudo: false
+
+language: node_js
+node_js:
+ - stable
View
@@ -0,0 +1,3 @@
+# Head
+
+* Initial release
View
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 stylelint
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
View
@@ -1,2 +1,121 @@
# stylelint-config-standard
-The standard shareable config for stylelint
+[![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)
+
+> The standard shareable config for stylelint.
+
+Use it as is or as a foundation for your own config.
+
+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),
+[Github's PrimerCSS Guidelines](http://primercss.io/guidelines/#scss),
+[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).
+
+It favours flexibility over strictness for things like multi-line declarations and single-line rulesets, and tries to avoid potentially divisive rules.
+
+## Example
+
+```css
+/**
+ * Multi-line comment
+ */
+
+.selector-1,
+.selector-2,
+.selector-3[type="text"] {
+ background: linear-gradient(#fff, rgba(0, 0, 0, 0.8));
+ box-sizing: border-box;
+ display: block;
+ color: #333;
+}
+
+.selector-a,
+.selector-b {
+ padding: 10px !important;
+ top: calc(calc(1em * 2) / 3);
+}
+
+.selector-x { width: 10%; }
+.selector-y { width: 20%; }
+.selector-z { width: 30%; }
+
+/* Single-line comment */
+
+@media (min-width >= 60em) {
+ .selector {
+ transform: translate(1, 1) scale(3);
+ }
+}
+
+@media (min-orientation: portrait), projection and (color) {
+ .selector-i + .selector-ii {
+ background: color(rgb(0, 0, 0) lightness(50%));
+ font-family: helvetica, arial, sans-serif;
+ }
+}
+
+@media screen and (min-device-pixel-ratio: 2),
+ screen and (min-resolution: 192dpi),
+ screen and (min-resolution: 2dppx) {
+
+ .selector {
+ background-image:
+ repeating-linear-gradient(
+ -45deg,
+ transparent,
+ #fff 25px,
+ rgba(255, 255, 255, 1) 50px
+ );
+ margin: 10px;
+ margin-bottom: 5px;
+ box-shadow:
+ 0 1px 1px #000,
+ 0 1px 0 #fff,
+ 2px 2px 1px 1px #ccc inset;
+ height: 10rem;
+ }
+
+ .selector::after {
+ content: "";
+ background-image: url("x.svg");
+ }
+}
+
+```
+
+_Note: the config is tested against this example, as such the example contains plenty of CSS syntax, formatting and features._
+
+## Installation
+
+```console
+$ npm install stylelint-config-standard
+```
+
+## Usage
+
+Set your stylelint config to:
+
+```json
+{
+ "extends": "stylelint-config-standard"
+}
+```
+
+### Extending the config
+
+Simply add a `"rules"` key to your config and add your overrides there.
+
+For example, to change the `indentation` to tabs and turn off the `number-leading-zero` rule:
+
+
+```json
+{
+ "extends": "stylelint-config-standard",
+ "rules": {
+ "indentation": "tab",
+ "number-leading-zero": null
+ }
+}
+```
+
+## [Changelog](CHANGELOG.md)
+
+## [License](LICENSE)
View
@@ -0,0 +1,122 @@
+import config from "../"
+import stylelint from "stylelint"
+import test from "tape"
+
+test("basic properties of config", t => {
+ t.ok(isObject(config.rules), "rules is object")
+ t.end()
+})
+
+function isObject(obj) {
+ return typeof obj === "object" && obj !== null
+}
+
+const invalidCss = (
+`a {
+ top: .2em;
+}
+
+`)
+
+stylelint.lint({
+ code: invalidCss,
+ config: config,
+})
+.then(function (data) {
+ const { errored, results } = data
+ const { warnings } = results[0]
+ test("expected warnings", t => {
+ t.ok(errored, "errored")
+ t.equal(warnings.length, 1, "flags one warning")
+ t.equal(warnings[0].text, "Expected a leading zero (number-leading-zero)", "correct warning text")
+ t.end()
+ })
+})
+.catch(function (err) {
+ console.error(err.stack)
+})
+
+const validCss = (
+`/**
+ * Multi-line comment
+ */
+
+.selector-1,
+.selector-2,
+.selector-3[type="text"] {
+ background: linear-gradient(#fff, rgba(0, 0, 0, 0.8));
+ box-sizing: border-box;
+ display: block;
+ color: #333;
+}
+
+.selector-a,
+.selector-b {
+ padding: 10px !important;
+ top: calc(calc(1em * 2) / 3);
+}
+
+.selector-x { width: 10%; }
+.selector-y { width: 20%; }
+.selector-z { width: 30%; }
+
+/* Single-line comment */
+
+@media (min-width >= 60em) {
+ .selector {
+ transform: translate(1, 1) scale(3);
+ }
+}
+
+@media (min-orientation: portrait), projection and (color) {
+ .selector-i + .selector-ii {
+ background: color(rgb(0, 0, 0) lightness(50%));
+ font-family: helvetica, arial, sans-serif;
+ }
+}
+
+@media screen and (min-device-pixel-ratio: 2),
+ screen and (min-resolution: 192dpi),
+ screen and (min-resolution: 2dppx) {
+
+ .selector {
+ background-image:
+ repeating-linear-gradient(
+ -45deg,
+ transparent,
+ #fff 25px,
+ rgba(255, 255, 255, 1) 50px
+ );
+ margin: 10px;
+ margin-bottom: 5px;
+ box-shadow:
+ 0 1px 1px #000,
+ 0 1px 0 #fff,
+ 2px 2px 1px 1px #ccc inset;
+ height: 10rem;
+ }
+
+ .selector::after {
+ content: "→";
+ background-image: url("x.svg");
+ }
+}
+
+`)
+
+stylelint.lint({
+ code: validCss,
+ config: config,
+})
+.then(function (data) {
+ const { errored, results } = data
+ const { warnings } = results[0]
+ test("expected no warnings", t => {
+ t.notOk(errored, "no errored")
+ t.equal(warnings.length, 0, "flags no warnings")
+ t.end()
+ })
+})
+.catch(function (err) {
+ console.error(err.stack)
+})
View
@@ -0,0 +1,20 @@
+# http://www.appveyor.com/docs/appveyor-yml
+
+environment:
+ matrix:
+ - nodejs_version: 5
+
+version: "{build}"
+build: off
+deploy: off
+cache: [node_modules]
+
+install:
+ - ps: Install-Product node $env:nodejs_version
+ - npm install
+
+test_script:
+ - node --version
+ - npm --version
+ - ps: "npm test # PowerShell"
+ - cmd: "npm test"
View
@@ -0,0 +1,62 @@
+module.exports = {
+ "rules": {
+ "at-rule-empty-line-before": [ "always", {
+ except: ["blockless-group"],
+ } ],
+ "block-closing-brace-newline-after": "always",
+ "block-closing-brace-newline-before": "always-multi-line",
+ "block-closing-brace-space-before": "always-single-line",
+ "block-opening-brace-newline-after": "always-multi-line",
+ "block-opening-brace-space-after": "always-single-line",
+ "block-opening-brace-space-before": "always",
+ "color-hex-case": "lower",
+ "color-hex-length": "short",
+ "color-no-invalid-hex": true,
+ "comment-empty-line-before": "always",
+ "comment-whitespace-inside": "always",
+ "declaration-bang-space-after": "never",
+ "declaration-bang-space-before": "always",
+ "declaration-block-semicolon-newline-after": "always-multi-line",
+ "declaration-block-semicolon-space-after": "always-single-line",
+ "declaration-block-semicolon-space-before": "never",
+ "declaration-block-single-line-max-declarations": 1,
+ "declaration-colon-newline-after": "always-multi-line",
+ "declaration-colon-space-after": "always-single-line",
+ "declaration-colon-space-before": "never",
+ "function-calc-no-unspaced-operator": true,
+ "function-comma-newline-after": "always-multi-line",
+ "function-comma-space-after": "always-single-line",
+ "function-comma-space-before": "never",
+ "function-parentheses-newline-inside": "always-multi-line",
+ "function-parentheses-space-inside": "never-single-line",
+ "function-whitespace-after": "always",
+ "function-url-quotes": "double",
+ "indentation": 2,
+ "max-empty-lines": 1,
+ "media-feature-colon-space-after": "always",
+ "media-feature-colon-space-before": "never",
+ "media-feature-range-operator-space-after": "always",
+ "media-feature-range-operator-space-before": "always",
+ "media-query-list-comma-newline-after": "always-multi-line",
+ "media-query-list-comma-space-after": "always-single-line",
+ "media-query-list-comma-space-before": "never",
+ "media-query-parentheses-space-inside": "never",
+ "no-eol-whitespace": true,
+ "no-missing-eof-newline": true,
+ "number-leading-zero": "always",
+ "number-no-trailing-zeros": true,
+ "number-zero-length-no-unit": true,
+ "rule-no-shorthand-property-overrides": true,
+ "rule-non-nested-empty-line-before": "always-multi-line",
+ "rule-trailing-semicolon": "always",
+ "selector-combinator-space-after": "always",
+ "selector-combinator-space-before": "always",
+ "selector-list-comma-newline-after": "always",
+ "selector-list-comma-space-before": "never",
+ "selector-pseudo-element-colon-notation": "double",
+ "string-quotes": "double",
+ "value-list-comma-newline-after": "always-multi-line",
+ "value-list-comma-space-after": "always-single-line",
+ "value-list-comma-space-before": "never",
+ },
+}
Oops, something went wrong.

0 comments on commit 090055e

Please sign in to comment.