1.2.14 • Published 4 days ago

@andreashuber69/eslint-config v1.2.14

Weekly downloads
-
License
Unlicense
Repository
github
Last release
4 days ago

This is a comprehensive and carefully curated shareable eslint config for TypeScript projects.

Rationale

A search for eslint-config and typescript on npm lists well over 2500 packages. Despite this abundance, I've failed to find a package that satisfies what I was looking for, namely:

  • Leverage the best eslint-plugins to thoroughly inspect code. To get an idea of what this config tries to achieve, it's probably best to compare the number of active rules recommended for TypeScript projects (see TS eslint quick start) with React support (see eslint-plugin-react) to the number of active rules in this configuration. At the time of writing the count is only 97 for the recommended set compared to 596 rules in this package. More specifically, ...
    • flag as many problems and as much inconsistent formatting as possible while keeping false positives low. Developers should be able to correct most errors and warnings by rewriting the code as opposed to sprinkling it with eslint-disable.
    • treat developers as responsible human beings and trust that they have a good sense of how much and what documentation is necessary. Forcing developers to write docs usually leads to text that is not actually helpful and therefore a waste of time.
    • enforce established ES and TS naming conventions.
  • Make installation, configuration and maintenance as easy as possible. With npm >= 7.0 you only need to install and update this package. All dependencies are kept up to date automatically, see Getting Started for more information.
  • Closely track the versions of all dependencies and release new config versions as necessary.
  • Last but not least: Automatically test the configuration, such that changes in eslint and the plugins (e.g. added or removed rules) are detected and the rules listed in the configuration are always in sync with the rules provided. With 7 plugins adding rules to this package, it's hard to overstate the importance of testing for completeness and consistency. No other eslint configuration out there seems to do that, which is probably why some of them still needlessly turn off eslint base rules in favor of their @typescript-eslint counterparts, even though they extend from the @typescript-eslint/recommended list (which already does that).

To see how the linted code will look like, you can look at async-css-plugin and verify-coldcard-dice-seed. If the code looks sensible to you, you might want to give this package a try in your project. Of course, you can tweak everything to your liking, see below.

Prerequisites

The configuration provided by this package and the instructions below are designed to work out of the box for already setup TypeScript projects. That is, there must be a tsconfig.json file in a direct or indirect parent folder of every linted .ts file, see this article for details. Also, while not required, it is recommended to have your tsconfig.json extend from a strict configuration. Here's an example for node:

{
  "extends": [
    "@tsconfig/strictest/tsconfig",
    "@tsconfig/node-lts/tsconfig"
  ],
  "compilerOptions": {
    // Additional compiler options to the ones set by @tsconfig
  },
  "include": [
    "src/**/*"
  ]
}

Getting Started

Installation

On the command line, first enter npm -v to see what version of npm you have installed. If you have a version >=7.0.0, please use this command:

npm install --save-dev @andreashuber69/eslint-config

Otherwise, please use this command:

npx install-peerdeps @andreashuber69/eslint-config --dev

On npm 7 and newer, peer dependencies are installed automatically. On older versions of npm, you can use the tool install-peerdeps as shown above or install the peer dependencies manually.

Configuration

  1. Create the new file .eslintrc.cjs in the root folder of your project, with the following contents:

    module.exports = {
        env: {
            // You need to set your execution environment (node, browser, etc.), for more information please see
            // https://eslint.org/docs/latest/user-guide/configuring/language-options#specifying-environments
            node: true,
        },
        extends: ["@andreashuber69"],
        rules: {
            // Customize rules as you see fit
        },
    };

    This is typically enough, as eslint will merge the above with parserOptions: { ecmaVersion: "latest" }, env: { es2024: true } and other defaults. To see the complete configuration you might want to run ...

    npx eslint --print-config .eslintrc.cjs >eslint-config.json

    ... and inspect eslint-config.json. Note that for a typical TS project you want to parse according to the latest standard because the TypeScript compiler will downlevel language features depending on the target setting in tsconfig.json.

  2. Add the following line to the scripts section of your package.json (assuming your code resides in the src folder):

    "lint": "eslint --ext .js,.ts --report-unused-disable-directives './src'",

Lint

npm run lint
1.2.14

4 days ago

1.2.12

17 days ago

1.2.13

17 days ago

1.2.10

18 days ago

1.2.11

17 days ago

1.2.8

1 month ago

1.2.9

1 month ago

1.2.7

1 month ago

1.2.6

2 months ago

1.2.5

2 months ago

1.2.4

2 months ago

1.2.3

2 months ago

1.2.2

2 months ago

1.2.0

2 months ago

1.2.1

2 months ago

1.1.98

2 months ago

1.1.96

2 months ago

1.1.97

2 months ago

1.1.95

2 months ago

1.1.94

2 months ago

1.1.93

2 months ago

1.1.92

3 months ago

1.1.91

3 months ago

1.1.90

3 months ago

1.1.89

3 months ago

1.1.88

3 months ago

1.1.87

3 months ago

1.1.86

3 months ago

1.1.85

3 months ago

1.1.84

3 months ago

1.1.83

3 months ago

1.1.82

4 months ago

1.1.81

4 months ago

1.1.79

4 months ago

1.1.80

4 months ago

1.1.78

4 months ago

1.1.77

5 months ago

1.1.76

5 months ago

1.1.75

5 months ago

1.1.74

5 months ago

1.1.73

5 months ago

1.1.72

5 months ago

1.1.71

5 months ago

1.1.70

5 months ago

1.1.69

5 months ago

1.1.68

5 months ago

1.1.67

5 months ago

1.1.66

5 months ago

1.1.65

6 months ago

1.1.64

6 months ago

1.1.63

6 months ago

1.1.62

6 months ago

1.1.61

7 months ago

1.1.34

10 months ago

1.1.33

10 months ago

1.1.38

10 months ago

1.1.37

10 months ago

1.1.36

10 months ago

1.1.35

10 months ago

1.1.39

10 months ago

1.1.41

9 months ago

1.1.40

10 months ago

1.1.45

9 months ago

1.1.44

9 months ago

1.1.43

9 months ago

1.1.42

9 months ago

1.1.49

9 months ago

1.1.48

9 months ago

1.1.47

9 months ago

1.1.46

9 months ago

1.1.52

8 months ago

1.1.51

8 months ago

1.1.50

9 months ago

1.1.56

8 months ago

1.1.55

8 months ago

1.1.54

8 months ago

1.1.53

8 months ago

1.1.59

7 months ago

1.1.58

7 months ago

1.1.57

7 months ago

1.1.60

7 months ago

1.1.32

11 months ago

1.1.31

11 months ago

1.1.29

11 months ago

1.1.28

11 months ago

1.1.30

11 months ago

1.1.23

11 months ago

1.1.26

11 months ago

1.1.25

11 months ago

1.1.24

11 months ago

1.1.16

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.22

12 months ago

1.1.21

12 months ago

1.1.20

1 year ago

1.1.12

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago