npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ayan4m1/gatsby-plugin-eslint

v5.0.0

Published

Gatsby plugin to add support for ESLint

Downloads

5

Readme

gatsby-plugin-eslint

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-webpack-plugin

or

yarn add --dev gatsby-plugin-eslint eslint-webpack-plugin

Default Settings

  1. Lints development mode in the 'develop' stage. Add other Webpack Config Stages into stages array to enable linting during other Gatsby stages (eg. build-javascript)
  2. Lint .js, .jsx, .ts, and .tsx files.
  3. Excludes node_modules, bower_components, .cache, and public folders from linting
  4. Otherwise uses eslint-webpack-plugin option defaults

Usage

  1. Create eslint.config.mjs file in project root.

    export default [
      {
        files: ['src/**/*.js'],
        rules: {
          'no-anonymous-exports-page-templates': 'warn',
          'limited-exports-page-templates': 'warn'
        }
      }
    ];
  2. Add plugin into gatsby-config.js

    // gatsby-config.js
    
    const path = require('path');
    // Get paths of Gatsby's required rules, which as of writing is located at
    // https://github.com/gatsbyjs/gatsby/tree/gatsby%405.3.3/packages/gatsby/src/utils/eslint-rules
    const gatsbyRequiredRules = path.join(
      process.cwd(),
      'node_modules',
      'gatsby',
      'dist',
      'utils',
      'eslint-rules'
    );
    
    module.exports = {
      plugins: [
        // ...other plugins
        {
          resolve: 'gatsby-plugin-eslint',
          options: {
            configType: 'flat',
            eslintPath: 'eslint/use-at-your-own-risk',
            // Optional path for Gatsby required rules
            rulePaths: [gatsbyRequiredRules]
            // Default settings that may be omitted or customized
            // stages: ['develop'],
            // extensions: ['js', 'jsx', 'ts', 'tsx'],
            // exclude: ['node_modules', 'bower_components', '.cache', 'public']
          }
        }
      ]
    };
  3. 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 (To Be Updated For Flat Config)

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

  1. 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

  2. Add .eslintrc file to project root:

    {
      "parser": "babel-eslint", // uses babel-eslint transforms
      "settings": {
        "react": {
          "version": "detect" // detect react version
        }
      },
      "env": {
        "node": true // defines things like process.env when generating through node
      },
      "extends": [
        "eslint:recommended", // use recommended configs
        "plugin:react/recommended"
      ],
      "rules": {
        "no-anonymous-exports-page-templates": "warn",
        "limited-exports-page-templates": "warn"
      }
    }

Typescript Linting with ESLint Plugin Typescript

  1. 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

  2. Add .eslintrc file to project root:

    {
      "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended",
      ],
      "rules": {
        "no-anonymous-exports-page-templates": "warn",
        "limited-exports-page-templates": "warn"
      }
    }