Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Repro
I get many alerts from eslint because I have supposedly unused variables. For Example in this File.
importReact,{ReactElement}from'react'importTodofrom'../../interfaces/todo.interface'importTodoListItemfrom'../TodoListItem'importstylefrom'./todo-list.scss'interfaceListProps{todos:Todo[]addTodo:FunctionsaveTodo:FunctionremoveTodo:FunctionisLoading:boolean}constTodoList=({ todos, addTodo, saveTodo, removeTodo, isLoading,}:ListProps):ReactElement<{}>=>{constcreateNewId=():number=>{if(!todos.length){return0}constids=todos.map(todo=>todo.id)consthighestId=Math.max(...ids)returnhighestId+1}constaddNewTodo=():void=>{constid=createNewId()addTodo(id)}consttodoElements=todos.map(todo=>(<likey={todo.id}className={style['list-element']}><TodoListItemtodo={todo}saveTodo={saveTodo}removeTodo={removeTodo}isLoading={isLoading}/></li>))return(<divclassName="container"><h1>TodoList</h1><ulclassName={style.list}>{todoElements}</ul><buttontype="button"className={style['add-todo-btn']}title="Add Todo"onClick={addNewTodo}disabled={isLoading}>+</button></div>)}exportdefaultTodoList
Expected Result
no eslint warnings, scince all variables are used at some point.
Actual Result
4:8 warning 'style' is defined but never used @typescript-eslint/no-unused-vars
17:5 warning 'saveTodo' is defined but never used @typescript-eslint/no-unused-vars
18:5 warning 'removeTodo' is defined but never used @typescript-eslint/no-unused-vars
19:5 warning 'isLoading' is defined but never used @typescript-eslint/no-unused-vars
30:11 warning 'addNewTodo' is assigned a value but never used @typescript-eslint/no-unused-vars
35:36 warning 'todo' is defined but never used @typescript-eslint/no-unused-vars
Additional Info
I just migrated fromhttps://www.npmjs.com/package/eslint-plugin-typescript. While using that package, there was no warnings.
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin | 1.1.1 |
@typescript-eslint/parser | 1.1.1 |
TypeScript | 3.2.4 |
ESLint | 5.12.1 |
node | 10.14.1 |
npm | 6.5.0 |