Skip to content

Commit a96dc3b

Browse files
committed
use custom parser for gts/gjs
bonus: * enables type aware lints * prettier eslint plugin (with template tag prettier plugin) will just work for gts/gjs * can detect unused block params in templates * can detect undef vars in PathExpression * can add eslint directive comments in mustache or html disadvantage: * prettier will not work without template tag prettier plugin for gts/gjs files
1 parent 1b172a6 commit a96dc3b

File tree

14 files changed

+1005
-1068
lines changed

14 files changed

+1005
-1068
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,29 @@ module.exports = {
4242
};
4343
```
4444

45+
To correctly parse gjs/gts:
46+
Do not set an override for the parser in the global config.
47+
To use e.g. the typescript parser, the following should be used
48+
49+
```js
50+
// .eslintrc.js
51+
module.exports = {
52+
plugins: ['ember'],
53+
// parser: '@typescript-eslint/parser', <-- needs to be removed, or set the gts/gjs one
54+
// so we could also have:
55+
// parser: "eslint-plugin-ember/gts-parser",
56+
extends: [
57+
'eslint:recommended',
58+
'plugin:@typescript-eslint/base', // or typescript-eslint/recommended, must come before plugin:ember/recommended
59+
'plugin:ember/recommended', // or other configuration
60+
],
61+
rules: {
62+
// override / enable optional rules
63+
'ember/no-replace-test-comments': 'error'
64+
}
65+
};
66+
```
67+
4568
## 🧰 Configurations
4669

4770
| | Name | Description |

lib/config/recommended.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const rules = require('../recommended-rules');
2-
const util = require('ember-template-imports/src/util');
32

43
module.exports = {
54
root: true,
@@ -29,11 +28,12 @@ module.exports = {
2928
* on -- and isn't relevant to user-land code.
3029
*/
3130
{
32-
files: ['**/*.gjs', '**/*.gts'],
33-
processor: 'ember/<template>',
34-
globals: {
35-
[util.TEMPLATE_TAG_PLACEHOLDER]: 'readonly',
36-
},
31+
files: ['**/*.gts'],
32+
parser: require.resolve('../parsers/gts-parser'),
33+
},
34+
{
35+
files: ['**/*.gjs'],
36+
parser: require.resolve('../parsers/gjs-parser'),
3737
},
3838
],
3939
};

lib/index.js

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

33
const requireIndex = require('requireindex');
44

5-
const gjs = require('./preprocessors/glimmer');
6-
75
module.exports = {
86
rules: requireIndex(`${__dirname}/rules`),
97
configs: requireIndex(`${__dirname}/config`),
108
utils: {
119
ember: require('./utils/ember'),
1210
},
13-
processors: {
14-
// https://eslint.org/docs/developer-guide/working-with-plugins#file-extension-named-processor
15-
'.gjs': gjs,
16-
'.gts': gjs,
17-
'<template>': gjs,
18-
},
1911
};

0 commit comments

Comments
 (0)