SolidJSS
SolidJSโ€ข3y agoโ€ข
5 replies
aryzing

ESLint error: ref is never reassigned, use const

With a farily simple practice app set up with TS + ESLint, there seems to be an issue when using refs in Solid. ESLint is reporting a lonely let myForm: HTMLFormElement as unused, despite it being passed to a ref prop later on in the code,

function MyComponent() {
  let myForm: HTMLFormElement = undefined;
  // ...
  return <form ref={myForm}>{*/ ... */}</form>


The error reported by ESLint is

'myForm' is never reassigned. Use 'const' instead. eslint(prefer-const)


Is the above code following the expected patterns / best practices? The ESLint config is using Solid's plugin,

env:
  browser: true
  es2021: true
  node: true
extends:
  - eslint:recommended
  - plugin:@typescript-eslint/recommended
  - plugin:solid/typescript
  - prettier
parser: "@typescript-eslint/parser"
parserOptions:
  ecmaVersion: latest
  sourceType: module
plugins:
  - "@typescript-eslint"
  - solid
Was this page helpful?