@vumotions/codestandards
v1.0.1
Published
Shared code standards — ESLint, Prettier, Commitlint, Husky, lint-staged
Maintainers
Readme
@vumotions/codestandards
Opinionated code standards for TypeScript projects. One command to setup ESLint, Prettier, Commitlint, Husky, and lint-staged — ready to go.
Features
- Interactive CLI — detects existing configs, asks before replacing
- Shared configs — ESLint rules, Prettier formatting, Commitlint conventions
- Git hooks — Husky + lint-staged pre-configured for pre-commit and commit-msg
- Fully extensible — override any config in your project
- Zero manual setup — one command installs everything
Quick Start
npx @vumotions/codestandards initThe CLI will:
- Detect existing configs in your project
- Ask what to do with each (replace or skip)
- Scaffold config files that reference shared standards
- Optionally install all peer dependencies
- Initialize husky git hooks
CLI Reference
Usage: codestandards init [options]
Options:
--force Replace all existing configs without asking
--skip-existing Only setup tools that are not yet configured
-h, --help Display helpExamples
# Interactive (default) — asks for each existing config
npx @vumotions/codestandards init
# Replace all existing configs without asking
npx @vumotions/codestandards init --force
# Only setup tools that are not yet configured
npx @vumotions/codestandards init --skip-existingWhat Gets Created
| File | Tool | Description |
|------|------|-------------|
| eslint.config.mjs | ESLint | Flat config with TypeScript + Prettier integration |
| .prettierrc | Prettier | Formatting rules (no semi, single quotes, 120 width) |
| commitlint.config.ts | Commitlint | Conventional commit enforcement |
| .husky/commit-msg | Husky | Runs commitlint on commit messages |
| .husky/pre-commit | Husky | Runs lint-staged before commit |
| package.json | lint-staged | ESLint + Prettier on staged files |
Extending and Overriding
All configs can be extended or overridden in your project.
ESLint
// eslint.config.mjs
import eslint from '@eslint/js'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import { eslintConfig } from '@vumotions/codestandards'
export default tseslint.config(
{ ignores: ['eslint.config.mjs'] },
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: { ...globals.node },
sourceType: 'commonjs',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname
}
}
},
{ rules: eslintConfig.rules },
// Your overrides
{ rules: { 'no-console': 'off' } }
)Prettier
Override any value in .prettierrc:
{
"semi": true,
"printWidth": 100
}Or reference the shared config and override programmatically:
// prettier.config.mjs
import { prettierConfig } from '@vumotions/codestandards'
export default { ...prettierConfig, semi: true }Commitlint
// commitlint.config.ts
import type { UserConfig } from '@commitlint/types'
import { commitlintConfig } from '@vumotions/codestandards'
export default {
...commitlintConfig,
rules: {
...commitlintConfig.rules,
'scope-enum': [2, 'always', ['api', 'admin', 'storefront']]
}
} satisfies UserConfiglint-staged
Edit the lint-staged field in package.json:
{
"lint-staged": {
"src/**/*.ts": ["eslint --fix", "prettier --write"],
"**/*.{json,md,yml,yaml}": ["prettier --write"],
"**/*.css": ["prettier --write"]
}
}Shared Config Defaults
Prettier
| Option | Value |
|--------|-------|
| semi | false |
| singleQuote | true |
| printWidth | 120 |
| trailingComma | none |
| tabWidth | 2 |
| jsxSingleQuote | true |
| endOfLine | auto |
ESLint Rules
Formatting
| Rule | Value |
|------|-------|
| prettier/prettier | error (endOfLine: auto) |
Async Safety
| Rule | Value |
|------|-------|
| @typescript-eslint/no-floating-promises | error |
| @typescript-eslint/return-await | error (in-try-catch) |
| no-async-promise-executor | error |
Type Safety
| Rule | Value |
|------|-------|
| @typescript-eslint/no-explicit-any | warn |
| @typescript-eslint/no-non-null-assertion | warn |
| @typescript-eslint/prefer-nullish-coalescing | warn |
| @typescript-eslint/prefer-optional-chain | error |
| @typescript-eslint/only-throw-error | error |
Consistency
| Rule | Value |
|------|-------|
| @typescript-eslint/consistent-type-imports | error (type-imports) |
| @typescript-eslint/no-import-type-side-effects | error |
| @typescript-eslint/no-unused-vars | error (ignore _ prefix) |
Bug Prevention
| Rule | Value |
|------|-------|
| no-console | warn |
| no-debugger | error |
| eqeqeq | error (always) |
| no-template-curly-in-string | error |
Commitlint
Allowed commit types: feat, fix, chore, refactor, perf, test, docs, style, ci, revert
Peer Dependencies
Installed automatically when you choose "Install peer dependencies" during init:
| Package | Version |
|---------|---------|
| eslint | >= 9 |
| prettier | >= 3 |
| typescript-eslint | >= 8 |
| @eslint/js | >= 9 |
| eslint-config-prettier | >= 10 |
| eslint-plugin-prettier | >= 5 |
| globals | >= 16 |
| husky | >= 9 |
| lint-staged | >= 16 |
| @commitlint/cli | >= 19 |
All peer dependencies are marked as optional — the CLI only installs what you need.
License
MIT
