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

@bob-obringer/eslint-plugin

v0.6.2

Published

ESLint plugin for Bob Obringer's projects

Downloads

68

Readme

eslint-plugin

This is a custom ESLint plugin that provides my opinionated rules and configurations for TypeScript, React, and Next.js projects.

Installation

pnpm i -D @bob-obringer/eslint-plugin
npm i --save-dev @bob-obringer/eslint-plugin
yarn add --dev @bob-obringer/eslint-plugin

Usage

This plugin provides three configurations:

  • recommended: A base configuration that enforces my opinionated practices.
  • react: Extends recommended with rules tailored for React projects.
  • next: Extends recommended with rules tailored for Next.js projects.

To use a configuration, extend your .eslintrc file like so:

{
  "plugins": ["@bob-obringer"],
  "extends": ["plugin:@bob-obringer/react"]
}

Replace recommended with react or next for React and Next.js projects, respectively.

Rules


no-process-env

Enabled by default in the recommended configuration.

Disallows the use of process.env outside of a config file.

  • It prevents process.env from being scattered throughout the codebase, which can make it difficult to manage and maintain.
  • Having a centralized config allows you to provide both compile time and run time typesafety for your environment variables.
  • Centralizing config makes it easy to see all the environment variables in one place, understand how they are used, and avoid accidental duplication.
  • By prohibiting process.env outside the config folder, this rule nudges developers towards the best practice and keeps the codebase clean.

Usage:

{
  "rules": {
    "@bob-obringer/no-process-env": ["error", "config"]
  }
}

The second argument is a optional string that specifies folders which may contain process.env references. The default is config.


next-prefer-named-exports

Enabled by default in the next configuration.

Usage:

{
  "rules": {
    "@bob-obringer/next-prefer-named-exports": "error"
  }
}

Configurations

These configurations begin with sane defaults provided by recommended ESLint and Typescript rules, and then add my opinionated rules on top of them.

Recommended

Extends:

  • eslint:recommended
  • @typescript-eslint
  • prettier

Rules:

  • Disallows unused imports (unused-imports/no-unused-imports)
  • Disallows unused variables (@typescript-eslint-no-unused-vars)
  • Disallows duplicate imports from the same module (import/no-duplicates)
  • Requires a newline after imports (import/newline-after-import)
  • Prevents the use of process.env outside of a config file (@bob-obringer/no-process-env)

React

Extends:

  • @bob-obringer/recommended
  • react/recommended

Rules:

  • Disables requiring React to be in scope (react/react-in-jsx-scope)
  • Disallows the default React import, and that begin with ./..

NextJS

Extends:

  • @bob-obringer/recommended
  • next/core-web-vitals

Rules:

  • Disallows default exports (@bob-obringer/next-prefer-named-exports)
  • Disallows the default React import (no-restricted-imports)
  • Disallows imports that begin with ./.. (no-restricted-imports)
  • Disallows the use of next/router (no-restricted-imports)

TODO:

ESLint 9 is here, including a new config system. Most of the ecosystem has not caught up yet, including our dependencies. Once our dependencies are ready, we'll bump this to 9 and upgrade to the new config system. If they drag, we'll create our own version of the old rules.