Skip to content

Commit

Permalink
Add Stylelint to gulp and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson committed Jan 5, 2017
1 parent 29e3de7 commit 7f16b25
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 14 deletions.
43 changes: 43 additions & 0 deletions .stylelintrc
@@ -0,0 +1,43 @@
{
"rules": {
"color-no-invalid-hex": true,
"font-family-no-duplicate-names": true,
"font-family-name-quotes": "always-where-recommended",
"function-name-case": "lower",
"function-url-no-scheme-relative": true,
"function-url-quotes": ["always", { "severity": "warning" }],
"number-no-trailing-zeros": true,
"length-zero-no-unit": [true, { "severity": "warning" }],
"unit-case": "lower",
"unit-no-unknown": true,
"property-case": "lower",
"property-no-unknown": true,
"keyframe-declaration-no-important": true,
"declaration-no-important": true,
"declaration-block-no-duplicate-properties": [true, { "severity": "warning" }],
"declaration-block-no-ignored-properties": true,
"declaration-block-no-shorthand-property-overrides": true,
"declaration-block-single-line-max-declarations": [1, { "severity": "warning" }],
"declaration-block-trailing-semicolon": ["always", { "severity": "warning" }],
"block-no-empty": true,
"selector-no-empty": true,
"selector-pseudo-class-no-unknown": true,
"selector-pseudo-element-no-unknown": true,
"selector-pseudo-element-case": "lower",
"selector-type-case": "lower",
"selector-type-no-unknown": true,
"selector-max-empty-lines": 0,
"media-feature-name-case": "lower",
"media-feature-name-no-unknown": true,
"media-feature-no-missing-punctuation": true,
"stylelint-disable-reason": "always-after",
"comment-no-empty": true,
"max-nesting-depth": [5, { "severity": "warning" }],
"no-duplicate-selectors": [true, { "severity": "warning" }],
"no-invalid-double-slash-comments": true,
"no-unknown-animations": true,
"no-extra-semicolons": true,
"no-missing-end-of-source-newline": [true, { "severity": "warning" }],
"no-eol-whitespace": [true, { "severity": "warning" }]
}
}
1 change: 1 addition & 0 deletions circle.yml
Expand Up @@ -33,6 +33,7 @@ test:
pre:
- mkdir -p "$CIRCLE_TEST_REPORTS/django"
override:
- gulp css:lint
- gulp js:lint
- gulp js:test
- make test-image
22 changes: 19 additions & 3 deletions gulpfile.js
Expand Up @@ -9,14 +9,20 @@ const del = require('del');
const karma = require('karma');
const eslint = require('gulp-eslint');
const watch = require('gulp-watch');
const gulpStylelint = require('gulp-stylelint');

const lintPaths = [
const lintPathsJS = [
'media/js/**/*.js',
'!media/js/libs/*.js',
'tests/unit/spec/**/*.js',
'gulpfile.js'
];

const lintPathsCSS = [
'media/css/**/*.scss',
'media/css/**/*.less'
];

gulp.task('media:watch', () => {
return gulp.src('./media/**/*')
.pipe(watch('./media/**/*', {
Expand All @@ -33,17 +39,27 @@ gulp.task('js:test', done => {
});

gulp.task('js:lint', () => {
return gulp.src(lintPaths)
return gulp.src(lintPathsJS)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});


gulp.task('css:lint', function lintCssTask() {
return gulp.src(lintPathsCSS)
.pipe(gulpStylelint({
reporters: [
{formatter: 'string', console: true}
]
}));
});

gulp.task('static:clean', () => {
return del(['static/**', '!static', '!static/.gitignore']);
});

gulp.task('default', () => {
gulp.start('media:watch');
gulp.watch(lintPaths, ['js:lint']);
gulp.watch(lintPathsJS, ['js:lint']);
});

0 comments on commit 7f16b25

Please sign in to comment.