Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass linter result down to stream #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/index.js
Expand Up @@ -106,6 +106,8 @@ module.exports = function gulpStylelint(options) {
file.contents = Buffer.from(lintResult.output);
}

file.stylelint = lintResult;

done(null, file);

return lintResult;
Expand Down
17 changes: 17 additions & 0 deletions test/index.spec.js
Expand Up @@ -5,6 +5,7 @@ const gulp = require('gulp');
const gulpSourcemaps = require('gulp-sourcemaps');
const path = require('path');
const test = require('tape');
const { Transform } = require('stream');

const gulpStylelint = require('../src/index');

Expand Down Expand Up @@ -53,6 +54,22 @@ test('should emit an error when linter complains', t => {
.on('error', () => t.pass('error has been emitted correctly'));
});

test('should pass linter result down to stream', t => {
t.plan(1);
gulp
.src(fixtures('basic.css'))
.pipe(gulpStylelint({config: {rules: {
'color-hex-case': 'lower'
}}}))
.pipe(new Transform({
objectMode: true,
transform: (file, enc, cb) => {
t.equal(file.stylelint.errored, false, 'has no errors');
cb(null, file);
}
}));
});

test('should ignore file', t => {
t.plan(1);
gulp
Expand Down