Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maksim Koretskiy
committed
Aug 25, 2015
0 parents
commit fa9efc0
Showing
10 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"stage": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "airbnb" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.gitignore | ||
|
||
test/ | ||
.travis.yml | ||
|
||
gulpfile.js | ||
|
||
.eslintrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "postcss-reset", | ||
"version": "1.0.0", | ||
"description": "PostCSS plugin for partial styles reset", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"prepublish": "babel src --out-dir dist", | ||
"lint": "eslint .", | ||
"tape": "babel-tape-runner 'test/*.js' | tap-spec", | ||
"test": "npm run lint && npm run tape" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/maximkoretskiy/postcss-reset.git" | ||
}, | ||
"keywords": [ | ||
"postcss", | ||
"postcss-plugin", | ||
"css", | ||
"reset", | ||
"isolation" | ||
], | ||
"author": "Maksim Koretskiy", | ||
"license": "MIT", | ||
"files": [ | ||
"dist", | ||
"README.md" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/maximkoretskiy/postcss-reset/issues" | ||
}, | ||
"homepage": "https://github.com/maximkoretskiy/postcss-reset", | ||
"devDependencies": { | ||
"babel": "^5.8.21", | ||
"babel-eslint": "^4.0.10", | ||
"babel-tape-runner": "^1.2.0", | ||
"eslint": "^1.2.1", | ||
"tap-spec": "^4.1.0", | ||
"tape": "^4.2.0" | ||
}, | ||
"dependencies": { | ||
"postcss": "^5.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import postcss from 'postcss'; | ||
|
||
export default postcss.plugin('postcss-autoreset', ()=> { | ||
return (css) => { | ||
css.walkRules( (rule)=> { | ||
const firstNode = rule.nodes[0]; | ||
if (firstNode) { | ||
firstNode.cloneAfter({prop: 'all', value: 'unset'}); | ||
}else { | ||
rule.nodes.push( | ||
postcss.decl({prop: 'all', value: 'unset'}) | ||
); | ||
} | ||
}); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.selector-first { | ||
padding: 1em; | ||
} | ||
|
||
|
||
.selector-second{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.selector { | ||
padding: 1em; | ||
all: unset; | ||
} | ||
|
||
.selector-second{ | ||
all: reset; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import fs from 'fs'; | ||
import test from 'tape'; | ||
import postcss from 'postcss'; | ||
import plugin from '../src'; | ||
|
||
function f(name) { | ||
const fullName = 'test/fixtures/' + name + '.css'; | ||
return fs.readFileSync(fullName, 'utf8'); | ||
} | ||
|
||
function makeCompareFn(t) { | ||
return (input, output, opts = {}) => { | ||
const css = postcss() | ||
.use(plugin(opts)) | ||
.process(input).css; | ||
t.equal(css, output); | ||
}; | ||
} | ||
|
||
test('postcss-autoreset', (t)=> { | ||
const compare = makeCompareFn(t); | ||
|
||
compare( | ||
f('default'), | ||
f('default.expected') | ||
); | ||
t.end(); | ||
}); |