eslint-plugin-ember-template-lint 0.15.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -57,14 +57,24 @@ require('eslint-plugin-ember-template-lint/lib/ember-teplate-lint/config').regis
57
57
 
58
58
 
59
59
  module.exports = {
60
- extends: [
61
- 'eslint:recommended',
62
- 'plugin:@typescript-eslint/base',
63
- 'plugin:ember-template-lint/config',
64
- 'plugin:ember-template-lint/recommended',
65
- //optional:
66
- 'plugin:ember-template-lint/ember-template-lint-plugin-prettier:recommended'
67
- ]
60
+ overrides: [
61
+ {
62
+ files: ['**/*.hbs'],
63
+ parser: 'ember-template-lint/lib/parser/hbs-parser',
64
+ extends: [
65
+ 'plugin:ember-template-lint/config',
66
+ 'plugin:ember-template-lint/recommended',
67
+ ],
68
+ },
69
+ {
70
+ files: ['**/*.gjs'],
71
+ parser: 'ember-eslint-parser',
72
+ extends: [
73
+ 'plugin:ember-template-lint/config',
74
+ 'plugin:ember-template-lint/recommended',
75
+ ],
76
+ },
77
+ ],
68
78
  };
69
79
  ```
70
80
 
@@ -13,7 +13,7 @@ module.exports = {
13
13
  },
14
14
  {
15
15
  files: ['**/*.gts', '**/*.gjs'],
16
- parser: require.resolve('../parser/gts-parser'),
16
+ parser: 'ember-eslint-parser',
17
17
  processor: 'ember-template-lint/noop'
18
18
  },
19
19
  ],
@@ -58,8 +58,8 @@ class Rule {
58
58
  return {
59
59
  'Program': (node) => node.isHbs && visitor.enter(node),
60
60
  'Program:exit': (node) => node.isHbs && visitor.exit(node),
61
- '__TEMPLATE__Template': visitor.enter,
62
- '__TEMPLATE__Template:exit': visitor.exit,
61
+ 'GlimmerTemplate': visitor.enter,
62
+ 'GlimmerTemplate:exit': visitor.exit,
63
63
  };
64
64
  }
65
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-ember-template-lint",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "Provide linting for ember template",
5
5
  "keywords": [
6
6
  "eslint",
@@ -19,18 +19,18 @@
19
19
  "@glimmer/syntax": "^0.84.3",
20
20
  "@typescript-eslint/parser": "^5.59.7",
21
21
  "@typescript-eslint/typescript-estree": "^5.59.7",
22
- "ember-template-imports": "^3.4.2",
23
- "ember-template-lint": "^5.7.3",
24
- "ember-template-recast": "^6.1.4",
22
+ "ember-eslint-parser": "^0.5.6",
23
+ "ember-template-recast": "^6.1.5",
24
+ "ember-template-lint": "^6.0.0",
25
25
  "prettier-linter-helpers": "^1.0.0",
26
26
  "synckit": "^0.8.5",
27
27
  "typescript": "^5.0.4"
28
28
  },
29
29
  "peerDependencies": {
30
- "ember-template-lint": "^5.7.3"
30
+ "ember-template-lint": "^6.0.0"
31
31
  },
32
32
  "devDependencies": {
33
- "ember-template-lint-plugin-prettier": "^4.1.0",
33
+ "ember-template-lint-plugin-prettier": "^5.0.0",
34
34
  "eslint": "^8.41.0",
35
35
  "eslint-plugin-jest": "^27.2.1",
36
36
  "eslint-plugin-node": "^11.1.0",
@@ -1,57 +0,0 @@
1
- const gts = require('ember-template-imports');
2
- const typescriptParser = require('@typescript-eslint/parser');
3
- const typescriptEstree = require('@typescript-eslint/typescript-estree');
4
-
5
-
6
- function replaceRange(s, start, end, substitute) {
7
- return s.substring(0, start) + substitute + s.substring(end);
8
- }
9
-
10
- module.exports = {
11
- parseForESLint(code, options) {
12
- let jsCode = code;
13
- const templateInfos = gts.parseTemplates(jsCode, options.filePath);
14
- templateInfos.forEach((tpl) => {
15
- const range = [tpl.start.index, tpl.end.index + tpl.end[0].length];
16
- tpl.range = range;
17
- const template = jsCode.slice(...range);
18
- const lines = template.split('\n');
19
- lines.forEach((line, i) => {
20
- lines[i] = ' '.repeat(line.length);
21
- });
22
- const emptyText = '[`' + lines.join('\n').slice(4) + '`]';
23
- jsCode = replaceRange(jsCode, ...range, emptyText);
24
- const ast = {
25
- type: '__TEMPLATE__Template',
26
- };
27
- ast.range = range;
28
- ast.contents = template;
29
- tpl.ast = ast;
30
- });
31
- const result = typescriptParser.parseForESLint(jsCode, options);
32
- const visitorKeys = {...result.visitorKeys, '__TEMPLATE__Template': []};
33
- result.ast.tokens.forEach((token) => {
34
- if (token.type === 'Template') {
35
- const range = [token.range[0] - 1, token.range[1] + 1];
36
- const template = templateInfos.find(t => t.range[0] >= range[0] && t.range[1] <= range[1]);
37
- if (!template) return;
38
- const ast = template.ast;
39
- ast.loc = token.loc;
40
- Object.assign(token, ast);
41
- }
42
- });
43
- typescriptEstree.simpleTraverse(result.ast, {
44
- enter(node) {
45
- if (node.type === 'TemplateLiteral') {
46
- const range = [node.range[0] - 1, node.range[1] + 1];
47
- const template = templateInfos.find(t => t.range[0] >= range[0] && t.range[1] <= range[1]);
48
- if (!template) return;
49
- const ast = template.ast;
50
- Object.assign(node, ast);
51
- }
52
- }
53
- });
54
-
55
- return { ...result, visitorKeys };
56
- }
57
- };