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

eslint-config-code-complexity

v1.2.4

Published

Eslint config for adding code complexity constraints to code linting.

Downloads

2,838

Readme

Eslint config code complexity

Eslint config for adding code complexity constraints to code linting. Let's make code comfort to read and maintain. Config inspired by Nikita Sobolev's talk about code complexity.

Usage

  1. Add dev dependency:

npm install --save-dev eslint-config-code-complexity

or

yarn add -D eslint-config-code-complexity

  1. Add config extending in eslint config file (e.g. .eslintrc.json):
...
"extends": ["eslint-config-code-complexity"],
...

Rules description

  • complexity — Cyclomatic complexity measures the number of linearly independent paths through a program's source code. Complexity setted to 5 as maximum or error.
  • max-params — Functions that take numerous parameters can be difficult to read and write because it requires the memorization of what each parameter is, its type, and the order they should appear in. As a result, many coders adhere to a convention that caps the number of parameters a function can take. This rule setted to 4 as maximum or error.
  • max-statements — this rule specify the maximum number of statements allowed in a function. Setted to 7 as maximum or error.
  • max-statements-per-line — A line of code containing too many statements can be difficult to read. Code is generally read from the top down, especially when scanning, so limiting the number of statements allowed on a single line can be very beneficial for readability and maintainability. This rule setted to 2 as maximum or error.
  • max-nested-callbacks — Many JavaScript libraries use the callback pattern to manage asynchronous operations. A program of any complexity will most likely need to manage several asynchronous operations at various levels of concurrency. A common pitfall that is easy to fall into is nesting callbacks, which makes code more difficult to read the deeper the callbacks are nested. Setted to 2 as maximum or error.
  • max-depth — Many developers consider code difficult to read if blocks are nested beyond a certain depth. This rule setted to 3 as maximum or error.
  • max-lines — Some people consider large files a code smell. Large files tend to do a lot of things and can make it hard following what's going. While there is not an objective maximum number of lines considered acceptable in a file, most people would agree it should not be in the thousands. Recommendations usually range from 100 to 500 lines. This rule setted to 150 as maximum or error.