Xo: Conflict with newest eslint-typescript version 2.26

Created on 31 Mar 2020  路  3Comments  路  Source: xojs/xo

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/[email protected] @typescript-eslint/[email protected]
bug

All 3 comments

@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: []},

// @pvdlg

Good catch @danthegoodman . Will open a PR tonight.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

haskellcamargo picture haskellcamargo  路  3Comments

pizzafox picture pizzafox  路  7Comments

pizzafox picture pizzafox  路  5Comments

lagden picture lagden  路  3Comments

iwata picture iwata  路  5Comments