1.3.8 • Published 7 months ago

typescript-eslint-prettier-config v1.3.8

Weekly downloads
-
License
-
Repository
github
Last release
7 months ago

npm version format lint

typescript-eslint-prettier-config

Minimal Typescript, ESLint and Prettier configuration.

ESLint and Prettier configurations are pretty standard in Javascript world. The intention of this package is to create a minimal setup with recommendations for eslint and prettier from the authors. According to them, we don't even need advance plugins that tries to get the best of both the worlds. Typescript config is cherry on top and gels easily with them.

Installation

To install:

npm i -D typescript eslint prettier typescript-eslint-prettier-config

or

yarn add -D typescript eslint prettier typescript-eslint-prettier-config

How to use this package

  1. To extend your existing Typescript configuration

**/tsconfig.json

{
    "extends": "**/node_modules/typescript-eslint-prettier-config/tsconfig.json",
    "compilerOptions": {
        ...
    },
    "exclude": ["**/node_modules/**", "build/**", "dist/**"],
    "include": ["src"] // include your src folder or use default
}
  1. To extend your existing ESLint configuration

**/.eslintrc

{
    "root": true,
    "extends": "**/node_modules/typescript-eslint-prettier-config/.eslintrc",
    "parserOptions": {
        "project": ["./tsconfig.json"] // this is your typescript configuration that you extended in the previous step
    }
}
  1. To extend your existing Prettier configuration

**/.prettierrc.ts

module.exports = {
    ...require('**/node_modules/typescript-eslint-prettier-config/prettier.config'),
};

Further ideas to use the setup optimally

VSCode

eslint --fix can be configured in the settings.json file in VSCode to automatically fix the linting errors. Also, adding formatOnSave runs Prettier every time you save.

{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true,
    "source.organizeImports": true
  },
  "editor.formatOnSave": true
}

Lint staging

lint-staged in combination with husky can be used in package.json to avoid accidentally committing non-linted files on github.

{
  "husky": {
      "hooks": {
          "pre-commit": "lint-staged"
      }
  },
  "lint-staged": {
      "*.{js,jsx,ts,tsx}": [
          "eslint --fix"
      ],
      "*.{js,jsx,ts,tsx,json,yml,yaml,css,html}": [
          "prettier --write"
      ]
  }
}

Inspiration and Thanks

1.3.8

7 months ago

1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.2.3

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.9

2 years ago

1.2.12

2 years ago

1.2.10

2 years ago

1.2.11

2 years ago

1.1.25

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.8

2 years ago

1.0.11

2 years ago

1.1.21

2 years ago

1.0.20

2 years ago

1.1.20

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago