You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-l, --lint in case some fixes needed returns an error
65
66
```
66
67
@@ -137,6 +138,8 @@ var combedLESS = comb.processString(less, 'less');
137
138
138
139
## Configuration
139
140
141
+
### Through `.csscomb.json`
142
+
140
143
`csscomb` is configured using [.csscomb.json](https://github.com/csscomb/csscomb.js/blob/master/.csscomb.json) file, located in the project root.
141
144
142
145
Example configuration:
@@ -162,6 +165,66 @@ Example configuration:
162
165
}
163
166
```
164
167
168
+
### Through `.css`-template
169
+
170
+
Instead of configuring all the options one by one, you can use a CSS-template file instead: CSSComb.js would detect the codestyle used in this file and would use it as a config. All the existent properties except for the `sort-order` could be configured this way.
171
+
172
+
To provide a template just add `"template"` with the path to the template in the `.csscomb.json`:
173
+
174
+
```json
175
+
{
176
+
"template": "example.css"
177
+
}
178
+
```
179
+
180
+
CSSComb.js would detect only those things that could be detected, so if your template don't provide examples of usage for some of the options, or if you would want to override something from it, you can write them in the `.csscomb.json` along the `"template"`:
181
+
182
+
```json
183
+
{
184
+
"template": "example.css",
185
+
"leading-zero": false,
186
+
"vendor-prefix-align": true
187
+
}
188
+
```
189
+
190
+
This config would detect all the options from the `example.css`, then it would use `"leading-zero": false` instead of what it detected, and then it would use `"vendor-prefix-align": true` even if there were no prefixed properties or values inside the `example.css`.
191
+
192
+
### Creating `.csscomb.json` from the `.css` file
193
+
194
+
If you want to configure everything manually, but based on the codestyle from existing `.css`-file, you can at first detect all the options using `--detect` CLI option, and then add/edit any options you like. So if you have such `example.css`:
195
+
196
+
```css
197
+
.foo
198
+
{
199
+
width: #fff;
200
+
}
201
+
```
202
+
203
+
then by running
204
+
205
+
```bash
206
+
csscomb -d template.css > .csscomb.json
207
+
```
208
+
209
+
you would generate this `.csscomb.json`:
210
+
211
+
```json
212
+
{
213
+
"remove-empty-rulesets": true,
214
+
"always-semicolon": true,
215
+
"color-case": "lower",
216
+
"color-shorthand": true,
217
+
"strip-spaces": true,
218
+
"eof-newline": true,
219
+
"stick-brace": "\n",
220
+
"colon-space": [
221
+
"",
222
+
" "
223
+
],
224
+
"rule-indent": " "
225
+
}
226
+
```
227
+
165
228
## Options
166
229
167
230
### exclude
@@ -178,7 +241,7 @@ Available value: `{Boolean}` `true`
0 commit comments