Skip to content

Commit 025f885

Browse files
authored
Merge pull request #37 from suitcss/local-suit-config
Use stylelint-config-suitcss within preprocessor
2 parents 2a04b22 + 4dfc9b9 commit 025f885

File tree

6 files changed

+30
-21
lines changed

6 files changed

+30
-21
lines changed

.stylelintrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
### HEAD
22

3+
* Use `stylelint-config-suitcss` from within the preprocessor. No longer needs
4+
to be installed locally by the consumer.
5+
36
### 2.0.0 (April 12, 2016)
47

58
* Switch to `postcss-easy-import`

README.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,32 +102,23 @@ Where to resolve imports from. Passed to [`postcss-import`](https://github.com/p
102102
Ensure code conforms to the [SUIT code style](https://github.com/suitcss/suit/blob/master/doc/STYLE.md)
103103
by using the [stylelint-config-suitcss](https://github.com/suitcss/stylelint-config-suitcss) package.
104104

105-
Stylelint [configuration options](http://stylelint.io/?/docs/user-guide/configuration.md) can also be overridden:
105+
Stylelint [configuration
106+
options](http://stylelint.io/?/docs/user-guide/configuration.md) can also be
107+
overridden but this requires the `stylelint-config-suitcss` to be installed
108+
locally in your package.
106109

107110
```js
108111
{
109112
lint: true,
110113
stylelint: {
111-
extends: 'stylelint-config-suitcss',
114+
extends: 'stylelint-config-suitcss',
112115
rules: {
113116
indentation: [4, 'tab'],
114117
}
115118
}
116119
}
117120
```
118121

119-
The preprocessor will also pick up any rules added to a `.stylelintrc` in your
120-
project root. For example:
121-
122-
123-
```js
124-
{
125-
"extends": "stylelint-config-suitcss"
126-
}
127-
```
128-
129-
**Note**: This works the same with the CLI `-l` flag.
130-
131122
##### `minify`
132123

133124
* Type: `Boolean`

lib/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var postcss = require('postcss');
99
var cssnano = require('cssnano');
1010
var reporter = require('postcss-reporter');
1111
var stylelint = require('stylelint');
12+
var stylelintConfigSuit = require('stylelint-config-suitcss');
1213

1314
/**
1415
* Module export
@@ -128,7 +129,7 @@ function lintImportedFiles(options, css, filename) {
128129
var processor = postcss();
129130

130131
if (options.lint) {
131-
processor.use(stylelint(options.stylelint));
132+
processor.use(stylelint(options.stylelint || stylelintConfigSuit));
132133
}
133134

134135
processor

test/fixtures/stylelint.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
.Component {
2-
flex: 1;
3-
box-sizing: content-box;
2+
box-sizing: content-box;
43
}

test/test.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,24 @@ describe('suitcss', function() {
166166
).to.be.fulfilled;
167167
});
168168

169+
it('should allow the config to be overidden', function() {
170+
return expect(
171+
suitcss('@import "./stylelint.css"', {
172+
lint: true,
173+
root: 'test/fixtures',
174+
stylelint: {
175+
extends: 'stylelint-config-suitcss',
176+
rules: {
177+
indentation: 4
178+
}
179+
},
180+
'postcss-reporter': {
181+
throwError: true
182+
}
183+
})
184+
).to.be.fulfilled;
185+
});
186+
169187
it('should throw an error if stylelint fails', function() {
170188
return expect(
171189
suitcss('@import "./stylelint.css"', {
@@ -332,7 +350,7 @@ describe('cli', function() {
332350
it('should output stylelint warnings', function(done) {
333351
exec('node bin/suitcss -i test/fixtures test/fixtures/stylelint-import.css test/fixtures/cli/output.css -l', function(err, stdout) {
334352
if (err) return done(err);
335-
expect(stdout).to.contain('Expected "box-sizing" to come before "flex"');
353+
expect(stdout).to.contain('Expected indentation of 2 spaces');
336354
done();
337355
});
338356
});

0 commit comments

Comments
 (0)