Skip to content

Commit 729d424

Browse files
authored
Merge pull request #47 from dcyriller/cleanup-deprecation
templateEnvironmentData: Cleanup deprecation
2 parents d43f726 + 763c574 commit 729d424

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

rules/lint-prettier.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ function isFile(loc) {
1818
}
1919

2020
module.exports = class Prettier extends Rule {
21+
constructor(options) {
22+
super(options);
23+
this.filePath = options.moduleName + ".hbs";
24+
}
25+
2126
visitor() {
2227
return {
2328
Program: {
@@ -33,7 +38,15 @@ module.exports = class Prettier extends Rule {
3338
}
3439

3540
const source = this.sourceForNode(node);
36-
const filepath = this.templateEnvironmentData.moduleName + ".hbs";
41+
// Following
42+
// https://github.com/ember-template-lint/ember-template-lint/commit/a7bf55cf36ee90d0460e7cb94e7ca4731aaa4be7
43+
// `templateEnvironmentData` is deprecated (in v1.8.0).
44+
// This code aims at remaining compatible with
45+
// ember-template-lint@>=1.3.0. The ternary might be removed when
46+
// upgrading the peerDependency to ember-template-lint@2.
47+
let filepath = this.filePath
48+
? this.filePath
49+
: this.templateEnvironmentData.moduleName + ".hbs";
3750

3851
if (!prettier) {
3952
// Prettier is expensive to load, so only load it if needed.

0 commit comments

Comments
 (0)