Tsdx: missing dependency `eslint-config-react-app`?

Created on 13 Jan 2020  Â·  8Comments  Â·  Source: formium/tsdx

Current Behavior

after updating in our monorepo we found that tsdx failed on:

tsdx lint src 

(node:82469) UnhandledPromiseRejectionWarning: Error: Failed to load config "react-app" to extend from.
Referenced from: BaseConfig
    at configMissingError (/XXXXX/node_modules/eslint/lib/cli-engine/config-array-factory.js:233:9)
    at ConfigArrayFactory._loadExtendedShareableConfig (//XXXXX/node_modules/eslint/lib/cli-engine/config-array-factory.js:712:23)
    at ConfigArrayFactory._loadExtends (/XXXXX/node_modules/eslint/lib/cli-engine/config-array-factory.js:617:25)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/XXXXX/node_modules/eslint/lib/cli-engine/config-array-factory.js:547:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (/XXXXX/node_modules/eslint/lib/cli-engine/config-array-factory.js:491:20)
    at _normalizeObjectConfigData.next (<anonymous>)
    at createConfigArray (/XXXXX/node_modules/eslint/lib/cli-engine/config-array-factory.js:307:25)
    at ConfigArrayFactory.create (/XXXXX/node_modules/eslint/lib/cli-engine/config-array-factory.js:362:16)
    at createBaseConfigArray (/XXXXX/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:84:48)
(node:82469) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:82469) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨  Done in 0.94s.

After digging though both tsdx and eslint to figure out what went wrong
i found that if i add eslint-config-react-app to the project it worked
npm install --save-dev eslint-config-react-app

now the project is a NONE react project and a really small helper project.
It seems to me that tsdx is missing its sub requirement for linting.

| Software | Version(s) |
| ---------------- | ---------- |
| TSDX | 0.12.1
| TypeScript | 3.4.5
| Browser | NA
| npm/Yarn | Yarn 1.21.1
| Node | 10.17.0
| Operating System | MacOS

help wanted

Most helpful comment

Hi yes, this just started failing after a recent rm -rf node_modules and npm install. Something happened.

npm install --save-dev eslint-config-react-app did not fix my problem.

All 8 comments

changed the title to reflect this. PR welcome

Hi yes, this just started failing after a recent rm -rf node_modules and npm install. Something happened.

npm install --save-dev eslint-config-react-app did not fix my problem.

@fullstackwebdev oh dear. mind investigating further please? or file a different issue and link to this one since i'm not sure you have the exact same issue

I'm configuring tsdx lint for one of my libraries for the first time right now and I didn't get the error that eslint-config-react-app didn't exist, but that eslint-plugin-react and eslint-plugin-import didn't exist.

ESLint appears to require these to be installed in your project even if a dependency (like TSDX) installs them already, which is pretty tedious for certain things.

(node:44162) UnhandledPromiseRejectionWarning: Error: Failed to load plugin 'prettier' declared in 'BaseConfig': Cannot find module 'eslint-plugin-prettier'
Require stack:
- /Users/kyleholmberg/Code/@innocuous/components/__placeholder__.js
Referenced from: BaseConfig

is this the same problem?

I think we can avoid this issue with creating a TSDX preset, as mentioned in #634

Yea that's probably the same root problem. A "shareable config" would still have the same issue -- the longstanding https://github.com/eslint/eslint/issues/3458 is the root of all this I'm pretty sure.
I think the "plugin and config" workaround mentioned there would work as a proper "preset" as it would do both, but not totally sure.
resolve-plugins-relative-to might help here as well but I think that would only work if you don't use any plugins relative to your own project root. Not sure either.

If you are using a monorepo with yarn workspace, try applying nohoist on tsdx

  "workspaces": {
    "packages": [ ...],
    "nohoist": [
      "**/tsdx",
      "**/tsdx/**"
    ]
  },

see https://classic.yarnpkg.com/blog/2018/02/15/nohoist/

Yea that's probably the same root problem. A "shareable config" would still have the same issue -- the longstanding eslint/eslint#3458 is the root of all this I'm pretty sure.
I think the "plugin and config" workaround mentioned there would work as a proper "preset" as it would do both, but not totally sure.
resolve-plugins-relative-to might help here as well but I think that would only work if you don't use any plugins relative to your own project root. Not sure either.

I think this issue is related as well:
On running yarn lint, this error is generated:
image

I guess as eslint-config-prettier is not in the root node_modules, eslint fails to find it.
Manually installing eslint-config-prettier removes the error.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vberlier picture vberlier  Â·  5Comments

liby picture liby  Â·  3Comments

MarceloAlves picture MarceloAlves  Â·  4Comments

NateRadebaugh picture NateRadebaugh  Â·  3Comments

xaviergonz picture xaviergonz  Â·  3Comments