@genji-ball-team/style
v1.0.0
Published
The Genji Ball coding style: ESLint and Prettier config, the file-size check and the pre-commit hook
Readme
Genji-Ball-Team/.github
Team-wide files for every Genji-Ball-Team repo:
- STYLE.md: the coding style for TypeScript, Rust and OverPy.
- CONTRIBUTING.md: shown as the contributing guide in every repo of the org.
@genji-ball-team/style: the shared ESLint and Prettier config, the file-size check and the pre-commit hook, published to npm from this repo.
Using the package
npm install --save-dev @genji-ball-team/style eslint prettier typescriptpackage.json:
{
"prettier": "@genji-ball-team/style/prettier",
"scripts": {
"prepare": "gb-hooks install",
"lint": "prettier --check . && eslint . && gb-size"
}
}eslint.config.js at the repo root, next to the tsconfig.json:
import { styleConfig } from "@genji-ball-team/style/eslint";
export default styleConfig({ root: import.meta.dirname, ignores: ["dist/"] });gb-sizechecks the tracked Rust and OverPy files against the size limit (ESLintmax-linescovers TS and JS). In Rust, a file's#[cfg(test)]part counts against the test limit..size-exceptionsat the repo root lists the files already over the limit, one path per line, each with its split issue in a#comment. Both ESLint andgb-sizeread it, andgb-sizefails when a listed file is gone or under the limit, so the list only shrinks.gb-hooks installwrites the pre-commit hook (it leaves an existing hook of someone else's alone, and does nothing in CI). The hook runs Prettier, ESLint andgb-sizeon the staged files, each only if the repo has it.git commit --no-verifyskips it once.- Line endings: add a
.gitattributeswith* text=auto eol=lf. Prettier wants LF, and without it a Windows checkout (CRLF) failsprettier --check. - Rust: copy
rust/clippy.tomlnext toCargo.toml, and pasterust/lints.tomlinto it. - OverPy (CE): only
gb-sizeand the hook; leave out ESLint, Prettier and TypeScript.
Working on it
npm ci
npm run check # typecheck (tsc on the JS), Prettier, ESLint, size check, node --testThe package is plain JavaScript with JSDoc types, so ESLint and Node load it without a build.
Make a release
- Bump
versioninpackage.jsonin its PR (a rule that fails more code is a major version). - After the merge, tag the merge commit and push the tag:
git tag v1.0.0 && git push origin v1.0.0. The Release workflow checks and publishes it to npm. - Write the GitHub release notes by hand:
gh release create v1.0.0 --notes-file <notes>. Say what changed and what repos must change.
