Installations
npm install gatsby-plugin-eslint
Releases
Unable to fetch releases
Developer
mongkuen
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
16.15.0
NPM Version
9.2.0
Statistics
13 Stars
59 Commits
14 Forks
3 Watching
4 Branches
6 Contributors
Updated on 19 Mar 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
8,563,205
Last day
-3.1%
3,149
Compared to previous day
Last week
2.9%
19,002
Compared to previous week
Last month
12%
82,039
Compared to previous month
Last year
-25.4%
1,102,628
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
3
gatsby-plugin-eslint
Now working with Gatsby V3
Replaces Gatsby's ESLint Webpack configs, giving you full control to customize linting with the rules and developer experience you specifically need to maintain code quality.
This will COMPLETELY OVERWRITE any ESLint Webpack Plugins that Gatsby uses. The installation instructions will help you reactivate the two required rules as of writing:
Installation
npm install --save-dev gatsby-plugin-eslint eslint eslint-webpack-plugin
or
yarn add --dev gatsby-plugin-eslint eslint eslint-webpack-plugin
Default Settings
- Lints development mode in the
'develop'
stage. Add other Webpack Config Stages intostages
array to enable linting during other Gatsby stages (eg.build-javascript
) - Lint
.js
,.jsx
,.ts
, and.tsx
files. - Excludes
node_modules
,bower_components
,.cache
, andpublic
folders from linting - Otherwise uses
eslint-webpack-plugin
option defaults
Usage
-
Create
.eslintrc
file in project root.1// .eslintrc 2 3// Gatsby's required rules 4{ 5 "rules": { 6 "no-anonymous-exports-page-templates": "warn", 7 "limited-exports-page-templates": "warn" 8 } 9}
-
Add plugin into
gatsby-config.js
1// gatsby-config.js 2 3const path = require("path"); 4// Get paths of Gatsby's required rules, which as of writing is located at: 5// https://github.com/gatsbyjs/gatsby/tree/fbfe3f63dec23d279a27b54b4057dd611dce74bb/packages/ 6// gatsby/src/utils/eslint-rules 7const gatsbyRequiredRules = path.join( 8 process.cwd(), 9 "node_modules", 10 "gatsby", 11 "dist", 12 "utils", 13 "eslint-rules" 14); 15 16module.exports = { 17 plugins: [ 18 // ...other plugins 19 { 20 resolve: "gatsby-plugin-eslint", 21 options: { 22 // Gatsby required rules directory 23 rulePaths: [gatsbyRequiredRules], 24 // Default settings that may be omitted or customized 25 stages: ["develop"], 26 extensions: ["js", "jsx", "ts", "tsx"], 27 exclude: ["node_modules", "bower_components", ".cache", "public"], 28 // Any additional eslint-webpack-plugin options below 29 // ... 30 }, 31 }, 32 ], 33};
-
Additionally as of writing, Gatsby's default ESLint config may be copied over if you would still like to take advavntage of those rules.
Configuring ESLint
Mix and match your own ESLint plugins and rules depending on the React/Javascript/Typescript patterns you want to enforce. Here are three ways you can get started:
Basic React Linting with eslint-plugin-react
-
Follow
eslint-plugin-react
plugin installation procedures:npm install --save-dev eslint-plugin-react babel-eslint
or
yarn add --dev eslint-plugin-react babel-eslint
-
Add
.eslintrc
file to project root:1{ 2 "parser": "babel-eslint", // uses babel-eslint transforms 3 "settings": { 4 "react": { 5 "version": "detect" // detect react version 6 } 7 }, 8 "env": { 9 "node": true // defines things like process.env when generating through node 10 }, 11 "extends": [ 12 "eslint:recommended", // use recommended configs 13 "plugin:react/recommended" 14 ], 15 "rules": { 16 "no-anonymous-exports-page-templates": "warn", 17 "limited-exports-page-templates": "warn" 18 } 19}
Advanced React Linting with AirBnB's eslint-config-airbnb
-
Follow
eslint-config-airbnb
plugin installation procedures. If npm 5+ this command works fornpm
andyarn
npx install-peerdeps --dev eslint-config-airbnb
-
Add
.eslintrc
file to project root:1{ 2 "extends": "airbnb", 3 "rules": { 4 "no-anonymous-exports-page-templates": "warn", 5 "limited-exports-page-templates": "warn" 6 } 7}
Typescript Linting with ESLint Plugin Typescript
-
Follow
@typescript-eslint/eslint-plugin
plugin installation procedures:npm install --save-dev typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
or
yarn add --dev typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
-
Add
.eslintrc
file to project root:1{ 2 "extends": [ 3 "eslint:recommended", 4 "plugin:@typescript-eslint/recommended", 5 ], 6 "rules": { 7 "no-anonymous-exports-page-templates": "warn", 8 "limited-exports-page-templates": "warn" 9 } 10}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 3/13 approved changesets -- score normalized to 2
Reason
8 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 20 are checked with a SAST tool
Score
2.3
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More