Skip to content

Commit

Permalink
fix: avoid side effects from @typescript-eslint/typescript-estree (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW authored Sep 4, 2024
1 parent f12447e commit e5e4580
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-jars-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-import-x": patch
---

Fix https://github.com/nuxt/eslint/issues/494 by avoid importing from `@typescript-eslint/typescript-estree`.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"eslint": "^8.57.0 || ^9.0.0"
},
"dependencies": {
"@typescript-eslint/typescript-estree": "^8.1.0",
"@typescript-eslint/utils": "^8.1.0",
"debug": "^4.3.4",
"doctrine": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-rename-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import path from 'node:path'

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

import { createRule, ExportMap } from '../utils'
import type { ModuleOptions } from '../utils'
Expand Down
19 changes: 15 additions & 4 deletions src/utils/parse.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'node:path'

import { withoutProjectParserOptions } from '@typescript-eslint/typescript-estree'
// import { withoutProjectParserOptions } from '@typescript-eslint/typescript-estree'
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
import debug from 'debug'

Expand All @@ -13,6 +13,19 @@ import type {

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

// https://github.com/nuxt/eslint/issues/494
function withoutProjectParserOptions(
opts: TSESLint.ParserOptions,
): Exclude<
TSESLint.ParserOptions,
'EXPERIMENTAL_useProjectService' | 'project' | 'projectService'
> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- The variables are meant to be omitted
const { EXPERIMENTAL_useProjectService, project, projectService, ...rest } =
opts
return rest
}

const log = debug('eslint-plugin-import-x:parse')

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

// require the parser relative to the main module (i.e., ESLint)
const parser =
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2428,7 +2428,7 @@
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/typescript-estree@8.1.0", "@typescript-eslint/typescript-estree@^8.1.0":
"@typescript-eslint/typescript-estree@8.1.0":
version "8.1.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.1.0.tgz#c44e5667683c0bb5caa43192e27de6a994f4e4c4"
integrity sha512-NTHhmufocEkMiAord/g++gWKb0Fr34e9AExBRdqgWdVBaKoei2dIyYKD9Q0jBnvfbEA5zaf8plUFMUH6kQ0vGg==
Expand Down

0 comments on commit e5e4580

Please sign in to comment.