@chanyuxi/eslint-waltz
v1.3.2
Published
A composable ESLint flat config for JavaScript, TypeScript, JSONC, imports, React, Tailwind CSS, Perfectionist, and Vitest.
Downloads
1,472
Maintainers
Readme
@chanyuxi/eslint-waltz
Composable ESLint flat config for JavaScript, TypeScript, JSONC, React, Tailwind CSS, Perfectionist, and Vitest.
Requires Node.js >=20.19.0.
Install
Install the package, ESLint, and the peer dependencies used by the default configuration:
pnpm add -D @chanyuxi/eslint-waltz eslint eslint-plugin-jsonc eslint-plugin-import-x eslint-plugin-perfectionist jsonc-eslint-parser@eslint/js, @stylistic/eslint-plugin, globals, and jsonc-parser are included automatically.
Install peers only for the optional modules you enable:
# TypeScript
pnpm add -D typescript-eslint
# React
pnpm add -D eslint-plugin-react-x eslint-plugin-react-debug eslint-plugin-react-dom eslint-plugin-react-hooks-extra eslint-plugin-react-naming-convention eslint-plugin-react-web-api
# Tailwind CSS
pnpm add -D eslint-plugin-tailwindcss tailwindcss
# .gitignore support
pnpm add -D eslint-config-flat-gitignore
# Vitest
pnpm add -D @vitest/eslint-plugin vitestUsage
// eslint.config.ts
import waltz from '@chanyuxi/eslint-waltz'
export default waltz({
ts: true,
react: true,
})Enabled by default:
- JavaScript and stylistic rules
- JSONC rules
- import validation
- Perfectionist with
recommended-alphabetical
Optional: ts, react, tailwindcss, gitignore, and vitest.
More options are documented in the exported TypeScript types.
The potentially expensive module-resolution rules are disabled by default. Enable them explicitly when your project needs them:
export default waltz({
imports: {
overrides: {
'imports/named': 'error',
'imports/namespace': 'error',
},
},
})TypeScript file scope
When ts.files is provided, it is the maximum TypeScript scope used by the
other modules that automatically include TypeScript files. JavaScript files
keep their normal scope, and a module's own files option can override this
limit. Vitest additionally intersects its test-file patterns with this scope.
export default waltz({
ts: { files: ['src/**/*.ts'] },
react: true,
})VS Code synchronization
Run this command from your project root to enable ESLint fix-on-save settings
while preserving existing .vscode/settings.json values and comments:
npx eslint-waltz sync-vscodeReact plugin settings can be customized when needed:
export default waltz({
react: {
settings: {
'react-x': { importSource: 'preact' },
},
},
})