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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@andreasnicolaou/eslint-plugin-conditional-best-practices

v2.0.0

Published

ESLint plugin with opinionated rules for cleaner, safer conditionals: limit nesting, prefer early returns, catch duplicate/constant conditions, and more.

Readme

@andreasnicolaou/eslint-plugin-conditional-best-practices

Opinionated ESLint rules for cleaner, safer conditionals — limit nesting, prefer early returns, catch duplicate and constant conditions, simplify ternaries, and flag risky eval.

GitHub Workflow Status (with event) NPM Version NPM Downloads NPM License

Zero runtime dependencies. Works with ESLint flat config (ESLint 9, and 8.21+) and legacy .eslintrc.

These rules focus on writing clear and efficient conditional statements. They are intentionally opinionated, so feel free to enable only the ones that suit your team.

Installation

npm install -D @andreasnicolaou/eslint-plugin-conditional-best-practices

Usage

Flat config (eslint.config.js) — ESLint 9+ (recommended)

The quickest way is to extend the bundled recommended config, which registers the plugin and turns on every rule at sensible severities:

// eslint.config.js
import conditional from '@andreasnicolaou/eslint-plugin-conditional-best-practices';

export default [conditional.configs.recommended];

Prefer granular control? Register the plugin and pick rules yourself:

// eslint.config.js
import conditional from '@andreasnicolaou/eslint-plugin-conditional-best-practices';

export default [
    {
        plugins: {
            '@andreasnicolaou/conditional-best-practices': conditional,
        },
        rules: {
            '@andreasnicolaou/conditional-best-practices/no-eval': 'error',
            '@andreasnicolaou/conditional-best-practices/no-excessive-nested-conditionals': ['warn', { max: 3 }],
            '@andreasnicolaou/conditional-best-practices/prefer-early-return': 'warn',
        },
    },
];

CommonJS works the same way with require:

const conditional = require('@andreasnicolaou/eslint-plugin-conditional-best-practices');
module.exports = [conditional.configs.recommended];

There is also a conditional.configs.all config that enables every rule as an error.

Legacy config (.eslintrc)

{
    "plugins": ["@andreasnicolaou/conditional-best-practices"],
    "extends": ["plugin:@andreasnicolaou/conditional-best-practices/legacy-recommended"],
}

Rules

✅ = enabled in recommended · 🔧 = autofixable · 💡 = has editor suggestions

| Name | Description | Recommended | Fixable | | :--------------------------------------------------------------------------- | :------------------------------------------------------------------- | :---------: | :-----: | | no-constant-conditionals | Disallow conditionals that always evaluate to true or false. | ✅ | | | no-duplicated-conditions | Disallow duplicate conditions in if/else if chains. | ✅ | | | no-excessive-nested-conditionals | Disallow excessive nesting of conditionals (configurable max). | ✅ | | | no-long-else-if-chains | Limit the number of consecutive else if statements (configurable). | ✅ | | | no-nested-ternary-operators | Disallow nested ternary operators. | ✅ | | | no-useless-ternary | Disallow unnecessary boolean ternaries (x ? true : false). | ✅ | 🔧 | | prefer-early-return | Encourage early returns instead of deeply nested if/else blocks. | ✅ | | | require-default-in-switch | Require a non-empty default case in switch statements. | ✅ | 💡 | | no-eval | Disallow eval() and the Function constructor (security risk). | ✅ | |

Autofixing

Run ESLint with --fix to apply automatic fixes:

npx eslint . --fix
  • no-useless-ternary rewrites cond ? true : falsecond and cond ? false : true!cond.
  • require-default-in-switch offers an editor suggestion to insert a default case (suggestions are applied manually from your editor, not by --fix).

The remaining rules report problems without auto-rewriting, since the safe fix depends on intent.

Contributing

Issues and pull requests are welcome at the GitHub repository.

License

MIT © Andreas Nicolaou