eslint-plugin-github
raw JSON → 6.0.0 verified Sat Apr 25 auth: no javascript
An opinionated collection of ESLint shared configs and rules used by GitHub. Current stable version is 6.0.0, which includes flat config support and ESM-only. The package provides configs for browser, React, TypeScript, and internal GitHub applications. Key differentiators: it enforces GitHub's own coding standards, includes accessibility rules (a11y), async/await best practices, and actionable rules like array-foreach and no-then. It supports both legacy .eslintrc and flat config via getFlatConfigs().
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/eslint-plugin-github/dist/index.js from .../eslint.config.js not supported. Instead rename the index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change the required code to use ESM. ↓
cause v6.0.0 is ESM-only; CommonJS require() fails.
fix
Use dynamic import() or set type: module in package.json. Alternatively, downgrade to v5.x.
error Definition for rule 'array-foreach' was not found. ↓
cause Rule name missing plugin prefix 'github/'.
fix
Change 'array-foreach' to 'github/array-foreach' in your ESLint config.
error ESLint couldn't find the plugin 'eslint-plugin-github'. ↓
cause Plugin not installed or not added to plugins array in flat config.
fix
Install with npm install --save-dev eslint-plugin-github, and import it at the top of eslint.config.js.
Warnings
breaking v6.0.0 is ESM-only. Requires Node >= 20. ↓
fix Upgrade to Node 20 or later, or continue using v5.x (legacy CommonJS).
breaking v6.0.0 removed github plugin from typescript config; previously included rules may no longer apply. ↓
fix Explicitly add rules from removed plugin if needed. See changelog for details.
deprecated filenames/match-regex rule renamed to github/filenames-match-regex (the original eslint-filenames-plugin is unmaintained). ↓
fix Update rule name from 'filenames/match-regex' to 'github/filenames-match-regex'.
gotcha When using flat config, plugin namespace must be explicit in rule names (e.g., 'github/array-foreach'), not just 'array-foreach'. ↓
fix Prefix custom rules with 'github/'.
gotcha The react config requires a component mapping setting for polymorphic components; otherwise some a11y rules may not apply correctly. ↓
fix Add 'settings.github.components' mapping and 'settings.github.polymorphicPropName' in your ESLint config.
Install
npm install eslint-plugin-github yarn add eslint-plugin-github pnpm add eslint-plugin-github Imports
- default wrong
const github = require('eslint-plugin-github')correctimport github from 'eslint-plugin-github' - github.getFlatConfigs wrong
require('eslint-plugin-github').getFlatConfigs()correctgithub.getFlatConfigs() - Rule: github/array-foreach wrong
'array-foreach': 'error'correct'github/array-foreach': 'error'
Quickstart
npm install --save-dev eslint eslint-plugin-github
# Create eslint.config.js (ESM flat config)
import github from 'eslint-plugin-github'
export default [
github.getFlatConfigs().recommended,
github.getFlatConfigs().browser,
github.getFlatConfigs().react,
...github.getFlatConfigs().typescript,
{
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
ignores: ['eslint.config.mjs'],
rules: {
'github/array-foreach': 'error',
'github/async-preventdefault': 'warn',
'github/no-then': 'error',
'github/no-blur': 'error',
},
},
]