Registry / devops / gatsby-plugin-eslint

gatsby-plugin-eslint

JSON →
library4.0.4jsnpmunverified

Gatsby plugin to replace default ESLint Webpack config, giving full control over linting rules in Gatsby projects. Current version 4.0.4 supports Gatsby v2-v5, ESLint 7/8, and eslint-webpack-plugin v2-v4. Overwrites Gatsby default ESLint config entirely; users must manually re-add Gatsby required rules (no-anonymous-exports-page-templates, limited-exports-page-templates) via rulePaths. Works only with eslint-webpack-plugin, not eslint-loader. Key differentiator: enables custom ESLint configuration that would otherwise be overridden by Gatsby's internal setup.

npm install gatsby-plugin-eslint
INSTALL
IMPORT
SIG · GATSBY-PLUGIN-ESLI
G
gatsby-plugin-eslint
devopsjavascriptv4.0.4
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.

gatsby-plugin-eslint
// In gatsby-config.js: module.exports = { plugins: [ { resolve: 'gatsby-plugin-eslint', options: { /* ... */ } } ] }
// Incorrect: CommonJS require in gatsby-config.js const plugin = require('gatsby-plugin-eslint');
This is a Gatsby plugin, used via gatsby-config.js resolve, not directly imported in components. No ESM/CJS distinction for config.
eslint-webpack-plugin
const ESLintPlugin = require('eslint-webpack-plugin');
const ESLintPlugin = require('eslint-loader');
eslint-loader is deprecated; this plugin uses eslint-webpack-plugin v2+. Must not use eslint-loader.
ESLint config
// .eslintrc.json { "rules": { "no-anonymous-exports-page-templates": "warn", "limited-exports-page-templates": "warn" } }
// Omitting Gatsby required rules { "rules": {} }
You must include Gatsby's two required rules explicitly; plugin overwrites default ESLint config entirely.

Sets up gatsby-plugin-eslint with required Gatsby rules, overwriting default ESLint config.

// Install peer dependencies npm install --save-dev gatsby-plugin-eslint eslint eslint-webpack-plugin // Create .eslintrc.json in root { "rules": { "no-anonymous-exports-page-templates": "warn", "limited-exports-page-templates": "warn" } } // In gatsby-config.js const path = require('path'); const gatsbyRequiredRules = path.join( process.cwd(), 'node_modules', 'gatsby', 'dist', 'utils', 'eslint-rules' ); module.exports = { plugins: [ { resolve: 'gatsby-plugin-eslint', options: { rulePaths: [gatsbyRequiredRules], stages: ['develop'], extensions: ['js', 'jsx', 'ts', 'tsx'], exclude: ['node_modules', 'bower_components', '.cache', 'public'], }, }, ], };
Debug
Known issues
breakingThis plugin completely overwrites Gatsby's ESLint Webpack Plugins. You must manually re-add Gatsby required rules (no-anonymous-exports-page-templates, limited-exports-page-templates) via rulePaths, or lint errors will not be enforced.
fix
Include rulePaths option pointing to Gatsby's built-in ESLint rules directory as shown in the quickstart.
affects: >=1.0.0
deprecatedeslint-loader is deprecated and not supported by this plugin. Use eslint-webpack-plugin instead.
fix
Install eslint-webpack-plugin: npm install --save-dev eslint-webpack-plugin
affects: >=3.0.0
gotchaVersions prior to 4.0.0 may not support Gatsby v4 or v5. Check compatibility. Current version supports Gatsby v2-v5.
fix
Update to latest version: npm install gatsby-plugin-eslint@latest
affects: <4.0.0
gotchaThe plugin only works in stages specified in the 'stages' option. Default is ['develop']; lint during build requires adding 'build-javascript' etc.
fix
Add desired stages to the options.stages array, e.g., stages: ['develop', 'build-javascript'].
affects: >=1.0.0
gotchaIf you are using ESLint flat config (eslint.config.js), this plugin may not work as it expects a traditional .eslintrc. Flat config is supported only in ESLint >=9 and requires additional configuration.
fix
Use traditional .eslintrc format or check plugin documentation for flat config support.
affects: >=4.0.4
Errors
Common errors & fixes
Error: Cannot find module 'eslint-webpack-plugin'
eslint-webpack-plugin is not installed or is installed as a devDependency but missing at runtime.
fix
Run: npm install --save-dev eslint-webpack-plugin
TypeError: ... is not a function (when using eslint-loader)
Using deprecated eslint-loader instead of eslint-webpack-plugin.
fix
Replace eslint-loader with eslint-webpack-plugin in your gatsby-config.js and package.json.
ESLint couldn't find the plugin "eslint-plugin-..."
ESLint plugin required by your config is missing or not installed.
fix
Install the missing plugin: npm install --save-dev eslint-plugin-<name>
Cannot read property 'rules' of undefined (rulePaths)
gatsbyRequiredRules path is incorrect; the ESLint rules directory inside gatsby package has moved or doesn't exist.
fix
Run: npm ls gatsby to check version; adjust rulePaths to node_modules/gatsby/dist/utils/eslint-rules or copy rules manually.
Upgrade
Version history
4.0.4latest on npm
Audit
Dependencies
eslintrequiredESLint is the core linting engine; must be installed as peer dependency
eslint-webpack-pluginrequiredWebpack plugin to run ESLint; used by this Gatsby plugin to intercept webpack config
gatsbyrequiredPlugin is designed to hook into Gatsby's webpack configuration; required peer dependency
Agent activity
6 hits · last 30 days
node
6
Resources
gatsby-plugin-eslint — npm install gatsby-plugin-eslint · libregistry