eslint-config-phoenix

An Eslint config for Typescript NodeJs projects

Usage no npm install needed!

<script type="module">
  import eslintConfigPhoenix from 'https://cdn.skypack.dev/eslint-config-phoenix';
</script>

README

eslint-config-phoenix

npm code style: prettier

A rather strict but sensible ESLint config for Node Js based projects.

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 71
eslint-plugin-unicorn 57
eslint-plugin-import 32
eslint-plugin-regexp 31
eslint-plugin-sonarjs 24
eslint-plugin-promise 12
eslint-plugin-security 11
eslint-plugin-eslint-comments 6
eslint-plugin-no-use-extend-native 1
eslint-plugin-optimize-regex 1
eslint-plugin-ext 1
eslint-plugin-json¹ 1
HTML ESLint 16
Total: phoenix 514

¹ 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-phoenix

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

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

phoenix/extra

This config adds rules for type-graphql.

Plugin Enabled rules
eslint-plugin-type-graphql 6
Total: phoenix + phoenix/extra 520

Use it in addition to the phoenix config:

{
  "extends": ["phoenix", "phoenix/extra"],
}

phoenix/ts-for-js

Plugin Enabled rules
typescript-eslint 44
eslint-plugin-sort-class-members 1
Total: phoenix + phoenix/extra + phoenix/ts-for-js 565

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 phoenix/ts-for-js to the overrides section in your .eslintrc like this:
{
  "extends": ["phoenix", "phoenix/extra"],
  "overrides": [
    {
      "files": ["*.js"],
      "extends": ["phoenix/ts-for-js"],
      "parserOptions": { "project": "./tsconfig.json" }
    }
  ]
}

Changelog

License

MIT