This repository has been archived by the owner on Aug 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
/
index.js
89 lines (73 loc) · 2.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
/* eslint-env node */
const VersionChecker = require('ember-cli-version-checker');
const TemplateLinter = require('./broccoli-template-linter');
const PrintFailing = require('./lib/commands/print-failing');
module.exports = {
name: require('./package').name,
included: function (app) {
this._super.included.apply(this, arguments);
this._options = app.options['ember-cli-template-lint'] || {};
if (!('testGenerator' in this._options)) {
let VersionChecker = require('ember-cli-version-checker');
let checker = new VersionChecker(this.project);
if (checker.for('ember-cli-qunit', 'npm').exists() || checker.for('ember-qunit', 'npm').exists()) {
this._options.testGenerator = 'qunit';
} else if (checker.for('ember-cli-mocha', 'npm').exists() || checker.for('ember-mocha', 'npm').exists()) {
this._options.testGenerator = 'mocha';
} else {
this.ui.writeWarnLine(
'[ember-cli-template-lint] Test framework detection was unsuccessful. ' +
'Please provide a "testGenerator" option explicitly to enable the test generators.'
);
}
}
},
includedCommands() {
return {
'template-lint:print-failing': PrintFailing
};
},
lintTree(type, tree) {
let checker = new VersionChecker(this);
checker.for('ember-cli', 'npm').assertAbove('2.4.1');
if (type === 'templates') {
let ui = this.ui;
let mockConsole = {
log(data) {
ui.writeLine(data);
},
error(data) {
ui.writeLine(data, 'ERROR');
}
};
return TemplateLinter.create(tree, {
annotation: 'TemplateLinter',
templatercPath: this.project.root + '/.template-lintrc',
testGenerator: this._options.testGenerator,
groupName: (this._options.group !== false) ? type : undefined,
console: mockConsole,
project: this.project
});
}
},
setupPreprocessorRegistry(type, registry) {
const plugin = this._buildPlugin();
plugin.parallelBabel = {
requireFile: __filename,
buildUsing: '_buildPlugin',
params: {}
};
registry.add('htmlbars-ast-plugin', plugin);
},
_buildPlugin() {
let RemoveConfigurationHtmlComments = require('./lib/plugins/remove-configuration-html-comments');
return {
name: 'remove-configuration-html-comments',
plugin: RemoveConfigurationHtmlComments(),
baseDir() {
return __dirname;
}
};
}
};