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

[turborepo] ESLint TypeError: Cannot convert undefined or null to object with eslint-plugin-turbo 1.10.4 #5355

Closed
benmarch opened this issue Jun 21, 2023 · 8 comments · Fixed by #5370
Labels
kind: bug Something isn't working needs: reproduction pkg: turbo-eslint eslint-config-turbo and eslint-plugin-turbo

Comments

@benmarch
Copy link

benmarch commented Jun 21, 2023

What version of Turborepo are you using?

1.8.3

What package manager are you using / does the bug impact?

npm

What operating system are you using?

Mac

Describe the Bug

Attempting to run ESLint with eslint-plugin-turbo@1.10.4 throws errors and exits anywhere I'm using process.env. This just started happening, and appears to be related to the latest release of the plugin because the previous version we were using (1.9.8) is working as expected.

Oops! Something went wrong! :(

ESLint: 7.32.0

TypeError: Cannot convert undefined or null to object
Occurred while linting <root>/packages/design-system/api/getTranscript.ts:3
    at Function.values (<anonymous>)
    at xe.test (<root>/node_modules/eslint-plugin-turbo/dist/index.js:84:5623)
    at a (<root>/node_modules/eslint-plugin-turbo/dist/index.js:84:6743)
    at MemberExpression (<root>/node_modules/eslint-plugin-turbo/dist/index.js:84:7630)
    at <root>/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (<root>/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (<root>/node_modules/eslint/lib/linter/node-event-generator.js:293:26)
    at NodeEventGenerator.applySelectors (<root>/node_modules/eslint/lib/linter/node-event-generator.js:322:22)
    at NodeEventGenerator.enterNode (<root>/node_modules/eslint/lib/linter/node-event-generator.js:336:14)

Expected Behavior

It should not exit

To Reproduce

Install ESLint (we're using 7.32.0, haven't tried updating yet) and eslint-plugin-turbo@1.10.4. Then configure ESLint to use the turbo plugin and run it against any file containing process.env (example: const remoteVars = (process.env.REMOTES || {}) as Record<string, () => Promise<any>>)

I'll see what happens if we bump the ESLint version in the meantime...

UPDATE (T+5 minutes)

Upgraded to ESLint 8.43.0 and I'm getting a better error now but it's still failing in the same way:

Oops! Something went wrong! :(

ESLint: 8.43.0

TypeError: Cannot convert undefined or null to object
Occurred while linting <root>/packages/design-system/api/getTranscript.ts:3
Rule: "turbo/no-undeclared-env-vars"
    at Function.values (<anonymous>)
    at xe.test (<root>/node_modules/eslint-plugin-turbo/dist/index.js:84:5623)
    at a (<root>/node_modules/eslint-plugin-turbo/dist/index.js:84:6743)
    at MemberExpression (<root>/node_modules/eslint-plugin-turbo/dist/index.js:84:7630)
    at ruleErrorHandler (<root>/node_modules/eslint/lib/linter/linter.js:1050:28)
    at <root>/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (<root>/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (<root>/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (<root>/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
npm ERR! Lifecycle script `lint` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: @learning-destination/design-system@0.0.0 
npm ERR!   at location: <root>/packages/design-system 
ERROR: command finished with error: command (<root>/packages/design-system) npm run lint exited (1)

And it's pointing to an environment variable that is declared in turbo.json.

Reproduction Repo

No response

@benmarch benmarch added area: turborepo kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage labels Jun 21, 2023
@relsunkaev
Copy link

Same, issue is not present in 1.10.3

@arlyon
Copy link
Contributor

arlyon commented Jun 22, 2023

Hi, thanks for opening an issue. I added a commit with a test to try to trigger this error, but the test passes. Are you able to put together a repro-repo?

95b5de7

@arlyon arlyon added needs: reproduction pkg: turbo-eslint eslint-config-turbo and eslint-plugin-turbo and removed needs: triage New issues get this label. Remove it after triage labels Jun 22, 2023
@benmarch
Copy link
Author

@arlyon, sure, let me see what i can do...

@benmarch
Copy link
Author

benmarch commented Jun 22, 2023

@arlyon sorry for the delay. Here is the repo I put together, and I have confirmed that it's triggering the error: https://github.com/benmarch/eslint-plugin-turbo-error-example

The offending line is in the "docs" app: https://github.com/benmarch/eslint-plugin-turbo-error-example/blob/main/apps/docs/app/page.tsx#L8

Thanks for looking into this!

@albertilagan
Copy link

having the same issue, last working version for us is eslint-config-turbo@1.10.3.

turbo@1.10.5 + eslint-config-turbo@1.10.3
turbo@1.10.5 + eslint-config-turbo@1.10.4

@mqschwanda
Copy link

mqschwanda commented Jun 23, 2023

having the same issue, last working version for us is eslint-config-turbo@1.10.3.

white_check_mark turbo@1.10.5 + eslint-config-turbo@1.10.3 x turbo@1.10.5 + eslint-config-turbo@1.10.4

I can confirm I am passing and failing under these same listed module versions when my code uses process.env

@ilyagru
Copy link

ilyagru commented Jun 23, 2023

+1 -- it has broken with eslint-config-turbo@1.10.4+ when using process.env..

@arlyon
Copy link
Contributor

arlyon commented Jun 23, 2023

I have a PR up now, just waiting on feedback. Thanks for the repo @benmarch

gsoltis pushed a commit that referenced this issue Jun 23, 2023
### Description

Closes #5355

### Testing Instructions

Look at this repo for a demonstration of the issue.
https://github.com/benmarch/eslint-plugin-turbo-error-example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working needs: reproduction pkg: turbo-eslint eslint-config-turbo and eslint-plugin-turbo
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants