no-prop-types
Full Name in eslint-plugin-react-x
react-x/no-prop-typesFull Name in @eslint-react/eslint-plugin
@eslint-react/no-prop-typesFeatures
🔍
Presets
corerecommendedrecommended-typescriptrecommended-type-checked
What it does
Disallows using propTypes property in favor of TypeScript or another type-checking solution.
PropTypes were deprecated in April 2017 (v15.5.0).
The propType checks will be removed from the React package, and using them will be silently ignored. If you’re using propTypes, it is recommend to migrate to TypeScript or another type-checking solution.
Examples
Failing
import React from "react";
class MyComponent extends React.Component {
static propTypes = {
name: React.PropTypes.string,
};
render() {
return <div>{this.props.name}</div>;
}
}import React from "react";
class MyComponent extends React.Component {
render() {
return <div>{this.props.name}</div>;
}
}
MyComponent.propTypes = {
name: propTypes.string,
};import React from "react";
function MyComponent(props) {
return <div>{props.name}</div>;
}
MyComponent.propTypes = {
name: propTypes.string,
};Passing
import React from "react";
interface MyComponentProps {
name: string;
}
class MyComponent extends React.Component<MyComponentProps> {
render() {
return <div>{this.props.name}</div>;
}
}import React from "react";
interface MyComponentProps {
name: string;
}
function MyComponent({ name }: MyComponentProps) {
return <div>{name}</div>;
}