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

Conflict with newest eslint-typescript version 2.26 #450

Closed
EdJoPaTo opened this issue Mar 31, 2020 · 3 comments · Fixed by #452
Closed

Conflict with newest eslint-typescript version 2.26 #450

EdJoPaTo opened this issue Mar 31, 2020 · 3 comments · Fixed by #452
Labels

Comments

@EdJoPaTo
Copy link
Contributor

Just as I'm using rm -rf node_modules package-lock.json && npm install regularly xo suddenly stopped working yesterday. First thought, probably some eslint error, they will release another patch version. I just head to sleep and everything will be fine in the morning. Nothing happened till now so I went into investigating it further.

Error Message:

Error: Error while loading rule '@typescript-eslint/await-thenable': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /home/edjopato/tmp/xo-testing/index.ts
    at Object.getParserServices (/home/edjopato/tmp/xo-testing/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/getParserServices.js:15:15)
    at create (/home/edjopato/tmp/xo-testing/node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js:30:37)
    at Object.create (/home/edjopato/tmp/xo-testing/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/RuleCreator.js:12:24)
    at createRuleListeners (/home/edjopato/tmp/xo-testing/node_modules/eslint/lib/linter/linter.js:746:21)
    at /home/edjopato/tmp/xo-testing/node_modules/eslint/lib/linter/linter.js:916:31
    at Array.forEach (<anonymous>)
    at runRules (/home/edjopato/tmp/xo-testing/node_modules/eslint/lib/linter/linter.js:861:34)
    at Linter._verifyWithoutProcessors (/home/edjopato/tmp/xo-testing/node_modules/eslint/lib/linter/linter.js:1157:31)
    at Linter._verifyWithoutProcessors (/home/edjopato/tmp/xo-testing/node_modules/eslint-plugin-eslint-comments/lib/utils/patch.js:165:42)
    at Linter._verifyWithConfigArray (/home/edjopato/tmp/xo-testing/node_modules/eslint/lib/linter/linter.js:1255:21)

While trying to figure out what exactly went wrong i tried multiple versions in a clean project folder just containing package.json and an index.ts file.

{
  "name": "xo-testing",
  "devDependencies": {
    "eslint-config-xo-typescript": "^0.27.0",
    "typescript": "^3.8.3",

    "@typescript-eslint/eslint-plugin": "2.26.0",
    "@typescript-eslint/parser": "2.26.0",
    "xo": "0.27.0"
  }
}

typescript and eslint-config-xo-typescript does not seem to have any impact but are required as dependencies (for older xo versions). I installed all versions of xo from 0.27.0 until the current latest of 0.28.1 with either eslint packages of 2.26.0 or 2.25.0.
(adapt package.json then rm -rf node_modules package-lock.json && npm install && npx xo)

When using eslint packages 0.25.0 every xo version works fine.
When using eslint packages 0.26.0 only xo version 0.27.0 works fine indicating the problem arrived in xo 0.27.1. The release notes pointed me towards the PR #431 "Various fixes to TypeScript integration" which sounds like something that could indeed break something with eslint-typescript. I have not enough understanding of the xo code to understand the problem that might be introduced there. The problem might also be in some bug of the eslint packages 0.26.0 but there isnt any issue there regarding something like that (yet?).
Sadly i can not pinpoint the problem towards eslint or xo but as it changes with the earlier mentioned PR in xo I tend towards xo.

For everyone just looking for a quick workaround for now in order to work with the latest xo:

npm i -D xo@latest
npm i -D --save-exact @typescript-eslint/eslint-plugin@2.25.0 @typescript-eslint/parser@2.25.0
@danthegoodman
Copy link

@sindresorhus @pvdlg
I did some digging on this and it looks like @typescript-eslint/typescript-estree now defaults to ignoring typescript project files if it is in node_modules (which is where the cached auto-gen'd copy lives)

https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/typescript-estree/src/parser.ts#L154-L165

There is a parser option that can override this, so I think projectFolderIgnoreList: [] should get added to https://github.com/xojs/eslint-config-xo-typescript/blob/master/index.js#L4-L9

In the mean time, you can add this to your xo config as a workaround:

  parserOptions: {projectFolderIgnoreList: []},

@sindresorhus
Copy link
Member

// @pvdlg

@pvdlg
Copy link
Contributor

pvdlg commented Apr 1, 2020

Good catch @danthegoodman . Will open a PR tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants