/eslint-config-hardcore

The most strict (but practical) ESLint config out there. 621 rules.

Primary LanguageJavaScriptMIT LicenseMIT

eslint-config-hardcore

npm code style: prettier

The most strict (but practical) ESLint config out there. 621 rules.

Aims to include as many plugins and rules as possible to make your code extremely consistent and robust.

Uses eslint-plugin-prettier for autoformatting your code.

What's included

Plugin Enabled rules
ESLint core rules 184
eslint-plugin-prettier 82
eslint-plugin-putout 67
eslint-plugin-unicorn 57
eslint-plugin-import 32
eslint-plugin-sonarjs 24
eslint-plugin-regexp 16
eslint-plugin-promise 12
eslint-plugin-security 11
eslint-plugin-array-func 6
eslint-plugin-eslint-comments 6
eslint-plugin-no-constructor-bind 2
@shopify/eslint-plugin 1
eslint-plugin-no-use-extend-native 1
eslint-plugin-optimize-regex 1
eslint-plugin-ext 1
eslint-plugin-json¹ 1
HTML ESLint 16
Total: hardcore 520

¹ eslint-plugin-json actually includes 19 rules, but I consider them as one "no-invalid-json" rule.

Usage

Install:

npm install --save-dev eslint-config-hardcore

Then, add it to your .eslintrc file and specify your environments:

{
  "extends": ["hardcore"],
  "env": {
    "browser": true
  }
}

hardcore/fp

This config adds rules for functional programming.

Plugin Enabled rules
eslint-plugin-fp 14
eslint-plugin-ramda 24
Total: hardcore + hardcore/fp 558

Use it in addition to the hardcore config:

{
  "extends": ["hardcore", "hardcore/fp"],
  "env": {
    "browser": true
  }
}

hardcore/node

This config adds rules and globals for Node.js.

Plugin Enabled rules
eslint-plugin-node 35
Total: hardcore + hardcore/fp + hardcore/node 593

Use it in addition to other configs:

{
  "extends": ["hardcore", "hardcore/fp", "hardcore/node"]
}

Or, if your project contains both non-Node and Node files, use it like this:

{
  "extends": ["hardcore", "hardcore/fp"],
  "env": {
    "browser": true
  },
  "overrides": [
    {
      "files": ["server/**/*.js"],
      "extends": ["hardcore/node"],
      "env": {
        "browser": false
      }
    }
  ]
}

hardcore/ts-for-js

Plugin Enabled rules
typescript-eslint 44
@shopify/eslint-plugin 2
eslint-plugin-sort-class-members 1
eslint-plugin-decorator-position 1
Total: hardcore + hardcore/fp + hardcore/node + hardcore/ts-for-js 621

Did you know you can lint JavaScript code with typescript-eslint?

Use this config to take advantage of typescript-eslint's advanced type-aware rules (like @typescript-eslint/naming-convention and @typescript-eslint/prefer-optional-chain) without the need to switch to writing TypeScript.

  1. First, you'll need to create tsconfig.json in the root of your project. You don't have to specify any options, just {} should do it.
  2. Then add hardcore/ts-for-js to the overrides section in your .eslintrc like this:
{
  "extends": ["hardcore", "hardcore/fp", "hardcore/node"],
  "overrides": [
    {
      "files": ["*.js"],
      "extends": ["hardcore/ts-for-js"],
      "parserOptions": { "project": "./tsconfig.json" }
    }
  ]
}

License

MIT