@futagoza/eslint-config-typescript
v17.1.0
Published
Futago-za Ryuu's ESLint configurations for TypeScript projects.
Maintainers
Readme
This package contains configuration files for ESLint v10+
This is a configuration file for ESLint that is used to lint my TypeScript projects.
NOTE 1: This configuration will only check for @typescript-eslint/* rules, therefore it is recommended to also use @futagoza/eslint-config-javascript or something similar alongside this configuration.
NOTE 2: This configuration require's TypeScript, but the peerDependencies field is set as "typescript": "*" so that any version of TypeScript supported by the Typescript-ESLint project can be used.
installation
$ npm i --save-dev @futagoza/eslint-config-typescriptusage
Put the following into your eslint configuration file:
import { defineConfig } from "eslint/config"
import tsConfig from "@futagoza/eslint-config-typescript"
// Used alongside other configurations:
export default [
// ...
tsConfig,
// ...
]
// Used as base configuration for other configurations:
export default defineConfig(
{
// ...
extends: [ tsConfig ],
// ...
},
)
// direct access to unprocessed config object
import { config as rawTypeScriptConfig } from "@futagoza/eslint-config-typescript"
// Do this if you aren't using any TypeScript files with these extensions: "*.cts", "*.mts", "*.ts", "*.tsx"
delete rawTypeScriptConfig.files
// direct access to Typescript-ESLint rules used in this config
import { configRules } from "@futagoza/eslint-config-typescript"configurations
A list of usable configurations:
@futagoza/eslint-config-typescript(default, extends the below auto-generated configurations)@futagoza/eslint-config-typescript/rules/deprecated.js@futagoza/eslint-config-typescript/rules/extension.js@futagoza/eslint-config-typescript/rules/general.js@futagoza/eslint-config-typescript/rules/inference.js@futagoza/eslint-config-typescript/rules/layout.js@futagoza/eslint-config-typescript/rules/problem.js@futagoza/eslint-config-typescript/rules/suggestion.js@futagoza/eslint-config-typescript/node.js(recommended default when using with @futagoza/eslint-config-node)
tsconfig.json
@typescript-eslint/eslint-plugin requires a tsconfig.json in the current working directory to function correctly, but I believe in zero-config, so what this configuration does is the following in order:
- Try to load
tsconfig.eslint.jsonfrom the current working directory - Try to load
tsconfig.jsonfrom the current working directory - Try to load (and fallback to creating it instead) a
tsconfig.jsonfrom your systems temporary directory
If the third choice is reached, this configuration will create a temporary tsconfig.json (based on the built-in tsconfig.default.json) in the user's temporary directory with path's linked to the current working directory so that it functions like a normal tsconfig.json (albeit slightly opinionated). This is a great alternative to the createDeafultProgram option provided by @typescript-eslint/eslint-plugin as it can have performance issues (e.g. I've had VS Code slow down).
license
Copyright © 2019+ Futago-za Ryuu Released under the MIT License, http://opensource.org/licenses/MIT
