Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jeddy3 committed Jul 1, 2017
1 parent a490658 commit b9331a9
Show file tree
Hide file tree
Showing 13 changed files with 324 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .editorconfig
@@ -0,0 +1,10 @@
# 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
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text eol=lf
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
node_modules
package-lock.json
23 changes: 23 additions & 0 deletions .travis.yml
@@ -0,0 +1,23 @@
sudo: false

git:
depth: 1

branches:
only:
- master

language: node_js

# cache node modules
cache:
directories:
- node_modules

node_js:
- '8'
- '6'

before_install:
# remove outdated deps, assists with cache maintenance
- npm prune
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,3 @@
# 0.1.0

- Initial release
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 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.
58 changes: 57 additions & 1 deletion README.md
@@ -1,2 +1,58 @@
# stylelint-config-recommended
The recommended shareable config for stylelint

[![NPM version](http://img.shields.io/npm/v/stylelint-config-recommended.svg)](https://www.npmjs.org/package/stylelint-config-recommended) [![Build Status](https://travis-ci.org/stylelint/stylelint-config-recommended.svg?branch=master)](https://travis-ci.org/stylelint/stylelint-config-recommended) [![Build status](https://ci.appveyor.com/api/projects/status/o8rfhyax6n7bjnlt/branch/master?svg=true)](https://ci.appveyor.com/project/stylelint/stylelint-config-recommended/branch/master)

> The recommended shareable config for stylelint.
It turns on all the _possible errors_ rules within stylelint.

Use it as is or as a foundation for your own config.

## Installation

```bash
npm install stylelint-config-recommended --save-dev
```

## Usage

If you've installed `stylelint-config-recommended` locally within your project, just set your `stylelint` config to:

```json
{
"extends": "stylelint-config-recommended"
}
```

If you've globally installed `stylelint-config-recommended` using the `-g` flag, then you'll need to use the absolute path to `stylelint-config-recommended` in your config e.g.

```json
{
"extends": "/absolute/path/to/stylelint-config-recommended"
}
```

### Extending the config

Simply add a `"rules"` key to your config, then add your overrides and additions there.

For example, to turn off the `block-no-empty` rule, change the `property-no-unknown` rule to use its `ignoreAtRules` option and add the `unit-whitelist` rule:

```json
{
"extends": "stylelint-config-recommended",
"rules": {
"block-no-empty": "tab",
"property-no-unknown": [ true, {
"ignoreProperties": [
"composes"
]
}],
"unit-whitelist": ["em", "rem", "s"]
}
}
```

## [Changelog](CHANGELOG.md)

## [License](LICENSE)
3 changes: 3 additions & 0 deletions __tests__/css-invalid.css
@@ -0,0 +1,3 @@
madeup {
top: 0;
}
10 changes: 10 additions & 0 deletions __tests__/css-valid.css
@@ -0,0 +1,10 @@
@import url(x.css);

.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;
}
84 changes: 84 additions & 0 deletions __tests__/index.js
@@ -0,0 +1,84 @@
"use strict"

const fs = require("fs")
const config = require("../")
const stylelint = require("stylelint")

const validCss = fs.readFileSync("./__tests__/css-valid.css", "utf-8")
const invalidCss = fs.readFileSync("./__tests__/css-invalid.css", "utf-8")

describe("flags no warnings with valid css", () => {
let result

beforeEach(() => {
result = stylelint.lint({
code: validCss,
config,
})
})

it("did not error", () => {
return result.then(data => (
expect(data.errored).toBeFalsy()
))
})

it("flags no warnings", () => {
return result.then(data => (
expect(data.results[0].warnings.length).toBe(0)
))
})
})

describe("flags warnings with invalid css", () => {
let result

beforeEach(() => {
result = stylelint.lint({
code: invalidCss,
config,
})
})

it("did error", () => {
return result.then(data => (
expect(data.errored).toBeTruthy()
))
})

it("flags one warning", () => {
return result.then(data => (
expect(data.results[0].warnings.length).toBe(1)
))
})

it("correct warning text", () => {
return result.then(data => (
expect(data.results[0].warnings[0].text).toBe("Unexpected unknown type selector \"madeup\" (selector-type-no-unknown)")
))
})

it("correct rule flagged", () => {
return result.then(data => (
expect(data.results[0].warnings[0].rule).toBe("selector-type-no-unknown")
))
})

it("correct severity flagged", () => {
return result.then(data => (
expect(data.results[0].warnings[0].severity).toBe("error")
))
})

it("correct line number", () => {
return result.then(data => (
expect(data.results[0].warnings[0].line).toBe(1)
))
})

it("correct column number", () => {
return result.then(data => (
expect(data.results[0].warnings[0].column).toBe(1)
))
})
})
22 changes: 22 additions & 0 deletions appveyor.yml
@@ -0,0 +1,22 @@
# http://www.appveyor.com/docs/appveyor-yml

environment:
matrix:
- nodejs_version: 6

version: "{build}"
build: off
deploy: off
branches:
only:
- master
clone_depth: 1
skip_tags: true
install:
- ps: Install-Product node $env:nodejs_version
- npm install

test_script:
- node --version
- npm --version
- cmd: "npm test"
30 changes: 30 additions & 0 deletions index.js
@@ -0,0 +1,30 @@
"use strict"

module.exports = {
"rules": {
"at-rule-no-unknown": true,
"block-no-empty": true,
"color-no-invalid-hex": true,
"comment-no-empty": true,
"declaration-block-no-duplicate-properties": [ true, {
ignore: ["consecutive-duplicates-with-different-values"],
} ],
"declaration-block-no-redundant-longhand-properties": true,
"declaration-block-no-shorthand-property-overrides": true,
"font-family-no-duplicate-names": true,
"function-calc-no-unspaced-operator": true,
"function-linear-gradient-no-nonstandard-direction": true,
"keyframe-declaration-no-important": true,
"media-feature-name-no-unknown": true,
"no-empty-source": true,
"no-extra-semicolons": true,
"no-invalid-double-slash-comments": true,
"property-no-unknown": true,
"selector-pseudo-class-no-unknown": true,
"selector-pseudo-element-no-unknown": true,
"selector-type-no-unknown": true,
"shorthand-property-no-redundant-values": true,
"string-no-newline": true,
"unit-no-unknown": true,
},
}
58 changes: 58 additions & 0 deletions package.json
@@ -0,0 +1,58 @@
{
"name": "stylelint-config-recommended",
"version": "0.1.0",
"description": "Recommended shareable config for stylelint",
"keywords": [
"stylelint",
"stylelint-config",
"recommended"
],
"author": "stylelint",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/stylelint/stylelint-config-recommended.git"
},
"main": "index.js",
"files": [
"index.js"
],
"devDependencies": {
"eslint": "^4.1.0",
"eslint-config-stylelint": "^6.0.0",
"jest": "^20.0.0",
"npm-run-all": "^4.0.0",
"npmpub": "^3.0.1",
"remark-cli": "^3.0.0",
"remark-preset-lint-consistent": "^2.0.0",
"remark-preset-lint-recommended": "^2.0.0",
"stylelint": "^7.12.0"
},
"peerDependencies": {
"stylelint": "^7.8.0"
},
"scripts": {
"lint:js": "eslint . --ignore-path .gitignore",
"lint:md": "remark . --quiet --frail",
"lint": "npm-run-all --parallel lint:*",
"pretest": "npm run lint",
"release": "npmpub",
"test": "jest",
"watch": "jest --watch"
},
"eslintConfig": {
"extends": [
"stylelint"
]
},
"jest": {
"testEnvironment": "node",
"verbose": true
},
"remarkConfig": {
"plugins": [
"preset-lint-recommended",
"preset-lint-consistent"
]
}
}

0 comments on commit b9331a9

Please sign in to comment.