Registry /
testing / eslint-plugin-react-prefer-function-component
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
plugin
✓ import plugin from 'eslint-plugin-react-prefer-function-component'
✗ const plugin = require('eslint-plugin-react-prefer-function-component')
Default export; CJS require works but ESM is preferred. For flat config, use `import preferFC from 'eslint-plugin-react-prefer-function-component/config'`
configs.recommended
✓ import { configs } from 'eslint-plugin-react-prefer-function-component'
✗ const configs = require('eslint-plugin-react-prefer-function-component').configs
Access via configs.recommended for legacy eslintrc. For flat config, import the config directly from 'eslint-plugin-react-prefer-function-component/config'
config (flat config)
✓ import preferFC from 'eslint-plugin-react-prefer-function-component/config'
✗ import preferFC from 'eslint-plugin-react-prefer-function-component'
ESM-only; available since v3.3.0. This is the flat config export, not the rule itself.
rules['react-prefer-function-component']
✓ rules: { 'react-prefer-function-component/react-prefer-function-component': 'error' }
✗ rules: { 'prefer-function-component': 'error' }
Rule name prefix changed in v4.0.0 for flat config. Legacy eslintrc uses 'react-prefer-function-component' as the plugin name, but the rule is accessed via 'react-prefer-function-component/react-prefer-function-component'.
Shows both flat config (ESM) and legacy eslintrc (CJS) setup for the plugin, including the recommended config and custom options.
// eslint.config.js (flat config) - ESM
import js from '@eslint/js';
import reactRecommended from 'eslint-plugin-react/configs/recommended.js';
import preferFC from 'eslint-plugin-react-prefer-function-component/config';
export default [
js.configs.recommended,
reactRecommended,
preferFC,
];
// eslintrc (legacy) - CJS
module.exports = {
plugins: ['react-prefer-function-component'],
extends: ['plugin:react-prefer-function-component/recommended'],
rules: {
// Override allowErrorBoundary if needed
'react-prefer-function-component/react-prefer-function-component': ['error', { allowErrorBoundary: true }],
},
};
Errors
Common errors & fixes
ESLint couldn't determine the plugin 'react-prefer-function-component' uniquely.
Multiple plugins with same name or incorrect naming in eslintrc.
fixEnsure the plugin is installed and use the correct plugin name: 'react-prefer-function-component' (not 'prefer-function-component').
Configuration for rule 'react-prefer-function-component/react-prefer-function-component' is invalid: "allowComponentDidCatch" is not a valid option.
Using deprecated option from v5.0.0.
fixRename 'allowComponentDidCatch' to 'allowErrorBoundary'.
Cannot find module 'eslint-plugin-react-prefer-function-component/config'
Using flat config import with version <3.3.0 or incorrect path.
fixUpgrade to v3.3.0+. Ensure the import path is correct: 'eslint-plugin-react-prefer-function-component/config'.
Invalid plugin object: Plugin react-prefer-function-component did not export a 'rules' object.
Using flat config incorrectly (e.g., trying to spread the default export directly).
fixImport the config from 'eslint-plugin-react-prefer-function-component/config' and include it as an object in the array, not spread.
Audit
Dependencies
eslintrequiredpeer dependency; plugin requires ESLint to function