Skip to content

Commit e5e4580

Browse files
authored
fix: avoid side effects from @typescript-eslint/typescript-estree (import-js#146)
1 parent f12447e commit e5e4580

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

.changeset/twenty-jars-fix.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-import-x": patch
3+
---
4+
5+
Fix https://github.com/nuxt/eslint/issues/494 by avoid importing from `@typescript-eslint/typescript-estree`.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"eslint": "^8.57.0 || ^9.0.0"
4949
},
5050
"dependencies": {
51-
"@typescript-eslint/typescript-estree": "^8.1.0",
5251
"@typescript-eslint/utils": "^8.1.0",
5352
"debug": "^4.3.4",
5453
"doctrine": "^3.0.0",

src/rules/no-rename-default.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import path from 'node:path'
88

9-
import type { TSESTree } from '@typescript-eslint/typescript-estree'
9+
import type { TSESTree } from '@typescript-eslint/utils'
1010

1111
import { createRule, ExportMap } from '../utils'
1212
import type { ModuleOptions } from '../utils'

src/utils/parse.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'node:path'
22

3-
import { withoutProjectParserOptions } from '@typescript-eslint/typescript-estree'
3+
// import { withoutProjectParserOptions } from '@typescript-eslint/typescript-estree'
44
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
55
import debug from 'debug'
66

@@ -13,6 +13,19 @@ import type {
1313

1414
import { moduleRequire } from './module-require'
1515

16+
// https://github.com/nuxt/eslint/issues/494
17+
function withoutProjectParserOptions(
18+
opts: TSESLint.ParserOptions,
19+
): Exclude<
20+
TSESLint.ParserOptions,
21+
'EXPERIMENTAL_useProjectService' | 'project' | 'projectService'
22+
> {
23+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- The variables are meant to be omitted
24+
const { EXPERIMENTAL_useProjectService, project, projectService, ...rest } =
25+
opts
26+
return rest
27+
}
28+
1629
const log = debug('eslint-plugin-import-x:parse')
1730

1831
function keysFromParser(
@@ -90,9 +103,7 @@ export function parse(
90103
// "project" or "projects" in parserOptions. Removing these options means the parser will
91104
// only parse one file in isolate mode, which is much, much faster.
92105
// https://github.com/import-js/eslint-plugin-import/issues/1408#issuecomment-509298962
93-
parserOptions = withoutProjectParserOptions(
94-
parserOptions,
95-
) as TSESLint.ParserOptions
106+
parserOptions = withoutProjectParserOptions(parserOptions)
96107

97108
// require the parser relative to the main module (i.e., ESLint)
98109
const parser =

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -2428,7 +2428,7 @@
24282428
semver "^7.3.7"
24292429
tsutils "^3.21.0"
24302430

2431-
"@typescript-eslint/[email protected]", "@typescript-eslint/typescript-estree@^8.1.0":
2431+
"@typescript-eslint/[email protected]":
24322432
version "8.1.0"
24332433
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.1.0.tgz#c44e5667683c0bb5caa43192e27de6a994f4e4c4"
24342434
integrity sha512-NTHhmufocEkMiAord/g++gWKb0Fr34e9AExBRdqgWdVBaKoei2dIyYKD9Q0jBnvfbEA5zaf8plUFMUH6kQ0vGg==

0 commit comments

Comments
 (0)