Skip to content

Commit

Permalink
Add config required to support .gjs (<template> tag) (#34)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chancancode committed Jun 21, 2023
1 parent c5a669e commit 543fccb
Show file tree
Hide file tree
Showing 3 changed files with 1,070 additions and 10 deletions.
26 changes: 26 additions & 0 deletions index.js
Expand Up @@ -2,6 +2,8 @@

/* eslint-env node */

const { TEMPLATE_TAG_PLACEHOLDER } = require('ember-template-imports/src/util');

module.exports = {
root: true,
parser: "@babel/eslint-parser",
Expand Down Expand Up @@ -84,6 +86,7 @@ module.exports = {
2,
{
order: [
"[template-tag]",
"[static-properties]",
"[static-methods]",
"[injected-services]",
Expand All @@ -95,6 +98,16 @@ module.exports = {
"[everything-else]",
],
groups: {
// https://github.com/ember-cli/eslint-plugin-ember/issues/1896
// This only sort of works: in addition to the issues mentioned
// above, it doesn't seem to reliably enforce the order, e.g.
// [injected-services] -> <template> -> [injected-services]
// doesn't seem to trigger the error. That being said, it does
// work sometimes and this is needed to avoid emitting errors
// in the limited cases where it does work.
"template-tag": [
{ type: "property", name: `/${TEMPLATE_TAG_PLACEHOLDER}/` },
],
"injected-services": [
{ groupByDecorator: "service", type: "property" },
],
Expand All @@ -114,4 +127,17 @@ module.exports = {
},
],
},

// https://github.com/ember-cli/eslint-plugin-ember/issues/1895
// We may eventually be able to drop this by extending the base
// config from eslint-plugin-ember. In the meantime, this
overrides: [
{
files: ['**/*.gjs', '**/*.gts'],
processor: 'ember/<template>',
globals: {
[TEMPLATE_TAG_PLACEHOLDER]: 'readonly',
},
},
],
};
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -7,11 +7,12 @@
"@babel/core": "^7.18.5",
"@babel/eslint-parser": "^7.18.2",
"@babel/plugin-proposal-decorators": "^7.18.2",
"ember-template-imports": "^3.4.1",
"ember-template-lint": "^4.10.0",
"ember-template-lint-plugin-discourse": "^3.0.0",
"eslint": "^8.17.0",
"eslint-plugin-discourse-ember": "latest",
"eslint-plugin-ember": "^10.6.1",
"eslint-plugin-ember": "^11.8.0",
"eslint-plugin-lodash": "^7.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-sort-class-members": "^1.14.1",
Expand Down

0 comments on commit 543fccb

Please sign in to comment.