ember-eslint-parser 0.13.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "ember-eslint-parser",
3
- "version": "0.13.0",
3
+ "version": "0.14.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git@github.com:ember-tooling/ember-eslint-parser.git"
8
+ "url": "git+https://github.com/ember-tooling/ember-eslint-parser.git"
9
9
  },
10
10
  "license": "ISC",
11
11
  "author": "",
@@ -55,7 +55,7 @@
55
55
  "vitest": "^1.2.2"
56
56
  },
57
57
  "peerDependencies": {
58
- "@babel/eslint-parser": "^7.28.6",
58
+ "@babel/eslint-parser": "^7.28.6 || ^8.0.0",
59
59
  "@typescript-eslint/parser": "*"
60
60
  },
61
61
  "peerDependenciesMeta": {
@@ -12,15 +12,20 @@ const require = createRequire(import.meta.url);
12
12
  // peer (TS-only setups don't need it), so a missing dep yields null and the JS
13
13
  // path below emits a targeted error.
14
14
  //
15
- // The experimental-worker entry point runs babel in a worker and matches the
16
- // parser ember-cli wires up for plain `.js` files in JS-only apps, so config
17
- // discovery (decorators & friends) lines up with how the rest of the project
18
- // is being parsed.
15
+ // Matches the parser ember-cli wires up for plain `.js` files in JS-only
16
+ // apps, so config discovery (decorators & friends) lines up with how the
17
+ // rest of the project is being parsed.
19
18
  let babelParser = null;
20
19
  try {
20
+ // @babel/eslint-parser < 8
21
21
  babelParser = require('@babel/eslint-parser/experimental-worker');
22
22
  } catch {
23
- // optional peer; left null
23
+ try {
24
+ // @babel/eslint-parser >= 8
25
+ babelParser = require('@babel/eslint-parser');
26
+ } catch {
27
+ // optional peer; left null
28
+ }
24
29
  }
25
30
 
26
31
  /**
@@ -278,6 +278,11 @@ export const replaceRange = function replaceRange(s, start, end, substitute) {
278
278
  return s.slice(0, start) + substitute + s.slice(end);
279
279
  };
280
280
 
281
+ function maskTemplateContentForLint(content) {
282
+ // Preserve line endings and UTF-16 length, but remove template syntax from the JS placeholder.
283
+ return content.replace(/[^\r\n]/g, ' ');
284
+ }
285
+
281
286
  const processor = new Preprocessor();
282
287
 
283
288
  class EmberParserError extends Error {
@@ -332,7 +337,7 @@ export function transformForLint(code, fileName) {
332
337
  // Build placeholder JS inline (same format as ember-estree's toPlaceholderJS)
333
338
  let jsCode = code;
334
339
  for (const tplInfo of [...result].reverse()) {
335
- const content = tplInfo.contents.replace(/`/g, '\\`').replace(/\$/g, '\\$');
340
+ const content = maskTemplateContentForLint(tplInfo.contents);
336
341
  const start = tplInfo.range.startUtf16Codepoint;
337
342
  const end = tplInfo.range.endUtf16Codepoint;
338
343
  const tplLength = end - start;