-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
65 lines (56 loc) · 1.63 KB
/
index.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
'use strict';
const path = require('path');
const defaults = require('lodash.defaults');
const mergeTrees = require('broccoli-merge-trees');
const Funnel = require('broccoli-funnel');
const ScssLinter = require('broccoli-scss-linter');
module.exports = {
name: require('./package').name,
/*
* Merge scss-lint configuration
* options from the consuming
* application.
*
* @method included
*
* @param {Object} app
* An EmberApp instance.
*/
included: function(app) {
this._super.included.call(this, app);
// Merge the consuming application's options with the default options.
this.scssLintOptions = defaults(app.options.scssLintOptions || {}, {
config: path.join(app.project.root, '.sass-lint.yml'),
testGenerator: 'qunit'
});
this.app = app;
},
/*
* Lint the application's styles
* tree and report errors to the
* user.
*
* @method lintTree
*
* @param {String} treeType
* Either 'app', 'tests', 'templates', or 'addon'.
*
* @return {Object}
* Tree to be merged.
*/
lintTree: function(treeType) {
if (treeType === 'app') {
let trees = [this.app.trees.app];
// Push any custom paths onto the trees array
// to be linted.
if (this.scssLintOptions.includePaths) {
trees.push.apply(trees, this.scssLintOptions.includePaths);
}
const linted = trees.map(function(tree) {
const filteredTreeToBeLinted = new Funnel(tree, { exclude: ['**/*.js'] });
return new ScssLinter(mergeTrees([filteredTreeToBeLinted]), this.scssLintOptions);
}, this);
return mergeTrees(linted);
}
}
};