Registry / testing / eslint-plugin-primer-react

eslint-plugin-primer-react

JSON →
library8.6.0jsnpmunverified

ESLint plugin providing lint rules for Primer React components, currently at version 8.6.0. Requires ESLint ^9.0.0 and Node >=20. Actively maintained with frequent releases. Offers rules for enforcing best practices like using styled-react imports, no deprecated components, and preventing ReDoS vulnerabilities. Differentiates from generic React linting by being specific to Primer's design system.

npm install eslint-plugin-primer-react
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-PRIM
E
eslint-plugin-primer-react
testingjavascriptv8.6.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import primerReact from 'eslint-plugin-primer-react'
const primerReact = require('eslint-plugin-primer-react')
ESM-only; use import, not require.
rules
import { rules } from 'eslint-plugin-primer-react'
Access individual rules if needed.
configs
import { configs } from 'eslint-plugin-primer-react'
Use configs.recommended or configs.strict for preset rule sets.
RuleName
import { rules } from 'eslint-plugin-primer-react'; const rule = rules['rule-name']
import { rule-name } from 'eslint-plugin-primer-react'
Rules are accessed via the rules object, not as named exports.

Basic ESLint configuration using eslint-plugin-primer-react with three common rules enabled.

// eslint.config.js export default [ { plugins: { primerReact: (await import('eslint-plugin-primer-react')).default }, rules: { 'primer-react/no-deprecated-components': 'error', 'primer-react/no-unnecessary-components': 'warn', 'primer-react/use-styled-react-import': 'error' } } ];
Debug
Known issues
breakingESLint v9 support requires plugin version >=8.0.0; v7 and earlier are incompatible.
fix
Update to v8.0.0 or later and ensure ESLint ^9.0.0 is installed.
affects: <8.0.0
breakingNode.js version requirement is >=20 in v8.x; older Node versions may not work.
fix
Use Node.js 20 or newer.
affects: >=8.0.0
deprecatedThe Octicon component is deprecated; use specific icon components instead.
fix
Replace Octicon imports with named icon imports like {IconCheck} from '@primer/octicons-react'.
affects: >=8.6.0
gotchaESM-only import; CommonJS require() will fail if not using dynamic import or if in a CJS context.
fix
Use import syntax or dynamic import() in CJS modules.
affects: >=8.0.0
deprecatedReDoS vulnerability fixed in v8.5.2 for utils/casing-matches.
fix
Upgrade to v8.5.2 or later to mitigate the vulnerability.
affects: <8.5.2
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/eslint-plugin-primer-react/index.js from /path/to/eslint.config.js not supported.
Using CommonJS require() on an ESM-only package.
fix
Change eslint.config.js to ESM (add 'type': 'module' in package.json) or use dynamic import: const primerReact = (await import('eslint-plugin-primer-react')).default
ESLint configuration error: Cannot find module 'eslint-plugin-primer-react'
Package not installed or incorrect version.
fix
Run 'npm install eslint-plugin-primer-react@latest --save-dev'
Error: Rule 'primer-react/no-deprecated-components' is not configured.
Rule not included in the plugins object or not added to rules.
fix
Ensure the plugin is in the 'plugins' key and the rule in 'rules'.
Upgrade
Version history
8.6.0latest on npm
Audit
Dependencies
eslintrequiredpeer dependency for ESLint plugin
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-primer-react — npm install eslint-plugin-primer-react · libregistry