Skip to content

Commit b6b1cdb

Browse files
committed
Use stylelint-config-suitcss local to the preprocessor
If the user does not pass their own options then use the suit config that is a dependency of the processor. This removes the need for consumers to install it themselves
1 parent 6ce7d1f commit b6b1cdb

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

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)