@m14n/devkit
v2.0.0
Published
Shared developer toolkit with ESLint, Prettier, Commitlint, TypeScript, lint-staged and semantic-release configs for consistent project setup.
Maintainers
Readme
@m14n/devkit
Shared developer toolkit with ESLint, Prettier, Commitlint, TypeScript, lint-staged and semantic-release configs for consistent project setup.
Installation
npm i -D @m14n/devkitCompatibility
| Tool | Supported versions | | ---------- | ------------------ | | Node.js | 22+ | | ESLint | 10 | | TypeScript | 5.0 – 6.0 | | Prettier | 3 |
The TypeScript range is limited by what typescript-eslint supports.
Quick Reference
| Tool | Config path | Example usage |
| ---------------- | ------------------------------- | ------------------------------------------------------------------------------- |
| Commitlint | @m14n/devkit/commitlint | extends: ['@m14n/devkit/commitlint'] in commitlint.config.js |
| ESLint Base | @m14n/devkit/eslint-base | import base from '@m14n/devkit/eslint-base' in eslint.config.js. |
| ESLint Browser | @m14n/devkit/eslint-browser | import browser from '@m14n/devkit/eslint-browser' in eslint.config.js. |
| ESLint Node | @m14n/devkit/eslint-node | import node from '@m14n/devkit/eslint-node' |
| ESLint React | @m14n/devkit/eslint-react | import react from '@m14n/devkit/eslint-react' |
| ESLint TSDoc | @m14n/devkit/eslint-tsdoc | import tsdoc from '@m14n/devkit/eslint-tsdoc' |
| ESLint Test | @m14n/devkit/eslint-vitest | import test from '@m14n/devkit/eslint-vitest' |
| Prettier | @m14n/devkit/prettier | "prettier": "@m14n/devkit/prettier" in package.json |
| TypeScript | @m14n/devkit/tsconfig.*.json | "extends": "@m14n/devkit/tsconfig.node.json" in tsconfig.json |
| lint-staged | @m14n/devkit/lint-staged | export { default } from '@m14n/devkit/lint-staged' in lint-staged.config.js |
| semantic-release | @m14n/devkit/semantic-release | "extends": "@m14n/devkit/semantic-release" in .releaserc.json. |
Usage
ESLint
Pick the presets you need and compose them in your eslint.config.js (flat config, ESLint 10). Put base first.
// eslint.config.js
import base from '@m14n/devkit/eslint-base';
import node from '@m14n/devkit/eslint-node';
// If using Browser:
// import browser from '@m14n/devkit/eslint-browser';
// If using React:
// import react from '@m14n/devkit/eslint-react';
// If using TSDoc:
// import tsdoc from '@m14n/devkit/eslint-tsdoc';
// If using Vitest:
// import vitest from '@m14n/devkit/eslint-vitest';
export default [
...base,
...node,
// ...browser,
// ...react,
// ...tsdoc,
// ...vitest,
];Available ESLint presets
| Subpath | Purpose | Requires |
| ----------------------------- | --------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| @m14n/devkit/eslint-base | JS + type-checked TypeScript, import order, Prettier-compatible | Core peers |
| @m14n/devkit/eslint-browser | Browser globals | globals |
| @m14n/devkit/eslint-node | Node globals | globals |
| @m14n/devkit/eslint-react | React, Hooks (incl. React Compiler rules), JSX accessibility | @eslint-react/eslint-plugin, eslint-plugin-react-hooks, eslint-plugin-jsx-a11y-x |
| @m14n/devkit/eslint-tsdoc | TSDoc comment syntax | eslint-plugin-tsdoc |
| @m14n/devkit/eslint-vitest | Vitest globals in *.test.* / *.spec.* | none |
Good to know about eslint-base:
- It lints
.js,.mjs,.cjs,.jsx,.ts,.mts,.ctsand.tsxfiles, and ignoresdist/andcoverage/. - TypeScript files are type-checked through typescript-eslint's
project service, which finds the nearest
tsconfig.jsonfor each file. Every linted.tsfile must be included by a tsconfig. Config files such asvitest.config.tsare a common miss. - It ends with
eslint-config-prettier, so formatting is left to Prettier. Run Prettier on its own (for example via lint-staged), not through ESLint.
Good to know about eslint-react:
- It uses
@eslint-react/eslint-pluginfor React rules,eslint-plugin-react-hooksfor the Hooks and React Compiler rules, andeslint-plugin-jsx-a11y-xfor accessibility. - Accessibility rules keep the
jsx-a11y/*names, so existingeslint-disablecomments keep working. - It is ESM-only, because
@eslint-react/eslint-pluginis. Load it fromeslint.config.jsoreslint.config.mjs, not from a CommonJSeslint.config.cjs.
Prettier
Reference in your package.json:
{
"prettier": "@m14n/devkit/prettier"
}TypeScript
Pick the preset that matches your project:
| Preset | Use for |
| --------------------------------------- | ------------------------------------------------------ |
| @m14n/devkit/tsconfig.base.json | Base defaults, no runtime assumptions |
| @m14n/devkit/tsconfig.browser.json | Browser libraries (no JSX) |
| @m14n/devkit/tsconfig.decorators.json | Add-on: legacy decorators + metadata |
| @m14n/devkit/tsconfig.lib.json | Add-on: emit .d.ts, declaration maps and source maps |
| @m14n/devkit/tsconfig.node.json | Node (22+) libraries or CLIs |
| @m14n/devkit/tsconfig.react.json | React libraries (with JSX) |
| @m14n/devkit/tsconfig.strict.json | Add-on: stricter typing checks |
Example (tsconfig.json):
{
"extends": "@m14n/devkit/tsconfig.node.json",
"compilerOptions": {
"typeRoots": ["node_modules/@types", "src/@types"]
},
"exclude": ["dist", "node_modules"],
"include": ["./src/**/*.ts"]
}The strict, decorators and lib presets are add-ons. Combine them with a runtime preset using an extends array
(TypeScript 5+). Later entries win:
{
"extends": ["@m14n/devkit/tsconfig.node.json", "@m14n/devkit/tsconfig.strict.json", "@m14n/devkit/tsconfig.lib.json"]
}Commitlint
Add a commitlint.config.js:
// commitlint.config.js
export default {
extends: ['@m14n/devkit/commitlint'],
};If your project is CommonJS (no "type": "module" in package.json), name the file commitlint.config.mjs.
lint-staged (optional, recommended)
Use the provided lint-staged config to run Prettier, ESLint, and Markdownlint on staged files.
Create a .lintstagedrc.js in your project root:
// .lintstagedrc.js
export { default } from '@m14n/devkit/lint-staged';semantic-release (optional, recommended)
Use the shared config in your .releaserc.json:
{
"extends": "@m14n/devkit/semantic-release"
}What to install?
Install only what you actually use. Copy the block(s) that match your project.
Core (ESLint base + Prettier + TypeScript)
npm i -D @eslint/js \
@typescript-eslint/parser \
@typescript-eslint/eslint-plugin \
eslint \
eslint-config-prettier \
eslint-plugin-import-x \
prettier typescriptESLint Node / Browser presets
npm i -D globalsESLint TSDoc preset
npm i -D eslint-plugin-tsdocESLint React preset
npm i -D @eslint-react/eslint-plugin \
eslint-plugin-jsx-a11y-x \
eslint-plugin-react-hooksESLint Test (Vitest) preset
The preset itself needs no extra packages. It only declares the Vitest globals for *.test.* and *.spec.* files.
For type-checking, either import from 'vitest' in your tests or add "types": ["node", "vitest/globals"] to the
tsconfig that covers them.
Prettier
npm i -D prettierCommitlint preset
npm i -D @commitlint/config-conventional \
commitlintlint-staged (optional, recommended)
npm i -D lint-staged \
markdownlint-clisemantic-release (optional)
npm i -D semantic-release \
@semantic-release/commit-analyzer \
@semantic-release/github \
@semantic-release/npm \
@semantic-release/release-notes-generatorGit hooks (Husky)
To keep code quality checks consistent, we recommend using Husky to run Commitlint, lint-staged, and a final check before pushing.
Install and initialize Husky (v9) once in your repo:
npm i -D husky
npx husky initThis creates a .husky/ folder and adds a "prepare": "husky" script to your package.json. Then write the hooks:
echo 'npx --no -- commitlint --edit "$1"' > .husky/commit-msg
echo 'npx lint-staged' > .husky/pre-commit
echo 'npm run check' > .husky/pre-pushThe pre-push hook expects a check script in your package.json (for example type-check + build). Change it to
whatever your project uses.
Commit the .husky/ folder so your team shares the same hooks:
git add .husky
git commit -m "chore: set up husky hooks"From now on:
commit-msg→ validates commit messages with Commitlintpre-commit→ runs Prettier + ESLint + Markdownlint on staged files via lint-stagedpre-push→ runsnpm run check
Upgrading
Release notes for every version are on GitHub Releases.
From 1.x to 2.0
ESLint 10 is required. ESLint 9 is no longer supported upstream. Update
eslintand@eslint/jsto 10:npm i -D eslint@10 @eslint/js@10.The React preset uses maintained plugins that support ESLint 10. Swap the plugins:
npm rm eslint-plugin-react eslint-plugin-jsx-a11y npm i -D @eslint-react/eslint-plugin eslint-plugin-jsx-a11y-xreact/*rules are replaced by@eslint-react/*rules. Update anyeslint-disablecomments and rule overrides that name them (for examplereact/jsx-keyis now@eslint-react/no-missing-key).jsx-a11y/*andreact-hooks/*rule names don't change. React version detection now readssettings['react-x']instead ofsettings.react.@m14n/devkit/eslint-reactcan no longer be loaded withrequire. Use an ESM ESLint config (eslint.config.jsor.mjs).
From 0.x to 1.0
eslint-plugin-import→eslint-plugin-import-x. Runnpm rm eslint-plugin-import && npm i -D eslint-plugin-import-x. Rule names stayimport/*, so existingeslint-disablecomments keep working.eslint-plugin-prettieris no longer used. Remove it and run Prettier on its own.eslint-basenow includeseslint-config-prettier.eslint-basenow lints JavaScript files too and uses typescript-eslint's project service instead ofparserOptions.project: './tsconfig.json'. Make sure every linted.tsfile is included by a tsconfig.eslint-reactnow enables the recommended rule sets ofeslint-plugin-react,eslint-plugin-react-hooksandeslint-plugin-jsx-a11y. Expect new findings.tsconfig.base.jsonno longer setsdeclaration,declarationMap,sourceMaporimportHelpers. Libraries should add@m14n/devkit/tsconfig.lib.jsonto theirextends.- TypeScript 6.1+ and 7 aren't supported yet (typescript-eslint supports up to 6.0).
Development
npm install # also installs the Git hooks (Husky)
npm run lint # Prettier + ESLint on this repo, using the presets it ships
npm run check # type-check, build and ES-version check of dist/
npm test # build, then smoke-test every export and presetnpm testruns test/smoke.test.js against the built package. It lints the files intest/fixtures/with all ESLint presets combined and checks which rules fire. When you change a preset, add or update a fixture there.- Git hooks:
commit-msgruns commitlint,pre-commitruns lint-staged, andpre-pushrunscheckandtest. - CI runs
checkandteston every pull request and on pushes todevelop. Merging tomainpublishes a release via semantic-release, so commit messages must follow Conventional Commits.
License
MIT
For issues and contributions, see GitHub.
