Skip to content

Commit b171a00

Browse files
committed
First Commit, First Release, v1.0.0
0 parents  commit b171a00

11 files changed

Lines changed: 706 additions & 0 deletions

File tree

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.{json,yml}]
12+
indent_size = 2

.eslintrc

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
{
2+
"rules": {
3+
"space-before-function-paren": [2, { "named": "never" }],
4+
"no-shadow-restricted-names": [2],
5+
"computed-property-spacing": [2],
6+
"no-empty-character-class": [2],
7+
"no-irregular-whitespace": [2],
8+
"no-unexpected-multiline": [2],
9+
"no-multiple-empty-lines": [2],
10+
"space-return-throw-case": [2],
11+
"no-constant-condition": [2],
12+
"no-extra-boolean-cast": [2],
13+
"no-inner-declarations": [2],
14+
"no-this-before-super": [2],
15+
"no-use-before-define": [2],
16+
"no-array-constructor": [2],
17+
"object-curly-spacing": [2, "always"],
18+
"no-floating-decimal": [2],
19+
"no-warning-comments": [2],
20+
"handle-callback-err": [2],
21+
"no-unneeded-ternary": [2],
22+
"operator-assignment": [2],
23+
"space-before-blocks": [2],
24+
"no-native-reassign": [2],
25+
"no-trailing-spaces": [2],
26+
"operator-linebreak": [2, "after"],
27+
"consistent-return": [2],
28+
"no-duplicate-case": [2],
29+
"no-invalid-regexp": [2],
30+
"no-negated-in-lhs": [2],
31+
"constructor-super": [2],
32+
"no-nested-ternary": [2],
33+
"no-extend-native": [2],
34+
"block-scoped-var": [2],
35+
"no-control-regex": [2],
36+
"no-sparse-arrays": [2],
37+
"no-throw-literal": [2],
38+
"no-return-assign": [2],
39+
"no-const-assign": [2],
40+
"no-class-assign": [2],
41+
"no-extra-parens": [2],
42+
"no-regex-spaces": [2],
43+
"no-implied-eval": [2],
44+
"no-useless-call": [2],
45+
"no-self-compare": [2],
46+
"no-octal-escape": [2],
47+
"no-new-wrappers": [2],
48+
"no-process-exit": [2],
49+
"no-catch-shadow": [2],
50+
"linebreak-style": [2],
51+
"space-infix-ops": [2],
52+
"space-unary-ops": [2],
53+
"no-cond-assign": [2],
54+
"no-func-assign": [2],
55+
"no-unreachable": [2],
56+
"accessor-pairs": [2],
57+
"no-empty-label": [2],
58+
"no-fallthrough": [2],
59+
"no-path-concat": [2],
60+
"no-new-require": [2],
61+
"no-spaced-func": [2],
62+
"no-unused-vars": [2],
63+
"spaced-comment": [2],
64+
"no-delete-var": [2],
65+
"comma-spacing": [2],
66+
"no-extra-semi": [2],
67+
"no-extra-bind": [2],
68+
"arrow-spacing": [2],
69+
"prefer-spread": [2],
70+
"no-new-object": [2],
71+
"no-multi-str": [2],
72+
"semi-spacing": [2],
73+
"no-lonely-if": [2],
74+
"dot-notation": [2],
75+
"dot-location": [2, "property"],
76+
"comma-dangle": [2, "never"],
77+
"no-dupe-args": [2],
78+
"no-dupe-keys": [2],
79+
"no-ex-assign": [2],
80+
"no-obj-calls": [2],
81+
"valid-typeof": [2],
82+
"default-case": [2],
83+
"no-redeclare": [2],
84+
"no-div-regex": [2],
85+
"no-sequences": [2],
86+
"no-label-var": [2],
87+
"comma-style": [2],
88+
"brace-style": [2],
89+
"no-debugger": [2],
90+
"quote-props": [2, "consistent-as-needed"],
91+
"no-iterator": [2],
92+
"no-new-func": [2],
93+
"key-spacing": [2, { "align": "value" }],
94+
"complexity": [2],
95+
"new-parens": [2],
96+
"no-eq-null": [2],
97+
"no-bitwise": [2],
98+
"wrap-iife": [2],
99+
"no-caller": [2],
100+
"use-isnan": [2],
101+
"no-labels": [2],
102+
"no-shadow": [2],
103+
"camelcase": [2],
104+
"eol-last": [2],
105+
"no-octal": [2],
106+
"no-empty": [2],
107+
"no-alert": [2],
108+
"no-proto": [2],
109+
"no-undef": [2],
110+
"no-eval": [2],
111+
"no-with": [2],
112+
"no-void": [2],
113+
"max-len": [2, 80],
114+
"new-cap": [2],
115+
"eqeqeq": [2],
116+
"no-new": [2],
117+
"quotes": [2, "single"],
118+
"indent": [2, 4],
119+
"strict": [0],
120+
"semi": [2, "always"],
121+
"yoda": [2, "never"]
122+
},
123+
"ecmaFeatures": {
124+
"modules": true
125+
},
126+
"env": {
127+
"node": true,
128+
"es6": true
129+
}
130+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
npm-debug.log

.npmignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.gitignore
2+
3+
node_modules/
4+
npm-debug.log
5+
6+
test/
7+
test.js
8+
9+
.travis.yml

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- stable
5+
- "4.1"
6+
- "4.0"

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Change Log
2+
All notable changes to this project will be documented in this file.
3+
4+
## [Unreleased]
5+
6+
## 1.0.0 - 2015-12-14
7+
### Added
8+
- First Release
9+
- Tests
10+
- Readme Examples
11+
12+
[Unreleased]: https://github.com/Crimx/postcss-safe-important/compare/v1.0.0...HEAD

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright 2015 StrayBugs <straybugs@gmail.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
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, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# PostCSS Safe Important [![Build Status][ci-img]][ci] ![Node Version][node-img] [![Npm][npm-img]][npm]
2+
3+
[PostCSS] plugin that adds !important to style declarations safely.
4+
5+
[PostCSS]: https://github.com/postcss/postcss
6+
[ci-img]: https://travis-ci.org/Crimx/postcss-safe-important.svg
7+
[ci]: https://travis-ci.org/Crimx/postcss-safe-important
8+
[npm-img]: https://img.shields.io/npm/v/postcss-safe-important.svg
9+
[npm]: https://www.npmjs.com/package/postcss-safe-important
10+
[node-img]: https://img.shields.io/badge/node-%5E4.0.0-green.svg
11+
12+
## Why would I need it?
13+
14+
Whether you use extreme CSS reset stylesheet like [Cleanslate](http://cleanslatecss.com/) to distribut content (e.g. a widget, or syndicated news) to third-party websites, or simply just want to give maximum weight for all your declarations, don't do it manually! Use [postcss-safe-important] to keep your source styles clean and portable.
15+
16+
## Safe?
17+
18+
Adding `!important` to every declarations might break your style. For example, [declarations in a keyframe that are qualified with `!important` are ignored](https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#!important_in_a_keyframe).
19+
20+
[postcss-safe-important] will skip unnecessary declarations. You can also set your own exclusions through options or comments (see examples below).
21+
22+
[postcss-safe-important]: https://github.com/Crimx/postcss-safe-important
23+
24+
25+
```css
26+
/* Input example */
27+
.foo {
28+
width: 100px;
29+
color: #000; /* no !important */ }
30+
31+
.bar {
32+
/* no important */
33+
color: ##fff;
34+
width: 100px; }
35+
```
36+
37+
```css
38+
/* Output example */
39+
.foo {
40+
width: 100px; !important
41+
color: #000; }
42+
43+
.bar {
44+
color: ##fff;
45+
width: 100px; }
46+
```
47+
48+
## Usage
49+
50+
```
51+
$ npm install postcss-safe-important --save-dev
52+
```
53+
54+
```js
55+
var safeImportant = require('postcss-safe-important');
56+
57+
postcss([ safeImportant({
58+
// options
59+
selectors: '#bar', // you can pass a string
60+
decls: ['height', 'width'], // or an array(or anything with `forEach`)
61+
atrules: () => 'media', // even a function
62+
keepcomments: false // will erase all the `no important` comments
63+
}) ]);
64+
```
65+
66+
## Comments
67+
68+
You can use either `/* no !important */` or `/* no important */` to indicate no changing.
69+
70+
If the comment is right inside a rule(be the first child node of the rule), the whole rule will not change.
71+
72+
```css
73+
/* Input example */
74+
.foo {
75+
/* no important */
76+
width: 100px;
77+
color: #000; }
78+
79+
.bar { /* no !important */
80+
width: 100px;
81+
color: #000; }
82+
```
83+
84+
```css
85+
/* Output example */
86+
.foo {
87+
width: 100px;
88+
color: #000; }
89+
90+
.bar {
91+
width: 100px;
92+
color: #000; }
93+
```
94+
95+
If the comment is right behind(or below) a declaration, then only the declaration will remain the same.
96+
97+
```css
98+
/* Input example */
99+
.foo {
100+
width: 100px;
101+
color: #000; /* no important */}
102+
```
103+
104+
```css
105+
/* Output example */
106+
.foo {
107+
width: 100px !important;
108+
color: #000; }
109+
```
110+
111+
## Options
112+
113+
### exclutions
114+
115+
- `selectors`: excluded selectors
116+
- `decls`: excluded declarations
117+
- `atrules`: excluded atrules(e.g. `@font-face`)
118+
119+
You can pass either a **string**, an **array**(or anything with `forEach`), or a **function** which returns string/array.
120+
121+
### keep `/* no important */` comments
122+
123+
- `keepcomments`: **bool**, default `false`.
124+
125+
See [PostCSS] docs for examples for your environment.
126+
127+
## [Change Log](CHANGELOG.md)
128+
129+
## [License](LICENSE)
130+
131+
MIT

0 commit comments

Comments
 (0)