solidjs-community / eslint-plugin-solid

Solid-specific linting rules for ESLint.
MIT License
206 stars 24 forks source link

`undefined` second parameter crashes `solid/no-react-deps` #111

Closed moorejs closed 6 months ago

moorejs commented 7 months ago

Describe the bug

When I use undefined as my initial value for createEffect, eslint crashes in rule solid/no-react-deps.

To Reproduce

createEffect((previousValue) => {
  // logic uses previousValue which is initially undefined
}, undefined)

Expected behavior

The plugin does not crash. The warning does not apply.

Environment (please complete the following information):

Additional context

Stack trace points to the trace function.

Rule: "solid/no-react-deps"
    at trace (.../node_modules/.pnpm/eslint-plugin-solid@0.13.0_eslint@8.53.0_typescript@5.2.2/node_modules/eslint-plugin-solid/dist/utils.js:53:21)
    at .../node_modules/.pnpm/eslint-plugin-solid@0.13.0_eslint@8.53.0_typescript@5.2.2/node_modules/eslint-plugin-solid/dist/rules/no-react-deps.js:29:88
    at Array.map (<anonymous>)
    at CallExpression (.../node_modules/.pnpm/eslint-plugin-solid@0.13.0_eslint@8.53.0_typescript@5.2.2/node_modules/eslint-plugin-solid/dist/rules/no-react-deps.js:29:57)
    at ruleErrorHandler (.../node_modules/.pnpm/eslint@8.53.0/node_modules/eslint/lib/linter/linter.js:1091:28)
    at .../node_modules/.pnpm/eslint@8.53.0/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (.../node_modules/.pnpm/eslint@8.53.0/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (.../node_modules/.pnpm/eslint@8.53.0/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (.../node_modules/.pnpm/eslint@8.53.0/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
joshwilsonvu commented 6 months ago
Screenshot 2023-12-30 at 12 32 54 PM

Apparently undefined is parsed as an identifier, not a literal (like null and others) 😭 no matter how much I work with JavaScript it still manages to surprise me sometimes!

I'll just need to add a check in trace. Thanks for the issue!