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

[3.0.1] Failed to load parser errors with ESLint v6 #2100

Closed
SamChou19815 opened this issue May 25, 2020 · 3 comments · Fixed by #2105
Closed

[3.0.1] Failed to load parser errors with ESLint v6 #2100

SamChou19815 opened this issue May 25, 2020 · 3 comments · Fixed by #2105
Labels
bug Something isn't working has pr there is a PR raised to close this package: utils Issues related to the @typescript-eslint/utils package

Comments

@SamChou19815
Copy link

SamChou19815 commented May 25, 2020

Repro

package.json:

{
  "dependencies": {
    "@typescript-eslint/eslint-plugin": "^3.0.1",
    "@typescript-eslint/parser": "^3.0.1",
    "eslint": "^6.8.0",
    "typescript": "^3.9.3"
  }
}
{
  "parser": "@typescript-eslint/parser",
  "plugins": ["@typescript-eslint"]
}
const f = (): number => 42;

Command: yarn eslint ok.ts

Expected Result

No error.

Actual Result

yarn eslint ok.ts
yarn run v1.22.4
warning package.json: No license field
$ /Users/sam/Downloads/ttt/node_modules/.bin/eslint ok.ts
TypeError: Failed to load parser '@typescript-eslint/parser' declared in '.eslintrc': Class extends value undefined is not a constructor or null
    at Object.<anonymous> (/Users/sam/Downloads/ttt/node_modules/@typescript-eslint/experimental-utils/dist/ts-eslint/ESLint.js:14:31)
    at Module._compile (/Users/sam/Downloads/ttt/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (/Users/sam/Downloads/ttt/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/Users/sam/Downloads/ttt/node_modules/@typescript-eslint/experimental-utils/dist/ts-eslint/index.js:15:14)
    at Module._compile (/Users/sam/Downloads/ttt/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Additional Info

If I edit the node_modules and remove the line __exportStar(require("./ESLint"), exports); (export * from './ESLint'; in ts source) in node_modules/@typescript-eslint/experimental-utils/dist/ts-eslint/index.js, the error goes away.

I think it should not be exported to the top-level without guard, since the jsdoc for the class clearly says it's only in ESLint v7, and v3 still claims to support ESLint v6.

/**
* The ESLint class is the primary class to use in Node.js applications.
* This class depends on the Node.js fs module and the file system, so you cannot use it in browsers.
*
* If you want to lint code on browsers, use the Linter class instead.
*
* @since 7.0.0
*/
class ESLint extends (ESLintESLint as typeof ESLintBase) {}

Versions

package version
@typescript-eslint/experimental-utils 3.0.1
TypeScript 3.9.3
node 12.14.1
npm 6.14.3
@SamChou19815 SamChou19815 added package: utils Issues related to the @typescript-eslint/utils package triage Waiting for maintainers to take a look labels May 25, 2020
@Towerism
Copy link

Towerism commented May 25, 2020

This will cause all new projects scaffolded with eslint --init errors unless users downgrade the plugin to 3.0.0. They will get a warning if they want to use latest typescript version though.

@djejaquino
Copy link

@Towerism downgrading to 3.0.0 worked for me, thanks.

Shouldn't it be backward compatible, since it is a patch version?

@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for maintainers to take a look labels May 25, 2020
@bradzacher bradzacher pinned this issue May 25, 2020
@bradzacher bradzacher changed the title #2083 breaks compatibility with ESLint v6 [3.0.1] Failed to load parser errors with ESLint v6 May 25, 2020
bradzacher added a commit that referenced this issue May 25, 2020
Fixes #2100

Includes an integration test against eslint v6 to ensure this doesn't happen again.
Also spent a moment cleaning up the integration tests.
@bradzacher bradzacher added the has pr there is a PR raised to close this label May 25, 2020
@bradzacher
Copy link
Member

This has been fixed in master (and is available on the canary tag on npm).
It will be released to latest in due course.

@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators May 25, 2020
@bradzacher bradzacher unpinned this issue May 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working has pr there is a PR raised to close this package: utils Issues related to the @typescript-eslint/utils package
Projects
None yet
4 participants