0.0.4 • Published 2 years ago

one-eslint v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

one-eslint

A collection of opinionated eslint configs and plugins that can be installed as one dependency

It's similar to xo, but instead of wrapping eslint and prettier, it is installed along-side them. This enables use of the regular eslint/prettier IDE plugins, CLIs and more.

Features

:battery: Batteries included

Bundles all plugins and configs under one dependency. You only need to install one-eslint (and eslint itself) and you're ready to go.

:robot: Maximum uniformity

The base config disallows:

  • null (Use undefined)
  • classes (Use functions)
  • interface (Use type)
  • function keyword (Use arrow functions)
  • commonjs (Use esm)
  • forEach (Use for..of)
  • reduce (Use for..of, map or filter)
  • Abbreviations
  • Spelling mistakes
  • Certain dependencies (Suggests alternatives)

:nerd_face: Functional programming style

Includes eslint-plugin-fp.

:jigsaw: Works well with other popular tools

Assumes the use of TypeScript and prettier (It does not enable any style or formatting rules)

:zap: Fast

Only enables rules that are actually useful.

Ignores the following (and more):

  • Rules that are covered by TypeScript anyway

  • Rules that contradict each other

  • Rules regarding classes, they are disabled anyway

  • Rules that are extremely unlikely to catch errors in real life scenarios

For a full list of ignored rules and the reasoning behind them, see each configs ignored.js file.


:package: Install

npm

npm install --save-dev one-eslint eslint

yarn

yarn add --dev one-eslint eslint

Configs

All configs contain unique rules and can be combined however you want. Although it is recommended to always include the base config.

{
  "extends": ["one-base", "one-react", "one-ava", "one-cypress", "one-node"]
}

VS Code config

Some rules should be turned off in your IDE:

base

{
  "eslint.rules.customizations": [
    {
      "rule": "no-console",
      "severity": "off"
    },
    {
      "rule": "no-debugger",
      "severity": "off"
    },
    {
      "rule": "@typescript-eslint/no-explicit-any",
      "severity": "off"
    }
  ]
}

ava

{
  "eslint.rules.customizations": [
    {
      "rule": "ava/no-only-test",
      "severity": "off"
    },
    {
      "rule": "ava/no-skip-test",
      "severity": "off"
    }
  ]
}

Note

The configs are exported as one single dependency (one-eslint). This is so that the plugins can be included with the configs and don't pollute the package.json of the consumer. Also, if you use more than one config, you still only have one dependency in your package.json.

Measure performance

Run eslint with TIMING=1

TIMING=1 npx eslint test-project/index.ts

Formatter

https://github.com/sindresorhus/eslint-formatter-pretty

Features from xo

  • Default paths to lint or ignore
  • Enable clicking a line to open in your editor
0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago