-
EnvironmentNode version: 21.5.0 (using 20.11.1 w/ nvm) What parser are you using?Default (Espree) What did you do?Configuration
I'm working on a login component using React and React Router. I kept getting the no-unused-vars error and I couldn't figure out why. I wasn't seeing that I was missing a closing bracket in my handleLogin function. I tried different versions of Node using nvm, writing the function in the onSubmit attribute in various ways, and a few other things. Finally, I gave up and I decided to give an AI extension a chance to identify the issue. It didn't figure out the problem, but it did duplicate my imports. Magically, that error was gone, which is obviously wrong. Duplicate imports shouldn't clear this error. I deleted the imports one at a time to see when the error would reappear. It only returned when the duplicate import { Link } from 'react-router-dom';
import { useState } from 'react';
//other imported items
const LoginForm = () => {
const handleLogin = async (e) => {
e.preventDefault();
// other code
// !! missing closing bracket for handleLogin
return(
<form onSubmit={(e) => handleLogin(e)} method='post' id='login'>
// other code
<input onClick={(e) => handleLogin(e)} type='submit' value='Sign In' className='button'/>
</form>)
);
}; What did you expect to happen?I expected more errors with duplicate imports declared on the page. What actually happened?The no-unused-vars error was cleared. Link to Minimal Reproducible Examplehttps://github.com/w3dd1e/groupomania-client Participation
Additional commentsI'm still relatively new to this so, it's entirely possible this is the desired outcome. This is my first project with React. I only realized that the closing bracket was missing from the function when I was submitting this bug, but I opted to submit the issue anyway, just in case. I figure you can close it, if there is nothing to do. And, I'm happy to provide more info, as needed. Thanks for all you do! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @w3dd1e, I'm guessing you got a // now this is valid JavaScript
import { Link } from 'react-router-dom';
import { useState } from 'react';
//other imported items
const LoginForm = () => {
const handleLogin = async (e) => {
e.preventDefault();
// other code
}
return(
<form onSubmit={(e) => handleLogin(e)} method='post' id='login'>
// other code
<input onClick={(e) => handleLogin(e)} type='submit' value='Sign In' className='button'/>
</form>
);
}; The You can fix the error on export const LoginForm = () => { } |
Beta Was this translation helpful? Give feedback.
Hi @w3dd1e, I'm guessing you got a
Parsing Error
from ESLint since you had a syntax error (missing bracket). ESLint will not lint the file unless it has valid JS code (with no syntax errors).The
no-unused-vars
rule is complaining here becauseLink
,u…