DocumentationRulesno-prop-types

no-prop-types

Full Name in eslint-plugin-react-x

react-x/no-prop-types

Full Name in @eslint-react/eslint-plugin

@eslint-react/no-prop-types

Features

🔍

Presets

  • core
  • recommended
  • recommended-typescript
  • recommended-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 MyComponentComponent(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 MyComponentComponent({ name }: MyComponentProps) {
  return <div>{name}</div>;
}

Implementation

Further Reading