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

@jhecht/eslint-plugin

v1.0.0

Published

Personally preferred eslint config with a customn rule

Downloads

3

Readme

Core Fabrications ESLint Plugin

Custom Rules

This plugin currently provides the following custom rules

  1. @jhecht/max-static-destructure-depth
  2. @jhecht/prefer-destructuring

max-static-destructure-depth

This rule applies in contexts where you are utilizing destructuring, but you only wish to directly destructure a static length into a property. The most common use case for this would be pulling variables from process.env, where the normal destructuring rules try to enforce a code style that honestly doesn't make a lot of sense.

// example using ESLint's default destructuring rule

const { NODE_ENV, OTHER_VARIABLE } = process.env; // Will complain about this, suggesting it to be rewritten as
const {
  env: { NODE_ENV, OTHER_VARIABLE },
} = process; // Why?

max-static-destructure-depth takes an integer argument to determine how far down a developer should be allowed to destructure statically. It defaults to 2 levels, meaning with max-static-destructure-depth being enforced, our previous code

const { NODE_ENV, OTHER_VARIABLE } = process.env; // a-ok

const { foo, bar } = some.nested.variable; // not okay, as we nest 3 levels here.

To change the maximum in your own ESLint config, simply add a line to your rules that looks like this

"rules": {
  "@jhecht/max-static-destructure-depth": ["error", 4]
}

prefer-destructuring

This is a carbon-copy of the ESLint prefer-destructuring rule, modified not to output "errors" caused by our custom destructuring rule. Please see the link for any configuration documentation.

Provided Configs

This plugin currently provides the following custom configs. Note Unless otherwise stated, these extend the eslint:recommended configuration.

  1. plugin:@jhecht/recommended

@jhecht/recommended

The recommended rule profile has the following values

// We use semi colons
semi: ['error', 'always'],
// We use single quotes whenever possible, but allow double quotes to avoid escapes.
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
// Destructuring is a helpful pattern
'prefer-destructuring': ['error', { array: true, object: true }, { enforceForRenamedProperties: true }],
// Curly bracers for multi-line or nested statements
curly: ['error', 'multi-or-nest'],
'arrow-body-style': ['error', 'as-needed'],
// If we don't need arrow parenthesis, we won't add them
'arrow-parens': ['error', 'as-needed'],
'@jhecht/max-static-destructure-depth': ['error', 2]
'@jhecht/prefer-destructuring': ['error', { array: true, object: true }, { enforceForRenamedProperties: true }]

License

The license of this project is MIT. You are free to use and modify it to suit your needs so long as you understand that Core Fabrications is in no way offering support to your project.