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

v4.2.0

Published

eslint-config-es contains a strict ESLint configuration for ES2015+ and TypeScript.

Downloads

3,602

Readme

eslint-config-es

eslint-config-es contains a strict ESLint configuration for ES2015+ and TypeScript.

Status

| Category | Status | | ---------------- | ----------------------------------------------------------------------------------------------------------- | | Version | npm | | Dependencies | David | | Dev dependencies | David | | Build | GitHub Actions | | License | GitHub |

Installation

$ npm install eslint-config-es \
              eslint

The following additional ESLint plugins are included by default, so you don't have to install them:

| Plugin | Automatically enabled | | -------------------------------------------------------------------------------------------------- | --------------------- | | eslint-plugin-eslint-comments | Yes | | eslint-plugin-extended | Yes | | eslint-plugin-mocha | Yes | | eslint-plugin-react | No | | eslint-plugin-unicorn | Yes | | @typescript-eslint/eslint-plugin | No |

To enable support for React and JSX, all you need to do is to install the react module. The appropriate rules will become enabled automatically.

To enable support for TypeScript, all you need to do is to install the typescript module. The appropriate rules will become enabled automatically for .ts and .tsx files. The generated configuration expects a tsconfig.json at the project root.

Quick Start

This module contains a very strict ESLint configuration for ES2015 and above, both for Node.js and browser development. Its aims to eradicate any variation in code style. If you can not tell any more, based on little individual manners, who of your co-workers wrote a piece of code, this module succeeded. This helps you to narrow down your focus to pure functionality, as you do not have to think about code styling any more at all.

To use one of those configurations, create a .eslintrc.json file in your project and use the extends keyword.

{
  "extends": "es/node"
}

Alternatively, you may also use es/browser.

If you want to override any rules, you can do so in your configuration file. For details on how to do this, e.g. to get an explanation on how to enable or disable specific rules, see the ESLint documentation on extending configuration files.

Running quality assurance

To run quality assurance for this module use roboter:

$ npm run roboter

Note: npx roboter will not work as our ESLint Rules are written in TypeScript, so they have to be compiled before usage. npm run roboter will do this.

Better ESLint Rules

This package has a built-in library that allows defining ESLint-Rules in a more strict but (what we think) better and intuitive format.

A basic example looks like this:

const betterRulesRecord: BetterRulesRecord = {
  camelcase: false, // compiles to "camelcase: 'off'"
  forDirection: [], // compiles to "for-direction: 'error'"
  noParens: [ 'always', { otherConfig: 'value' } ], // compiles to "no-parens: [ 'error', 'always', {otherConfig: 'value' } ]"
}

To be able to use those rules with ESLint, they have to be compiled with the betterRules.compile method. The whole betterRules package is exported by this library and can be used like this:

import { betterRules } from 'eslint-config-es';
const compiledESLintRules = betterRules.compile(betterRulesRecord);

// Will produce:
{
  camelcase: 'off',
  'for-direction': [ 'error' ], 
  'no-parens': [ 'error', 'always', { otherConfig: 'value' } ],
}

Differences to normal ESLint Rules

  1. Only 2 allowed rule-configs exist:
    1. false for turning it off.
    2. [] (possible empty) to turn it on with severity error and provide additional configuration.
  2. Rules are now in camelCase.
  3. error is the default and only for all rules.

withPlugin-Hook

You can use the withPlugin hook to avoid having to put plugin-rules in quotes ('react/test-rule') like this:

import { betterRules } from 'eslint-config-es'

const reactRules: BetterRulesRecord = betterRules.withPlugin('react', {
  booleanPropNaming: false
});

Plugin names do not get compiled

Thus, you can use this hook to avoid weird constructs and streamline your configs:

const weirdMix: BetterRulesRecord = {
  '@typescript-eslint/arrayType': []
};

const betterDefiniton: BetterRulesRecord = 
  betterRules.withPlugin('@typescript-eslint', {
    arrayType: []
  };

But why?

  1. Turning Rules off with false rather than with a string 'off' is easier to distinguish from turned on rules and strictly avoids typos (false will yield a compiler error if mistyped).
  2. We do not see a value in ESLint warnings, as warnings tend to get ignored.
  3. Because of 2., there is no need for additional abilities to turn on a rule (true, or a string), thus only allowing arrays [] streamlines and simplifies the configuration a lot.
  4. CamelCasing the rules avoids the need to sometimes type property-keys of rules with quotes ' (e.g. { 'for-direction': 'off'}), thus again streamlining configuration.