This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
65 lines (53 loc) · 1.46 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';
module.exports = {
name: 'ember-cli-jshint',
/**
* instructs older versions of `ember-cli-qunit` and ember-cli-mocha to
* disable their lintTree implementations
*/
isDefaultJSLinter: true,
buildConsole: function() {
var ui = this.ui;
if (!ui) {
this.console = console;
return;
}
this.console = {
log: function(data) {
ui.writeLine(data);
},
error: function(data) {
ui.writeLine(data, 'ERROR');
}
};
},
init: function() {
this._super.init && this._super.init.apply(this, arguments);
this.buildConsole();
},
included: function included(app, parentAddon) {
this._super.included.call(this, app, parentAddon);
this.jshintrc = app.options.jshintrc;
},
lintTree: function(type, tree) {
var project = this.project;
return require('broccoli-jshint')(tree, {
jshintrcPath: this.jshintrc[type],
targetExtension: 'jshint.lint-test.js',
description: 'JSHint ' + type,
console: this.console,
testGenerator: function(relativePath, passed, errors) {
if (errors) {
errors = "\\n" + this.escapeErrorString(errors);
} else {
errors = "";
}
return project.generateTestFile('JSHint | ' + relativePath, [{
name: 'should pass jshint',
passed: !!passed,
errorMessage: relativePath + ' should pass jshint.' + errors
}]);
}
});
}
};