A collection of shared configurations for various linters and formatting tools. All managed as a single dependency, and invoked via a single command.
This project attempts to consolidate most of the configuration and tooling shared by my open-source and internal TypeScript / Node based projects into a single dependency.
It takes care of dependencies and configurations for the following tools:
- CSpell
- ESLint (including Svelte, Astro, and TypeScript support)
- mdat
- Prettier (including a bunch of extra plugins)
- remarklint
- Stylelint
- VS Code (extension recommendations and extension settings)
- Minimal repo boilerplate (
.npmrc
,.gitignore
, etc.)
This readme is for the @kitschpatrol/shared-config
package, which depends on a number of tool-specific packages included in the kitschpatrol/shared-config
monorepo on GitHub, each of which is documented in its respective readme, linked below:
@kitschpatrol/cspell-config
@kitschpatrol/eslint-config
@kitschpatrol/mdat-config
@kitschpatrol/prettier-config
@kitschpatrol/remark-config
@kitschpatrol/repo-config
@kitschpatrol/stylelint-config
Any of these may be installed and run on their own via CLI if desired. However, in general, the idea is to use @kitschpatrol/shared-config
to easily run them all simultaneously over a repo with a single command with options to either check or (where possible) fix problems, with output aggregated into a single report.
Node 18+ and pnpm are required. It probably works with NPM and yarn, but I haven't tested it.
Bootstrap a new project and open in VS Code:
git init && pnpm init && pnpm pkg set type="module" && pnpm dlx @kitschpatrol/repo-config --init && pnpm add -D @kitschpatrol/shared-config && pnpm shared-config --init && pnpm i && code .
This might overwrite certain config files, so commit first:
pnpm dlx @kitschpatrol/repo-config --init && pnpm i && pnpm add -D @kitschpatrol/shared-config && pnpm shared-config --init
-
Install the requisite
.npmrc
:pnpm dlx @kitschpatrol/repo-config --init
-
Install the package:
pnpm add -D @kitschpatrol/shared-config
-
Add default config files for all the tools to your project root:
pnpm shared-config --init
-
Add helper scripts to your
package.json
:These work a bit like npm-run-all to invoke all of the bundled tools.
"scripts": { "format": "shared-config --fix", "lint": "shared-config --lint", }
[!NOTE]
Prettier formatting for Ruby requires some extra legwork to configure, seethe @kitschpatrol/prettier-config
package readme for more details.
Various VS Code plugins should "just work".
To lint your entire project, after configuring the package.json
as shown above:
pnpm run lint
To run all of the tools in a potentially destructive "fix" capacity:
pnpm run format
A collection of shared configurations for various linters and formatting tools. All managed as a single dependency, and invoked via a single command.
Usage:
shared-config [<file|glob> ...]
Option | Argument | Description |
---|---|---|
--check -c |
Check for and report issues. Same as shared-config . |
|
--init -i |
Initialize by copying starter config files to your project root. | |
--print-config -p |
<path> |
Print the effective configuration at a certain path. |
--fix -f |
Fix all auto-fixable issues, and report the un-fixable. | |
--help -h |
Print this help info. | |
--version -v |
Print the package version. |
Recall that the @kitschpatrol/shared-config
package aggregates integration and invocation of the other tool-specific packages in this monorepo. Running a cli command on shared-config
effectively runs the same command against all the tool-specific packages.
Each package has a simple /src/cli.ts
file which defines the behavior of its eponymous binary. The build step turns these into node "binary" scripts, providing default implementations where feasible.
The monorepo must be kept intact, as the sub-packages depend on scripts in the parent during build.
Pnpm considers module hoisting harmful, and I tend to agree, but certain exceptions are carved out as necessary:
-
CSpell, remark, mdat, ESLint, and Prettier all need to be hoisted via
public-hoist-pattern
to be accessible inpnpm exec
scripts and to VS Code plugins. -
Even basic file-only packages like
repo-config
seem to need to be hoisted via for their bin scripts to be accessible viapnpm exec
-
prettier
andeslint
packages are hoisted by default inpnpm
The repo uses placeholders for the bin script for each tool to avoid circular dependency issues during pnpm install
.
To tell git to ignore changes to the placeholders, run pnpm run bin-ignore
.
For local development via pnpm
, use file:
dependency protocol instead of link:
Something to investigate: An approach to ignoring style rules in VS Code, and possibly migrate all style to
xo
is really, really close to what I'm after here, but I wanted a few extra tools and preferred to use "first party" VS Code plugins where possible.
- 1stG/configs
- antfu/eslint-config
- awesome-eslint
- lass (xo etc.)
- routine-npm-packages and example
- sheriff
- standard
- trunk
- xo
- vscode-file-nesting-config
- NullVoxPopuli/eslint-configs
- tsconfig/bases
- eslint-config-current-thing (Smart!)
MIT © Eric Mika