eslint showing error when using variable from parent scope
See original GitHub issueTell us about your environment
- ESLint Version: 6.0.1
- Node Version: v10.15.3
- npm Version: 6.4.1
What parser (default, Babel-ESLint, etc.) are you using? default Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
import React from 'react';
interface Props {
readonly history: number[];
}
export const MyHistory = (props: Props) => {
const renderContent = () => {
if (props.history.length > 0) {
return <div> My history here</div>
}
return <div> No historical events</div>
};
return renderContent();
};
npm run eslint --fix --ext .tsx --ext .ts src
What did you expect to happen? eslint show no errors
What actually happened? Please include the actual, raw output from ESLint.
9:19 error 'history' is missing in props validation react/prop-types
9:27 error 'history.length' is missing in props validation react/prop-types
Additional info: issue first created on eslint
repo https://github.com/eslint/eslint/issues/12004
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:11 (6 by maintainers)
Top Results From Across the Web
eslint showing error when using variable from parent scope
renderContent is being detected as a component ; but either way you should be destructuring props directly inside your component, not later.
Read more >Working with Rules - ESLint - Pluggable JavaScript Linter
The Scope#variables property contains an array of Variable objects. These are the variables declared in current scope. You can use these Variable objects...
Read more >ESlint reports an error when I call my parent's function
In my parent controller I added my function to the $scope so that the function could be accessed from state's child. function MyParentController ......
Read more >ESLint | WebStorm Documentation - JetBrains
WebStorm shows warnings and errors reported by ESLint right in the editor ... project or in its specific parts, see Configure linting scope....
Read more >Scope - Beginner JavaScript - Wes Bos
console showing value of the typed variable within scope ... If you hover over the variable in VSCode, you will see an error...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
gotcha, in that case it seems like a bug.
This one is fixed too with #2699