This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
forked from tomasbasham/ember-cli-scss-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (51 loc) · 1.44 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
'use strict';
const path = require('path');
const defaults = require('lodash.defaults');
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
* app, tests, templates, or addon
*
* @param {Tree} tree
* tree of files (JavaScript files for app, tests, and addon types)
*
* @return {Object}
* Tree to be merged.
*/
lintTree: function(treeType, tree) {
const includePaths = this.scssLintOptions.includePaths || ['app'];
if (includePaths.indexOf(treeType) > -1) {
const filteredTreeToBeLinted = new Funnel(tree, { exclude: ['**/*.js'] });
const lintedTree = new ScssLinter(filteredTreeToBeLinted, this.scssLintOptions);
return lintedTree;
}
}
};