Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid side effects from @typescript-eslint/typescript-estree #146

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2421,7 +2421,7 @@
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/[email protected]", "@typescript-eslint/typescript-estree@^8.1.0":
"@typescript-eslint/[email protected]":
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
Loading