This repository has been archived by the owner on Nov 23, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
index.js
65 lines (50 loc) · 1.65 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';
/* eslint-env node */
module.exports = {
name: 'ember-cli-eslint',
// TODO: Disable this (or set it to return false) before committing
isDevelopingAddon: function() {
return false;
},
// instructs ember-cli-qunit and ember-cli-mocha to
// disable their lintTree implementations (which use JSHint)
isDefaultJSLinter: true,
init() {
this._super.init && this._super.init.apply(this, arguments);
var VersionChecker = require('ember-cli-version-checker');
var checker = new VersionChecker(this.project);
if (checker.for('ember-qunit', 'npm').exists() || checker.for('ember-cli-qunit', 'npm').exists()) {
this._testGenerator = 'qunit';
} else if (checker.for('ember-mocha', 'npm').exists() || checker.for('ember-cli-mocha', 'npm').exists()) {
this._testGenerator = 'mocha';
}
},
included: function (app) {
this._super.included.apply(this, arguments);
this.options = app.options.eslint || {};
},
lintTree: function(type, tree) {
var ui = this.ui;
if (type === 'templates') {
return undefined;
}
var ESLint = require('broccoli-lint-eslint');
return ESLint.create(tree, {
format: this.options.format,
testGenerator: this.options.testGenerator || this._testGenerator,
group: (this.options.group !== false) ? type : undefined,
extensions: this.options.extensions,
options: {
rulesDir: this.options.rulesDir || 'eslint-rules'
},
console: {
log: function(message) {
ui.writeLine(message);
},
error: function(message) {
ui.writeLine(message, 'ERROR');
}
}
});
}
};