Skip to content

Commit 78ec876

Browse files
Fix eslint for imports with .gts extension, Cleanup parserOptions for typescript-eslint canary (#144)
* Cleanup parserOptions for typescript-eslint canary * Pin more * ope * ope * ope * ope * ope * ope * ope * Bring in work from https://github.com/ember-tooling/ember-eslint-parser/pull/142/files
1 parent 74b7345 commit 78ec876

5 files changed

Lines changed: 25 additions & 7 deletions

File tree

src/parser/gjs-gts-parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ module.exports = {
159159

160160
let result = null;
161161
const filePath = options.filePath;
162-
if (options.project) {
162+
if (options.project || options.projectService) {
163163
jsCode = replaceExtensions(jsCode);
164164
}
165165

test-projects/configs/flat-ts/eslint.config.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ import n from 'eslint-plugin-n';
2121
import globals from 'globals';
2222
import ts from 'typescript-eslint';
2323

24+
25+
import { createRequire } from 'node:module';
26+
const require = createRequire(import.meta.url);
27+
const manifestPath = require.resolve('@typescript-eslint/parser/package.json');
28+
const manifest = require(manifestPath);
29+
const isV8 = parseInt(manifest.version[0]) >= 8;
30+
2431
const parserOptions = {
2532
esm: {
2633
js: {
@@ -29,7 +36,7 @@ const parserOptions = {
2936
},
3037
ts: {
3138
projectService: true,
32-
project: true,
39+
...(isV8 ? {} : { project: true }),
3340
tsconfigRootDir: import.meta.dirname,
3441
},
3542
},

test-projects/configs/flat-ts/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"extends": "@tsconfig/ember/tsconfig.json",
3-
"include": ["src/**/*", "unpublished-development-types/**/*"],
43
"compilerOptions": {
54
"allowJs": true,
65
"declarationDir": "declarations",

test-projects/gjs-types/.eslintrc.cjs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@
33
const path = require('path');
44

55
const parserOptions = {};
6-
if (process.env.PROJECT_SERVICE) {
6+
// if (process.env.PROJECT_SERVICE) {
77
parserOptions.projectService = {
8-
defaultProject: process.env.DEFAULT_PROJECT || 'tsconfig.json',
8+
defaultProject: process.env.DEFAULT_PROJECT || process.env.PROJECT || 'tsconfig.json',
99
allowDefaultProject: process.env.ALLOW_DEFAULT_PROJECT === 'true' ? ['**/*.js'] : []
1010
};
11-
}
11+
// }
1212

1313
parserOptions.tsconfigRootDir = process.env.TSCONFIG_ROOT_DIR || __dirname;
1414
parserOptions.project = process.env.PROJECT === undefined ? true : process.env.PROJECT;
1515

16+
const manifestPath = require.resolve('@typescript-eslint/parser/package.json');
17+
const manifest = require(manifestPath);
18+
const isV8 = parseInt(manifest.version[0]) >= 8;
19+
20+
if (isV8) {
21+
delete parserOptions.project;
22+
}
23+
1624
module.exports = {
1725
root: true,
1826
parserOptions,

test-projects/gts/.eslintrc.cjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
'use strict';
22

3+
const manifestPath = require.resolve('@typescript-eslint/parser/package.json');
4+
const manifest = require(manifestPath);
5+
const isV8 = parseInt(manifest.version[0]) >= 8;
6+
37
module.exports = {
48
root: true,
59
parserOptions: {
6-
project: true,
10+
...(isV8 ? {} : { project: true }),
711
projectService: true,
812
tsconfigRootDir: __dirname
913
},

0 commit comments

Comments
 (0)