-
Notifications
You must be signed in to change notification settings - Fork 30
/
index.js
49 lines (38 loc) · 1.3 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
/* jshint node: true */
'use strict';
var JSCSFilter = require('broccoli-jscs');
var jsStringEscape = require('js-string-escape');
module.exports = {
name: 'ember-suave',
lintTree: function(type, tree) {
var project = this.project;
var ui = this.ui;
var jscsOptions = this.app.options.jscsOptions || {};
jscsOptions.configPath = jscsOptions.configPath || '.jscsrc';
if (!jscsOptions.testGenerator && project.generateTestFile) {
jscsOptions.testGenerator = function(relativePath, errors) {
var passed = !errors || errors.length === 0;
if (errors) {
errors = jsStringEscape('\n' + errors);
}
return project.generateTestFile('JSCS - ' + relativePath, [{
name: 'should pass jscs',
passed: passed,
errorMessage: relativePath + ' should pass jscs.' + errors
}]);
};
}
var jscsFilter = new JSCSFilter(tree, jscsOptions);
jscsFilter.logError = function(errorText) {
ui.writeLine(errorText);
};
return jscsFilter;
},
included: function(app) {
this._super.included.apply(this, arguments);
if (app.tests) {
app.import('vendor/ember-suave/qunit-configuration.js', { type: 'test' });
app.import('vendor/ember-suave/test-loader.js', { type: 'test' });
}
}
};