@kitschpatrol/shared-config 4.3.2 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +36 -36
- package/license.txt +21 -0
- package/package.json +10 -9
- package/readme.md +211 -0
package/license.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-2024 Eric Mika
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/shared-config",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Linting and formatting for web projects.",
|
|
6
6
|
"repository": {
|
|
@@ -33,23 +33,24 @@
|
|
|
33
33
|
"cosmiconfig": "^9.0.0",
|
|
34
34
|
"execa": "^8.0.1",
|
|
35
35
|
"fs-extra": "^11.2.0",
|
|
36
|
-
"@kitschpatrol/cspell-config": "4.
|
|
37
|
-
"@kitschpatrol/
|
|
38
|
-
"@kitschpatrol/
|
|
39
|
-
"@kitschpatrol/
|
|
40
|
-
"@kitschpatrol/repo-config": "4.
|
|
41
|
-
"@kitschpatrol/
|
|
36
|
+
"@kitschpatrol/cspell-config": "4.4.0",
|
|
37
|
+
"@kitschpatrol/eslint-config": "4.4.0",
|
|
38
|
+
"@kitschpatrol/mdat-config": "4.4.0",
|
|
39
|
+
"@kitschpatrol/prettier-config": "4.4.0",
|
|
40
|
+
"@kitschpatrol/repo-config": "4.4.0",
|
|
41
|
+
"@kitschpatrol/remark-config": "4.4.0",
|
|
42
|
+
"@kitschpatrol/stylelint-config": "4.4.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"camelcase": "^8.0.0",
|
|
45
46
|
"chalk": "^5.3.0",
|
|
46
|
-
"globby": "^14.0.
|
|
47
|
+
"globby": "^14.0.1"
|
|
47
48
|
},
|
|
48
49
|
"publishConfig": {
|
|
49
50
|
"access": "public"
|
|
50
51
|
},
|
|
51
52
|
"scripts": {
|
|
52
|
-
"build": "./scripts/capability-generator.ts && ../../scripts/build.ts",
|
|
53
|
+
"build": "./scripts/capability-generator.ts && ../../scripts/build.ts && mdat readme",
|
|
53
54
|
"clean": "pnpm run bin-restore && git clean -fdX",
|
|
54
55
|
"cli": "node ./bin/cli.js"
|
|
55
56
|
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
<!--+ Warning: Content in HTML comment blocks generated by mdat on 2024-02-20 +-->
|
|
2
|
+
|
|
3
|
+
<!-- header [{ prefix: "🔬 " }] -->
|
|
4
|
+
|
|
5
|
+
# 🔬 @kitschpatrol/shared-config
|
|
6
|
+
|
|
7
|
+
[](https://npmjs.com/package/@kitschpatrol/shared-config)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
**Linting and formatting for web projects.**
|
|
11
|
+
|
|
12
|
+
<!-- /header -->
|
|
13
|
+
|
|
14
|
+
<!-- table-of-contents { maxDepth: 2 } -->
|
|
15
|
+
|
|
16
|
+
## Table of contents
|
|
17
|
+
|
|
18
|
+
- [Overview](#overview)
|
|
19
|
+
- [Getting started](#getting-started)
|
|
20
|
+
- [Usage](#usage)
|
|
21
|
+
- [Implementation notes](#implementation-notes)
|
|
22
|
+
- [Development notes](#development-notes)
|
|
23
|
+
- [Background](#background)
|
|
24
|
+
- [License](#license)
|
|
25
|
+
|
|
26
|
+
<!-- /table-of-contents -->
|
|
27
|
+
|
|
28
|
+
## Overview
|
|
29
|
+
|
|
30
|
+
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.
|
|
31
|
+
|
|
32
|
+
It takes care of dependencies and configurations for the following tools:
|
|
33
|
+
|
|
34
|
+
- [CSpell](https://cspell.org)
|
|
35
|
+
- [ESLint](https://eslint.org) (including Svelte, Astro, and TypeScript support)
|
|
36
|
+
- [mdat](https://github.com/kitschpatrol/mdat)
|
|
37
|
+
- [Prettier](https://prettier.io) (including a bunch of extra plugins)
|
|
38
|
+
- [remarklint](https://github.com/remarkjs/remark-lint)
|
|
39
|
+
- [Stylelint](https://stylelint.io)
|
|
40
|
+
- [VS Code](https://code.visualstudio.com) (extension recommendations and extension settings)
|
|
41
|
+
- Minimal repo boilerplate (`.npmrc`, `.gitignore`, etc.)
|
|
42
|
+
|
|
43
|
+
All of the above may be added to a project as a single dependency. All may be run 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.
|
|
44
|
+
|
|
45
|
+
## Getting started
|
|
46
|
+
|
|
47
|
+
### Dependencies
|
|
48
|
+
|
|
49
|
+
Node 18+ and pnpm are required. It probably works with NPM and yarn, but I haven't tested it.
|
|
50
|
+
|
|
51
|
+
### Installation
|
|
52
|
+
|
|
53
|
+
#### Quick start from scratch:
|
|
54
|
+
|
|
55
|
+
Bootstrap a new project and open in VS Code:
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
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 .
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### Quick add to an existing project:
|
|
62
|
+
|
|
63
|
+
This might overwrite certain config files, so commit first:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
pnpm dlx @kitschpatrol/repo-config --init && pnpm i && pnpm add -D @kitschpatrol/shared-config && pnpm shared-config --init
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Step-by-step:
|
|
70
|
+
|
|
71
|
+
1. Install the requisite `.npmrc`:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
pnpm dlx @kitschpatrol/repo-config --init
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
2. Install the package:
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
pnpm add -D @kitschpatrol/shared-config
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
3. Add default config files for all the tools to your project root:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
pnpm shared-config --init
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
4. Add helper scripts to your `package.json`:
|
|
90
|
+
|
|
91
|
+
These work a bit like [npm-run-all](https://github.com/mysticatea/npm-run-all) to invoke all of the bundled tools.
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
"scripts": {
|
|
95
|
+
"format": "shared-config --fix",
|
|
96
|
+
"lint": "shared-config --lint",
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
> \[!NOTE]\
|
|
101
|
+
> Prettier formatting for Ruby requires some extra legwork to configure, see [`the @kitschpatrol/prettier-config` package readme](https://github.com/kitschpatrol/shared-config/blob/main/packages/prettier-config/readme.md) for more details.
|
|
102
|
+
|
|
103
|
+
## Usage
|
|
104
|
+
|
|
105
|
+
Various VS Code plugins should "just work".
|
|
106
|
+
|
|
107
|
+
To lint your entire project, after configuring the `package.json` as shown above:
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
pnpm run lint
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
To run all of the tools in a _potentially destructive_ "fix" capacity:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
pnpm run format
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### CLI
|
|
120
|
+
|
|
121
|
+
<!-- cli-help cliCommand: 'shared-config' -->
|
|
122
|
+
|
|
123
|
+
#### Command: `shared-config`
|
|
124
|
+
|
|
125
|
+
Linting and formatting for web projects.
|
|
126
|
+
|
|
127
|
+
Usage:
|
|
128
|
+
|
|
129
|
+
```txt
|
|
130
|
+
shared-config [<file|glob> ...]
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
| Option | Alias | Argument | Description |
|
|
134
|
+
| ---------------- | ----- | -------- | ---------------------------------------------------------------- |
|
|
135
|
+
| `--check` | `-c` | | Check for and report issues. Same as shared-config. |
|
|
136
|
+
| `--init` | `-i` | | Initialize by copying starter config files to your project root. |
|
|
137
|
+
| `--print-config` | `-p` | `<path>` | Print the effective configuration at a certain path. |
|
|
138
|
+
| `--fix` | `-f` | | Fix all auto-fixable issues, and report the un-fixable. |
|
|
139
|
+
| `--help` | `-h` | | Print this help info. |
|
|
140
|
+
| `--version` | `-v` | | Print the package version. |
|
|
141
|
+
|
|
142
|
+
<!-- /cli-help -->
|
|
143
|
+
|
|
144
|
+
The `@kitschpatrol/shared-config` package aggregates integration and invocation of the other tool-specific packages in this monorepo, each of which is documented in its respective readme, linked below:
|
|
145
|
+
|
|
146
|
+
- [`@kitschpatrol/cspell-config`](/packages/cspell-config/readme.md)
|
|
147
|
+
- [`@kitschpatrol/eslint-config`](/packages/eslint-config/readme.md)
|
|
148
|
+
- [`@kitschpatrol/mdat-config`](/packages/mdat-config/readme.md)
|
|
149
|
+
- [`@kitschpatrol/prettier-config`](/packages/prettier-config/readme.md)
|
|
150
|
+
- [`@kitschpatrol/remark-config`](/packages/remark-config/readme.md)
|
|
151
|
+
- [`@kitschpatrol/repo-config`](/packages/repo-config/readme.md)
|
|
152
|
+
- [`@kitschpatrol/stylelint-config`](/packages/stylelint-config/readme.md)
|
|
153
|
+
|
|
154
|
+
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`.
|
|
155
|
+
|
|
156
|
+
## Implementation notes
|
|
157
|
+
|
|
158
|
+
### Package architecture
|
|
159
|
+
|
|
160
|
+
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.
|
|
161
|
+
|
|
162
|
+
The monorepo must be kept intact, as the sub-packages depend on scripts in the parent during build.
|
|
163
|
+
|
|
164
|
+
### Hoisting caveats
|
|
165
|
+
|
|
166
|
+
Pnpm considers module hoisting harmful, and I tend to agree, but certain exceptions are carved out as necessary:
|
|
167
|
+
|
|
168
|
+
- CSpell, markdownlint, mdat, ESLint, and Prettier all need to be hoisted via `public-hoist-pattern` to be accessible in `pnpm exec` scripts and to VS Code plugins.
|
|
169
|
+
|
|
170
|
+
- Even basic file-only packages like `repo-config` seem to need to be hoisted via for their bin scripts to be accessible via `pnpm exec`
|
|
171
|
+
|
|
172
|
+
- `prettier` and `eslint` packages are [hoisted by default](https://pnpm.io/npmrc#public-hoist-pattern) in `pnpm`
|
|
173
|
+
|
|
174
|
+
## Development notes
|
|
175
|
+
|
|
176
|
+
The repo uses placeholders for the bin script for each tool to avoid circular dependency issues during `pnpm install`.
|
|
177
|
+
|
|
178
|
+
To tell git to ignore changes to the placeholders, run `pnpm run bin-ignore`.
|
|
179
|
+
|
|
180
|
+
For local development via `pnpm`, use `file:` dependency protocol instead of `link:`
|
|
181
|
+
|
|
182
|
+
Something to investigate: An [approach](https://github.com/antfu/eslint-config#vs-code-support-auto-fix) to ignoring style rules in VS Code, and possibly migrate all style to
|
|
183
|
+
|
|
184
|
+
## Background
|
|
185
|
+
|
|
186
|
+
### Motivation
|
|
187
|
+
|
|
188
|
+
[`xo`](https://github.com/xojs/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.
|
|
189
|
+
|
|
190
|
+
### Similar projects
|
|
191
|
+
|
|
192
|
+
- [1stG/configs](https://github.com/1stG/configs)
|
|
193
|
+
- [antfu/eslint-config](https://github.com/antfu/eslint-config)
|
|
194
|
+
- [awesome-eslint](https://github.com/dustinspecker/awesome-eslint)
|
|
195
|
+
- [lass](https://lass.js.org) (xo etc.)
|
|
196
|
+
- [routine-npm-packages](https://github.com/kachkaev/routine-npm-packages) and [example](https://github.com/kachkaev/website)
|
|
197
|
+
- [sheriff](https://www.eslint-config-sheriff.dev)
|
|
198
|
+
- [standard](https://standardjs.com)
|
|
199
|
+
- [trunk](https://trunk.io)
|
|
200
|
+
- [xo](https://github.com/xojs/xo)
|
|
201
|
+
- [vscode-file-nesting-config](https://github.com/antfu/vscode-file-nesting-config)
|
|
202
|
+
- [NullVoxPopuli/eslint-configs](https://github.com/NullVoxPopuli/eslint-configs)
|
|
203
|
+
- [tsconfig/bases](https://github.com/tsconfig/bases/tree/main)
|
|
204
|
+
|
|
205
|
+
<!-- license -->
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
[MIT](license.txt) © Eric Mika
|
|
210
|
+
|
|
211
|
+
<!-- /license -->
|