This repository has been archived by the owner on Mar 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scssLint.js
65 lines (56 loc) · 1.81 KB
/
scssLint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import BaseRecipe from './baseRecipe'
import scssLint from 'gulp-scss-lint'
import scssLintStylish from 'gulp-scss-lint-stylish'
import debug from 'gulp-debug'
import gulpif from 'gulp-if'
import File from './util/file'
export const Default = {
debug: false,
presetType: 'stylesheets',
task: {
name: 'scss:lint'
},
source: {
glob: '**/*.scss'
},
options: {
customReport: scssLintStylish
}
}
const ScssLint = class extends BaseRecipe {
/**
*
* @param gulp - gulp instance
* @param preset - base preset configuration - either one from preset.js or a custom hash
* @param configs - customized overrides for this recipe
*/
constructor(gulp, preset, ...configs) {
super(gulp, preset, Default, ...configs)
if (!this.config.source.options.cwd) {
this.notifyError(`Expected to find source.options.cwd in \n${this.dump(this.config)}`)
}
// If a config is not specified, emulate the eslint config behavior by looking up.
// If there is a config at or above the source cwd, use it, otherwise leave null.
if (!this.config.options.config) {
let configFile = File.findup('.scss-lint.yml', {cwd: this.config.source.options.cwd})
if (configFile) {
this.config.options.config = configFile
}
}
}
createDescription() {
return `Lints ${this.config.source.options.cwd}/${this.config.source.glob}`
}
run(done, watching = false) {
if (this.config.options.config) {
this.log(`Using config: ${this.config.options.config}`)
}
return this.gulp.src(this.config.source.glob, this.config.source.options)
.pipe(gulpif(this.config.debug, debug(this.debugOptions())))
.pipe(scssLint(this.config.options))
.on('error', (error) => {
this.notifyError(error, done, watching)
})
}
}
export default ScssLint