@mwlica/eslint
v1.0.4
Published
strict, premade, opinionated ESLint configuration for TypeScript projects
Downloads
166
Readme
@mwlica/eslint package provides a premade, opinionated ESLint configuration for TypeScript projects.
This package was primarily made for my own projects:
Setup
npm install --save-dev @mwlica/eslint eslint typescript typescript-eslintbun i -D @mwlica/eslint eslint typescript typescript-eslintUsage
Create
tsconfig.json:Create a
tsconfig.jsonfile in the root of your project. You can start with a basic configuration like this:{ "compilerOptions": { "target": "ESNext", "module": "NodeNext", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true } }Create
tsconfig.eslint.json:Create a
tsconfig.eslint.jsonfile in your project root. This file extends your maintsconfig.jsonand is specifically for ESLint.{ "extends": "./tsconfig.json", "compilerOptions": { "exactOptionalPropertyTypes": true, "module": "NodeNext", "typeRoots": [ "./node_modules/@eslint-types", "./node_modules/@types" ], "noEmit": true, "allowJs": true, "checkJs": true, "target": "ESNext" }, "include": [ "src/**/*", "tests/**/*", "scripts/**/*" ] }Create
eslint.config.mjs:Create an
eslint.config.mjsfile in your project root to configure ESLint.import { base, recommended, strict } from '@mwlica/eslint'; import tseslint from "typescript-eslint"; export default tseslint.config( base, recommended, strict );You can apply specific configurations to different parts of your project. For example, you might want to use a different set of rules for your tests or scripts.
import { base, recommended, strict } from '@mwlica/eslint'; import tseslint from "typescript-eslint"; export default tseslint.config( base, recommended, tseslint.config(strict, { ignores: ['scripts/**/*'] }) );
Configurations
This package exports three configurations:
base: The base configuration to make eslint work with this package.recommended: A recommended set of rules that builds on the base configuration.strict: The strictest set of rules; this might not be suitable for your project.
You can use them in any combination you like. In the example above, we are using all three, but you can customize it to your needs. The ignores option in the example shows how to exclude files or directories from specific rule sets.
