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

no-legacy-features: Error while loading rule 'regexp/no-legacy-features': Debug Failure #378

Closed
AriPerkkio opened this issue Nov 20, 2021 · 2 comments · Fixed by #379
Closed
Labels
bug Something isn't working

Comments

@AriPerkkio
Copy link

Information:

  • ESLint version: 8.2.0
  • eslint-plugin-regexp version: 1.5.0

Description

Hello, no-legacy-features rule seems to crash in certain cases. This issue was spotted by automated CI run - it is not blocking my development or anything. https://github.com/AriPerkkio/eslint-remote-tester/actions/runs/1476359476

It seems that something in this plugin is causing either whole typescript or just the parser to crash. I decided to report this issue to this project since other ESLint plugins are not crashing for the same minimal repro. For example, plugin:@typescript-eslint/recommended does not crash for this case. It's still likely that the root cause is in some dependency of this plugin.

AriPerkkio/eslint-remote-tester#307 (comment)

Minimal repro

<root>
├── package.json
├── hello.d.ts
└── world.d.ts
{
  "scripts": {
    "lint": "eslint hello.d.ts"
  },
  "devDependencies": {
    "@typescript-eslint/parser": "5.4.0",
    "eslint": "8.2.0",
    "eslint-plugin-regexp": "1.5.0",
    "typescript": "4.5.2"
  }
}
// world.d.ts
export default function world(): string;
// hello.d.ts
import world from "./world";
export as namespace world;
export = world;
$ yarn lint
yarn run v1.22.10
warning package.json: No license field
$ eslint hello.d.ts

Oops! Something went wrong! :(

ESLint: 8.2.0

Error: Error while loading rule 'regexp/no-legacy-features': Debug Failure.
Occurred while linting /workspaces/eslint-demo-repro/hello.d.ts
    at getTypeOfVariableOrParameterOrPropertyWorker (/workspaces/eslint-demo-repro/node_modules/typescript/lib/typescript.js:55033:22)
    at getTypeOfVariableOrParameterOrProperty (/workspaces/eslint-demo-repro/node_modules/typescript/lib/typescript.js:54997:28)
    at getTypeOfSymbol (/workspaces/eslint-demo-repro/node_modules/typescript/lib/typescript.js:55370:24)
    at getTypeOfAlias (/workspaces/eslint-demo-repro/node_modules/typescript/lib/typescript.js:55302:73)
    at getTypeOfSymbol (/workspaces/eslint-demo-repro/node_modules/typescript/lib/typescript.js:55382:24)
    at resolveExportByName (/workspaces/eslint-demo-repro/node_modules/typescript/lib/typescript.js:49073:64)
    at getTargetOfImportClause (/workspaces/eslint-demo-repro/node_modules/typescript/lib/typescript.js:49138:43)
    at getTargetOfAliasDeclaration (/workspaces/eslint-demo-repro/node_modules/typescript/lib/typescript.js:49422:28)
    at resolveAlias (/workspaces/eslint-demo-repro/node_modules/typescript/lib/typescript.js:49469:30)
    at getSymbol (/workspaces/eslint-demo-repro/node_modules/typescript/lib/typescript.js:48027:38)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This setup does not crash:

{
  "root": true,
  "parser": "@typescript-eslint/parser",

  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module"
  },
  "extends": ["plugin:@typescript-eslint/recommended"]
}
@RunDevelopment
Copy link
Collaborator

RunDevelopment commented Nov 20, 2021

It seems like this is a problem with the way we use TypeScript to track type information. All rules that need type info have this problem, not just regexp/no-legacy-features.

@ota-meshi Could you please handle this one? I'm not really familiar with our type tracker or TypeScript's API.

@RunDevelopment RunDevelopment added the bug Something isn't working label Nov 20, 2021
@ota-meshi
Copy link
Owner

Thank you for posting this issue.
I will check the cause and fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants