close

static-property-placement

Unreleased

Configuration

rslint.config.ts
import { defineConfig, reactPlugin } from '@rslint/core';

export default defineConfig([
  reactPlugin.configs.recommended,
  {
    rules: {
      'react/static-property-placement': 'error',
    },
  },
]);

Enforce where React component static properties are declared in an ES6 class.

The rule checks childContextTypes, contextTypes, contextType, defaultProps (including legacy getDefaultProps), displayName, and propTypes. The default placement is static public field.

Options

The first option selects the default placement:

  • static public fieldstatic propTypes = {...}
  • static getterstatic get propTypes() {...}
  • property assignmentMyComponent.propTypes = {...} outside the class

The second option is an object that overrides the placement for individual properties. Unspecified properties use the first option.

["property assignment", {"displayName": "static public field"}]

Original Documentation