@nelsonlaidev/eslint-config
v5.0.0
Published
Nelson Lai's ESLint config preset
Downloads
458
Readme
@nelsonlaidev/eslint-config
Personal ESLint configurations for Nelson Lai projects.
Installation
npm i -D @nelsonlaidev/eslint-configUsage
Create an eslint.config.ts file. The base configuration includes the shared JavaScript, TypeScript, accessibility, import, and code-quality rules:
import { defineConfig } from '@nelsonlaidev/eslint-config'
export default defineConfig()Pass project-specific flat configuration objects directly to defineConfig():
import { defineConfig } from '@nelsonlaidev/eslint-config'
export default defineConfig({
files: ['scripts/**/*.ts'],
rules: {
'no-console': 'off',
},
})Optional presets
Framework and tool integrations are explicit. Import the presets you need and pass them in the order they should be applied:
import { defineConfig, nextjs, playwright, prettier, react, tailwindcss, vitest } from '@nelsonlaidev/eslint-config'
export default defineConfig(
vitest({
files: ['**/*.test.{js,jsx,ts,tsx}'],
}),
playwright({
files: ['**/e2e/**/*.test.{js,jsx,ts,tsx}'],
}),
react(),
nextjs(),
tailwindcss({
settings: {
'better-tailwindcss': {
entryPoint: './src/globals.css',
},
},
}),
// Keep Prettier last so it can disable conflicting rules.
prettier(),
)Available optional presets are react(), nextjs(), tailwindcss(), vitest(), playwright(), and prettier().
Each preset accepts an ESLint flat configuration override. Arrays are replaced, nested objects are merged, and plugin maps are combined:
export default defineConfig(
react({
rules: {
'@eslint-react/immutability': 'warn',
},
}),
)When enabling Vitest or Playwright, provide files unless you intentionally want their rules to apply to every linted file.
Base options
Use defineConfig.withOptions() only when changing options consumed while the base configuration is created:
import { defineConfig, react } from '@nelsonlaidev/eslint-config'
export default defineConfig.withOptions(
{
ignores: ['coverage/**', 'generated/**'],
typescriptResolver: {
alwaysTryTypes: true,
bun: true,
project: ['packages/foo/tsconfig.json'],
},
},
react(),
)The available base options are:
type ConfigOptions = {
ignores?: string[]
typescriptResolver?: import('eslint-import-resolver-typescript').TypeScriptResolverOptions
}By default, the TypeScript import resolver scans these locations:
{ts,js}config.jsonapps/**/{ts,js}config.jsonpackages/**/{ts,js}config.json
Refer to the eslint-import-resolver-typescript documentation for all resolver options.
