0.1.1 • Published 1 year ago

@m-thalmann/eslint-config-typescript v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@m-thalmann/eslint-config-typescript

!NOTE
This package only supports the new flat config format

This package provides a base configuration for the TypeScript ESLint Plugin

Installation

!NOTE
You should also install the @m-thalmann/eslint-config-base package and set it up like described in it's README

npm install --save-dev @m-thalmann/eslint-config-typescript

Usage

Add the config to your eslint.config.js file:

// ...

const typeScriptConfig = require('@m-thalmann/eslint-config-typescript');

module.exports = [
  // ... other configurations

  // setup typescript usage!

  ...typeScriptConfig,

  // if you are using Prettier put it's config here

  // ... override any project-specific settings
];

!Tip When using flat config files with VSCode for the first time you need to make sure to enable the eslint.experimental.useFlatConfig setting

Configure TypeScript usage

You have to include additional metadata in your root eslint-config for this package:

module.exports = [
  // ...
  {
    files: ['**/*.ts'], // add all file-types you want to lint with TypeScript (ts, tsx, mts, cts)
    languageOptions: {
      parserOptions: {
        project: [
          './tsconfig.base.json', // path to your root tsconfig

          // for monorepos: define additional tsconfig files for different projects
          // see https://typescript-eslint.io/linting/typed-linting/monorepos/#one-tsconfigjson-per-package-and-an-optional-one-in-the-root
          './apps/*/tsconfig.json',
        ],
        tsconfigRootDir: __dirname,
      },
    },
  },
  // ...
];

Also you have to at least enable strictNullChecks in your tsconfig. It is recommended to use strict though, to enable all strict TypeScript checks:

{
  // ...
  "compilerOptions": {
    // ...

    "strict": true,
    // or
    "strictNullChecks": true
  }
}

License

This package is released under the MIT License.