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-genius

v0.1.4

Published

An ESLint config for geniuses. But you can continue to be standard if you want.

Downloads

12

Readme

ESLint Genius

An ESLint config for geniuses.

But you can continue to be standard if you want.

This is a combination of best practices, styles that have objective benefits, and my own (let's face it, correct) opinions. I try to provide my rationale for the more contentious decisions.

Base config

{
  "extends": "eslint:recommended",
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module"
  }
}

camelcase

"error"

Require camelCase for variables and object properties.

comma-dangle

[
  "error",
  "always-multiline"
]

Require multiline list items to have a dangling comma.

  • Makes adding and reordering items a whole lot less fiddly.
  • Simplifies diffs and makes them clearer. See the ESLint documentation for a good example of this.

Wrong

const things = [
	'foo',
	'bar'
];

const data = {
	foo: 'bar',
	baz: 'bat'
}

Right

const things = [
	'foo',
	'bar',
];

const data = {
	foo: 'bar',
	baz: 'bat',
};

comma-spacing

"error"

Space after commas, but not before.

comma-style

"error"

Require a comma after and on the same line as an array element, object property, or variable declaration

curly

"error"

Blocks require curly braces.

  • More consistent.
  • Easier and less error-prone to refactor a block later to include more lines.

Wrong

if (foo) alert(foo);

if (foo)
	alert(foo);
	alert(bar); // not inside the if block!

Right

if (foo) {
	alert(foo);
}

if (foo) {
	alert(foo);
}
alert(bar); // obviously not inside the if block.

eol-last

"error"

Require a newline at the end of files.

eqeqeq

"error"

Always require === and !==, even for literals on both sides and even when null is involved.

func-call-spacing

[
  "error",
  "never"
]

Disallow whitespace between a function call and its parens.

no-mixed-spaces-and-tabs

[
  "error",
  "smart-tabs"
]

Require tabs for indentation, but spaces for alignment. Combining them in this specific way provides the best of both.

  • Tabs maintain their intended purpose of indentation, and nothing else.
  • Code can always be viewed using the tab width the reader is most comfortable with.
  • Lined-up code will stay lined-up no matter what.

Wrong

if (foo) {
/*ss*/alert(foo);
}

const data = {
/*tab*/foo: 'barbaz',/*tab*/ // Some descriptive text
/*tab*//*tab*//*tab*//*tab*/ // explaining this item
/*tab*/quz: 'qux',
};

Right

if (foo) {
/*tab*/alert(foo);
}

const data = {
/*tab*/foo: 'barbaz', // Some descriptive text
/*tab*//*ssssssssss*/ // explaining this item
/*tab*/quz: 'qux',
};

no-trailing-spaces

"error"

Do not allow trailing whitespace, even on blank lines.

no-var

"error"

Always require let or const as opposed to var.

prefer-const

"error"

Always prefer const as opposed to let when possible.

semi

"error"

Always require semicolons.

space-before-blocks

"error"

Require a space before the opening brace of a block.

Wrong

if (a){
	b();
}

function a(){}

try {} catch(a){}

class Foo{
	constructor(){}
}

Right

if (a) {
	b();
}

function a() {}

try {} catch(a) {}

class Foo {
	constructor() {}
}

space-before-function-paren

[
  "error",
  {
    "anonymous": "always",
    "named": "never",
    "asyncArrow": "always"
  }
]

Require a space after anonymous and arrow function parens and disallow for named function parens.

space-in-parens

[
  "error",
  "never"
]

Disallow spaces padding the insides of parens.

space-unary-ops

[
  "error",
  {
    "words": true,
    "nonwords": false,
    "overrides": {
      "!": true,
      "!!": true
    }
  }
]

Require a space after ! and !!, but not other non-word unary operators.

  • It can be very easy to miss a ! (and, to a lesser extent, !!) in front of a variable when scanning code. A space instantly makes things clearer at a glance.
  • Other unary operators are much easier to see.

Wrong

if (!foo) {
	badFooCount ++;
}

foo = !bar;

Right

if (! foo) {
	badFooCount++;
}

foo = ! bar;