Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug is missing in props validation #3090

Closed
jonlepage opened this issue Oct 1, 2021 · 5 comments · Fixed by #3092
Closed

bug is missing in props validation #3090

jonlepage opened this issue Oct 1, 2021 · 5 comments · Fixed by #3092

Comments

@jonlepage
Copy link

jonlepage commented Oct 1, 2021

hi why this is not valid ? it should ok no!
image
image

here the demo from your example

interface Props {
	age: number
 }
 const Hello: VFC<Props> = function Hello(props) {
	const { age } = props;

	return <div>Hello {name}</div>;
	// 'name' type is missing in props validation
 }
@ljharb
Copy link
Member

ljharb commented Oct 1, 2021

Are you using the TypeScript eslint parser?

@jonlepage
Copy link
Author

yes

{
    "env": {
        "browser": true,
        "es2021": true,
        "node": true
    },
    "extends": [
        "plugin:react/recommended",
        "plugin:react-hooks/recommended"
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": 12,
        "sourceType": "module"
    },
    "plugins": [
        "react",
        "@typescript-eslint"
    ],
    "rules": {
        "array-bracket-spacing": "warn",
        "multiline-comment-style": "warn",
        "no-console": "warn",
        "comma-dangle": "off",
        "no-var": "warn",
        "no-duplicate-imports": "error",
        "sort-imports": "warn"
    }
}
	"devDependencies": {
		"@types/chrome": "0.0.157",
		"@types/nw.js": "^0.13.14",
		"@types/react": "^17.0.20",
		"@types/react-dom": "^17.0.9",
		"@types/react-grid-layout": "^1.1.2",
		"@typescript-eslint/eslint-plugin": "^4.32.0",
		"@typescript-eslint/parser": "^4.32.0",
		"@vitejs/plugin-react-refresh": "^1.3.6",
		"commander": "^8.1.0",
		"eslint": "^7.32.0",
		"eslint-config-airbnb": "^18.2.1",
		"eslint-plugin-import": "^2.24.2",
		"eslint-plugin-jsx-a11y": "^6.4.1",
		"eslint-plugin-react": "^7.26.1",
		"eslint-plugin-react-hooks": "^4.2.0",
		"nw": "^0.55.0",
		"nw-builder": "^3.5.7",
		"ts-essentials": "^8.1.0",
		"vite": "^2.5.6"
	}

@ljharb
Copy link
Member

ljharb commented Oct 1, 2021

That all seems good. Can you make a repro repo?

@jonlepage
Copy link
Author

jonlepage commented Oct 1, 2021

That all seems good. Can you make a repro repo?

oki i think i understand what happening.

interface Props {
	age: number
 }
 const Hello: VoidFunctionComponent<Props> = function Hello(props) {
	const { age } = props;

	return <div>Hello {name}</div>;
 }

 const Hello2: FunctionComponent<Props> = function Hello(props) {
	const { age } = props;

	return <div>Hello {name}</div>;
 }

it seem VoidFunctionComponent are not supported by the rule ! ?
Work fine with FunctionComponent

image

is this a bug? or any rules options i can add to allow VoidFunctionComponent support for the rule ?

@ljharb
Copy link
Member

ljharb commented Oct 1, 2021

It may be an oversight. I think the plugin would need to be updated to handle it. cc @vedadeepta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants