Skip to content

Commit 7ce70fb

Browse files
committed
initial commit
0 parents  commit 7ce70fb

File tree

10 files changed

+211
-0
lines changed

10 files changed

+211
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
end_of_line = lf
8+
charset = utf-8
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
indent_style = space
12+
indent_size = 2

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
.DS_Store
3+
.nyc_output
4+
coverage

.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
test
2+
contributing.md
3+
.editorconfig
4+
coverage
5+
.nyc_output
6+
.travis.yml

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
sudo: false
3+
node_js:
4+
- 6
5+
after_script:
6+
- npm run coveralls

LICENSE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
License (MIT)
2+
-------------
3+
4+
Copyright (c) 2016 static-dev
5+
6+
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:
7+
8+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9+
10+
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.

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# spike-css-standards
2+
3+
[![npm](https://img.shields.io/npm/v/spike-css-standards.svg?style=flat-square)](https://npmjs.com/package/spike-css-standards)
4+
[![tests](https://img.shields.io/travis/static-dev/spike-css-standards.svg?style=flat-square)](https://travis-ci.org/static-dev/spike-css-standards?branch=master)
5+
[![dependencies](https://img.shields.io/david/static-dev/spike-css-standards.svg?style=flat-square)](https://david-dm.org/static-dev/spike-css-standards)
6+
[![coverage](https://img.shields.io/coveralls/static-dev/spike-css-standards.svg?style=flat-square)](https://coveralls.io/r/static-dev/spike-css-standards?branch=master)
7+
8+
standard plugin pack for postcss
9+
10+
> **Note:** This project is in early development, and versioning is a little different. [Read this](http://markup.im/#q4_cRZ1Q) for more details.
11+
12+
### Why should you care?
13+
14+
Write about why this project is important.
15+
16+
### Installation
17+
18+
`npm install spike-css-standards -S`
19+
20+
> **Note:** This project is compatible with node v6+ only
21+
22+
### Usage
23+
24+
How to use this project.
25+
26+
### License & Contributing
27+
28+
- Details on the license [can be found here](LICENSE.md)
29+
- Details on running tests and contributing [can be found here](contributing.md)

contributing.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Contributing to spike-css-standards
2+
3+
Hello there! First of all, thanks for being interested in spike-css-standards and helping out. We all think you are awesome, and by contributing to open source projects, you are making the world a better place. That being said, there are a few ways to make the process of contributing code to spike-css-standards smoother, detailed below:
4+
5+
### Filing Issues
6+
7+
If you are opening an issue about a bug, make sure that you include clear steps for how we can reproduce the problem. _If we can't reproduce it, we can't fix it_. If you are suggesting a feature, make sure your explanation is clear and detailed.
8+
9+
### Getting Set Up
10+
11+
- Clone the project down
12+
- Make sure [nodejs](http://nodejs.org) has been installed and is above version `6.x`
13+
- Run `npm install`
14+
- Put in work
15+
16+
### Testing
17+
18+
This project is constantly evolving, and to ensure that things are secure and working for everyone, we need to have tests. If you are adding a new feature, please make sure to add a test for it. The test suite for this project uses [ava](https://github.com/sindresorhus/ava).
19+
20+
To run the test suite just use `npm test` or install ava globally and use the `ava` command to run the tests.
21+
22+
### Code Style
23+
24+
This project uses ES6, interpreted directly by node.js. To keep a consistent coding style in the project, we are using [standard js](http://standardjs.com/). In order for tests to pass, all code must pass standard js linting. This project also uses an [editorconfig](http://editorconfig.org/). It will make life much easier if you have the [editorconfig plugin](http://editorconfig.org/#download) for your text editor. For any inline documentation in the code, we're using [JSDoc](http://usejsdoc.org/).
25+
26+
### Commit Cleanliness
27+
28+
It's ok if you start out with a bunch of experimentation and your commit log isn't totally clean, but before any pull requests are accepted, we like to have a nice clean commit log. That means [well-written and clear commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) and commits that each do something significant, rather than being typo or bug fixes.
29+
30+
If you submit a pull request that doesn't have a clean commit log, we will ask you to clean it up before we accept. This means being familiar with rebasing - if you are not, [this guide](https://help.github.com/articles/interactive-rebase) by github should help you to get started. And if you are still confused, feel free to ask!

lib/index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const sugarss = require('sugarss')
2+
let postcssImport = require('postcss-import')
3+
let cssnext = require('postcss-cssnext')
4+
let rucksack = require('rucksack-css')
5+
6+
module.exports = (options) => {
7+
// sugarss by default unless false or custom parser
8+
let parser = options.parser || sugarss
9+
if (options.parser === false) parser = undefined
10+
11+
// define addDependencyTo if the webpack object is provided
12+
if (options.webpack) {
13+
options.root = options.webpack.resourcePath
14+
options.addDependencyTo = options.webpack
15+
}
16+
17+
// standard options merge
18+
const importOpt = selectiveMerge(options, ['root', 'addDependencyTo'])
19+
const cssnextOpt = selectiveMerge(options, ['browsers', 'features', 'warnForDuplicates'])
20+
21+
// define normal plugin list
22+
const plugins = [
23+
postcssImport(importOpt),
24+
cssnext(cssnextOpt),
25+
rucksack(options.rucksack)
26+
]
27+
28+
// add cssnano if minify config present
29+
if (options.minify) plugins.push(require('cssnano')())
30+
31+
return {parser, plugins}
32+
}
33+
34+
function selectiveMerge (opts, optNames) {
35+
return optNames.reduce((m, opt) => {
36+
if (opts[opt]) { m[opt] = opts[opt] }; return m
37+
}, {})
38+
}

package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "spike-css-standards",
3+
"description": "standard plugin pack for postcss",
4+
"version": "0.0.0",
5+
"author": "static-dev",
6+
"ava": {
7+
"verbose": "true"
8+
},
9+
"bugs": "https://github.com/static-dev/spike-css-standards/issues",
10+
"devDependencies": {
11+
"ava": "^0.16.0",
12+
"coveralls": "^2.11.12",
13+
"nyc": "^8.1.0",
14+
"rewire": "^2.5.2",
15+
"snazzy": "^4.0.1",
16+
"standard": "^7.1.2"
17+
},
18+
"engines": {
19+
"node": ">= 6"
20+
},
21+
"homepage": "https://github.com/static-dev/spike-css-standards",
22+
"license": "MIT",
23+
"main": "lib",
24+
"repository": "static-dev/spike-css-standards",
25+
"scripts": {
26+
"test": "nyc ava",
27+
"lint": "standard | snazzy",
28+
"coverage": "nyc ava && nyc report --reporter=html && open ./coverage/index.html",
29+
"coveralls": "nyc report --reporter=text-lcov | coveralls"
30+
},
31+
"dependencies": {
32+
"cssnano": "^3.7.4",
33+
"postcss-cssnext": "^2.7.0",
34+
"postcss-import": "^8.1.2",
35+
"rucksack-css": "^0.8.6",
36+
"sugarss": "^0.1.5"
37+
}
38+
}

test/index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const rewire = require('rewire')
2+
const cssStandardsRewired = rewire('..')
3+
const cssStandards = require('..')
4+
const test = require('ava')
5+
6+
test('basic', (t) => {
7+
cssStandardsRewired.__set__('postcssImport', (opts) => {
8+
t.truthy(opts.root === 'test')
9+
t.truthy(opts.addDependencyTo.addDependency === 'test')
10+
})
11+
12+
cssStandardsRewired.__set__('cssnext', (opts) => {
13+
t.truthy(opts.features === 'test')
14+
t.truthy(opts.browsers === 'test')
15+
t.truthy(opts.warnForDuplicates === 'test')
16+
})
17+
18+
cssStandardsRewired.__set__('rucksack', (opts) => {
19+
t.truthy(opts === 'test')
20+
})
21+
22+
const out1 = cssStandardsRewired({
23+
parser: false,
24+
webpack: { resourcePath: 'test', addDependency: 'test' },
25+
features: 'test',
26+
browsers: 'test',
27+
warnForDuplicates: 'test',
28+
rucksack: 'test'
29+
})
30+
31+
t.truthy(out1.plugins.length === 3)
32+
t.falsy(out1.parser)
33+
34+
const out2 = cssStandards({ minify: true })
35+
36+
t.truthy(out2.parser)
37+
t.truthy(out2.plugins.length === 4)
38+
})

0 commit comments

Comments
 (0)