Skip to main content
interlace
Plugin: react-featuresRules

no-unsafe

Warn about UNSAFE_ lifecycle methods. This rule is part of eslint-plugin-react-features and provides LLM-optimized error messages.

Warn about UNSAFE_ lifecycle methods. This rule is part of eslint-plugin-react-features and provides LLM-optimized error messages.

Quick Summary

AspectDetails
SeverityWarning (code quality)
Auto-Fix❌ No auto-fix
CategoryReact
ESLint MCP✅ Optimized for ESLint MCP integration
Best ForAll React/JSX projects

Rule Details

UNSAFE_ lifecycle methods may cause issues with async rendering and will be removed in future React versions.

Examples

❌ Incorrect

class MyComponent extends React.Component {
  UNSAFE_componentWillMount() {
    this.loadData();
  }

  UNSAFE_componentWillReceiveProps(nextProps) {
    this.updateState(nextProps);
  }

  UNSAFE_componentWillUpdate(nextProps, nextState) {
    this.prepareUpdate();
  }
}

✅ Correct

class MyComponent extends React.Component {
  componentDidMount() {
    this.loadData();
  }

  static getDerivedStateFromProps(props, state) {
    return { derivedValue: props.value };
  }

  getSnapshotBeforeUpdate(prevProps, prevState) {
    return this.divRef.scrollHeight;
  }
}

Use this rule

npm install -D oxlint-plugin-react-features
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-react-features"],  "rules": {    "react-features/no-unsafe": "error"  }}
vite.config.ts
import { defineConfig } from 'vite-plus';export default defineConfig({  lint: {    jsPlugins: ['oxlint-plugin-react-features'],    rules: {      'react-features/no-unsafe': 'error',    },  },});

oxlint-plugin-react-features re-exports eslint-plugin-react-features/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.

Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.