This repository was archived by the owner on Jan 19, 2019. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 61
This repository was archived by the owner on Jan 19, 2019. It is now read-only.
[no-unused-vars] with React #112
Copy link
Copy link
Closed
Labels
bug/incomplete ruleunable to reproducebugs that are unable to reproduce in masterbugs that are unable to reproduce in master
Description
Hello,
I have several false positive no-unused-vars. I saw several issues related to no-unised-var but I am not sure that it is related.
Did I missed something in my configuration ?
Best regards
package.json
... "typescript": "^2.7.2", "typescript-eslint-parser": "^14.0.0", "eslint": "^4.18.2", ...
Dashboard.tsx
import * as React from 'react' import { connect } from 'react-redux' import { Route } from 'react-router' import { push, RouterAction } from 'react-router-redux' import { Dispatch } from 'redux' import { RootState } from './../reducers' import Navbar from './Navbar' import LeftMenu from './LeftMenu' import Recipes from './Recipes' import Home from './Home' import NewRecipe from './NewRecipe' import Api, { User } from './../api' import { storeUser } from '../actions' interface Props { user: User | undefined, api: Api, storeUser: (user: User) => void, redirect: () => {} } class Dasboard extends React.Component<Props> { componentWillMount() { const token = localStorage.getItem('accessToken') if (token != null) { this.props.api.setToken(token) this.props.api.getUser('me').then(user => { this.props.storeUser(user) }) } else { this.props.redirect() } } render() { if (this.props.user == null) return (<div></div>) return ( <div className="main-container"> <Navbar /> <div className="wrapper"> <LeftMenu /> <div className="content-wrapper"> <Route exact path="/dashboard" component={Home} /> <Route exact path="/dashboard/recipes" component={Recipes} /> <Route exact path="/dashboard/recipes/add" component={NewRecipe} /> </div> </div> </div> ) } } export default connect( (state: RootState) => ({ user: state.app.user, api: state.app.api }), (dispatch: Dispatch<any>) => ({ storeUser: (user: User) => { dispatch(storeUser(user)) }, redirect: () => { dispatch(push('/dashboard/login')) } }) )(Dasboard)
.eslintrc.json
{ "env": { "browser": true, "commonjs": true, "es6": true }, "parser": "typescript-eslint-parser", "extends": "eslint:recommended", "parserOptions": { "ecmaFeatures": { "experimentalObjectRestSpread": true, "jsx": true }, "sourceType": "module" }, "plugins": [ "react" ], "overrides": { "files": [ "**/*.ts", "**/*.tsx" ], "parser": "typescript-eslint-parser", "rules": { "no-undef": "off" } }, "rules": { "no-undef": "warn", "no-unused-vars": "warn", "react/jsx-uses-react": "error", "react/jsx-uses-vars": "error", "linebreak-style": [ "error", "unix" ], "quotes": [ "error", "single" ], "semi": [ "error", "never" ] } }
Linter result
4:16 warning 'RouterAction' is defined but never used no-unused-vars 5:10 warning 'Dispatch' is defined but never used no-unused-vars 7:10 warning 'RootState' is defined but never used no-unused-vars ✖ 3 problems (0 errors, 3 warnings)
Metadata
Metadata
Assignees
Labels
bug/incomplete ruleunable to reproducebugs that are unable to reproduce in masterbugs that are unable to reproduce in master