Skip to content

Commit e516bfb

Browse files
committed
Add config required to support .gjs (<template> tag)
See the comments and the linked issues for additional context. I arbitrarily decided to put the template tag at the top of the class but happy to change that to whatever seems reasonable. ember-cli/eslint-plugin-ember#1895 ember-cli/eslint-plugin-ember#1896
1 parent c5a669e commit e516bfb

File tree

3 files changed

+1070
-10
lines changed

3 files changed

+1070
-10
lines changed

index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/* eslint-env node */
44

5+
const { TEMPLATE_TAG_PLACEHOLDER } = require('ember-template-imports/src/util');
6+
57
module.exports = {
68
root: true,
79
parser: "@babel/eslint-parser",
@@ -84,6 +86,7 @@ module.exports = {
8486
2,
8587
{
8688
order: [
89+
"[template-tag]",
8790
"[static-properties]",
8891
"[static-methods]",
8992
"[injected-services]",
@@ -95,6 +98,16 @@ module.exports = {
9598
"[everything-else]",
9699
],
97100
groups: {
101+
// https://github.com/ember-cli/eslint-plugin-ember/issues/1896
102+
// This only sort of works: in addition to the issues mentioned
103+
// above, it doesn't seem to reliably enforce the order, e.g.
104+
// [injected-services] -> <template> -> [injected-services]
105+
// doesn't seem to trigger the error. That being said, it does
106+
// work sometimes and this is needed to avoid emitting errors
107+
// in the limited cases where it does work.
108+
"template-tag": [
109+
{ type: "property", name: `/${TEMPLATE_TAG_PLACEHOLDER}/` },
110+
],
98111
"injected-services": [
99112
{ groupByDecorator: "service", type: "property" },
100113
],
@@ -114,4 +127,17 @@ module.exports = {
114127
},
115128
],
116129
},
130+
131+
// https://github.com/ember-cli/eslint-plugin-ember/issues/1895
132+
// We may eventually be able to drop this by extending the base
133+
// config from eslint-plugin-ember. In the meantime, this
134+
overrides: [
135+
{
136+
files: ['**/*.gjs', '**/*.gts'],
137+
processor: 'ember/<template>',
138+
globals: {
139+
[TEMPLATE_TAG_PLACEHOLDER]: 'readonly',
140+
},
141+
},
142+
],
117143
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
"@babel/core": "^7.18.5",
88
"@babel/eslint-parser": "^7.18.2",
99
"@babel/plugin-proposal-decorators": "^7.18.2",
10+
"ember-template-imports": "^3.4.1",
1011
"ember-template-lint": "^4.10.0",
1112
"ember-template-lint-plugin-discourse": "^3.0.0",
1213
"eslint": "^8.17.0",
1314
"eslint-plugin-discourse-ember": "latest",
14-
"eslint-plugin-ember": "^10.6.1",
15+
"eslint-plugin-ember": "^11.8.0",
1516
"eslint-plugin-lodash": "^7.1.0",
1617
"eslint-plugin-node": "^11.1.0",
1718
"eslint-plugin-sort-class-members": "^1.14.1",

0 commit comments

Comments
 (0)