@kitschpatrol/prettier-config 4.7.11 → 5.0.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.
@@ -0,0 +1,15 @@
1
+ import type { Config as PrettierConfig } from 'prettier';
2
+ declare const sharedPrettierConfig: PrettierConfig;
3
+ /**
4
+ * **\@Kitschpatrol's Shared Prettier Configuration**
5
+ * @see [@kitschpatrol/prettier-config](https://github.com/kitschpatrol/shared-config/tree/main/packages/prettier-config)
6
+ * @see [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config)
7
+ * @example
8
+ * ```js
9
+ * export default prettierConfig({
10
+ * printWidth: 120,
11
+ * })
12
+ * ```
13
+ */
14
+ export declare function prettierConfig(config?: PrettierConfig): PrettierConfig;
15
+ export default sharedPrettierConfig;
package/dist/index.js ADDED
@@ -0,0 +1,72 @@
1
+ import { deepmerge } from 'deepmerge-ts';
2
+ import { homedir } from 'node:os';
3
+ // export { commandDefinition } from './command.js'
4
+ const sharedPrettierConfig = {
5
+ bracketSpacing: true,
6
+ overrides: [
7
+ {
8
+ files: ['*.md', '*.mdx', '*.yml'],
9
+ options: {
10
+ useTabs: false,
11
+ },
12
+ },
13
+ {
14
+ files: '*.astro',
15
+ options: {
16
+ parser: 'astro',
17
+ plugins: ['prettier-plugin-astro'],
18
+ },
19
+ },
20
+ {
21
+ files: '*.svelte',
22
+ options: {
23
+ parser: 'svelte',
24
+ plugins: ['prettier-plugin-svelte'],
25
+ },
26
+ },
27
+ {
28
+ files: '*.rb',
29
+ options: {
30
+ rubyExecutablePath: `${homedir()}/.rbenv/shims/ruby`,
31
+ },
32
+ },
33
+ {
34
+ files: ['*rc', '*ignore', '*.sh', '*.zsh', '*.bash', '*.fish'],
35
+ options: {
36
+ parser: 'sh',
37
+ plugins: ['prettier-plugin-sh'],
38
+ },
39
+ },
40
+ ],
41
+ plugins: [
42
+ '@prettier/plugin-php',
43
+ '@prettier/plugin-ruby',
44
+ '@prettier/plugin-xml',
45
+ 'prettier-plugin-packagejson',
46
+ 'prettier-plugin-sh',
47
+ 'prettier-plugin-sql',
48
+ 'prettier-plugin-tailwindcss',
49
+ 'prettier-plugin-toml',
50
+ ],
51
+ printWidth: 100,
52
+ semi: false,
53
+ singleQuote: true,
54
+ tabWidth: 2,
55
+ trailingComma: 'all',
56
+ useTabs: true,
57
+ };
58
+ /**
59
+ * **\@Kitschpatrol's Shared Prettier Configuration**
60
+ * @see [@kitschpatrol/prettier-config](https://github.com/kitschpatrol/shared-config/tree/main/packages/prettier-config)
61
+ * @see [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config)
62
+ * @example
63
+ * ```js
64
+ * export default prettierConfig({
65
+ * printWidth: 120,
66
+ * })
67
+ * ```
68
+ */
69
+ export function prettierConfig(config) {
70
+ return deepmerge(sharedPrettierConfig, config);
71
+ }
72
+ export default sharedPrettierConfig;
@@ -1,20 +1,5 @@
1
1
  # Prettier Ignore
2
- # Does not inherit from .gitignore
3
-
4
- # @kitschpatrol/repo-config boilerplate
5
- .astro/
6
- .DS_Store
7
- .svelte-kit/
8
- {tmp,temp}/
9
- **/*.min.js
10
- /scratch/
11
- bower_components/
12
- build/
13
- coverage/
14
- dist/
15
- node_modules/
16
- vendor/
17
- .parcel-cache/
2
+ # Also respects .gitignore
18
3
 
19
4
  # @kitschpatrol/prettier-config boilerplate
20
5
  pnpm-lock.yaml
@@ -25,5 +25,6 @@
25
25
  "**/*.rb",
26
26
  "**/*.svelte"
27
27
  ],
28
+
28
29
  "prettier.enable": true
29
30
  }
@@ -0,0 +1,3 @@
1
+ import { prettierConfig } from '@kitschpatrol/prettier-config'
2
+
3
+ export default prettierConfig()
package/license.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023-2024 Eric Mika
3
+ Copyright (c) 2023-2025 Eric Mika
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,62 +1,71 @@
1
1
  {
2
2
  "name": "@kitschpatrol/prettier-config",
3
- "version": "4.7.11",
4
- "type": "module",
3
+ "version": "5.0.0",
5
4
  "description": "Prettier configuration for @kitschpatrol/shared-config.",
5
+ "keywords": [
6
+ "shared-config",
7
+ "prettier-config",
8
+ "prettier",
9
+ "cli",
10
+ "kpi",
11
+ "kpi-prettier"
12
+ ],
13
+ "bugs": "https://github.com/kitschpatrol/shared-config/issues",
6
14
  "repository": {
7
15
  "type": "git",
8
16
  "url": "git+https://github.com/kitschpatrol/shared-config/cli.git",
9
17
  "directory": "packages/prettier-config"
10
18
  },
11
- "bugs": "https://github.com/kitschpatrol/shared-config/issues",
19
+ "license": "MIT",
12
20
  "author": {
13
21
  "name": "Eric Mika",
14
22
  "email": "eric@ericmika.com",
15
23
  "url": "https://ericmika.com"
16
24
  },
17
- "license": "MIT",
18
- "engines": {
19
- "node": ">=18.0.0",
20
- "pnpm": ">=8.0.0"
25
+ "type": "module",
26
+ "exports": {
27
+ ".": {
28
+ "import": "./dist/index.js",
29
+ "types": "./dist/index.d.ts"
30
+ }
21
31
  },
32
+ "main": "dist/index.js",
33
+ "types": "dist/index.d.ts",
22
34
  "bin": {
23
- "prettier-config": "bin/cli.js"
35
+ "kpi-prettier": "bin/cli.js"
24
36
  },
25
- "main": "prettier.config.js",
26
37
  "files": [
27
38
  "bin/*",
39
+ "dist/*",
28
40
  "init/*"
29
41
  ],
30
- "keywords": [
31
- "shared-config",
32
- "prettier-config",
33
- "prettier",
34
- "cli"
35
- ],
36
- "peerDependencies": {
37
- "prettier": "^3.3.3"
38
- },
39
42
  "dependencies": {
40
43
  "@pinojs/json-colorizer": "^4.0.0",
41
- "@prettier/plugin-php": "^0.22.2",
44
+ "@prettier/plugin-php": "^0.22.4",
42
45
  "@prettier/plugin-ruby": "^4.0.4",
43
46
  "@prettier/plugin-xml": "^3.4.1",
44
47
  "cosmiconfig": "^9.0.0",
45
- "execa": "^8.0.1",
46
- "fs-extra": "^11.2.0",
48
+ "deepmerge-ts": "^7.1.4",
49
+ "execa": "^9.5.2",
50
+ "fs-extra": "^11.3.0",
51
+ "prettier": "^3.4.2",
47
52
  "prettier-plugin-astro": "^0.14.1",
48
- "prettier-plugin-pkg": "^0.18.1",
53
+ "prettier-plugin-packagejson": "^2.5.8",
49
54
  "prettier-plugin-sh": "^0.14.0",
50
55
  "prettier-plugin-sql": "^0.18.1",
51
- "prettier-plugin-svelte": "^3.2.7",
52
- "prettier-plugin-tailwindcss": "^0.6.8",
56
+ "prettier-plugin-svelte": "^3.3.3",
57
+ "prettier-plugin-tailwindcss": "^0.6.11",
53
58
  "prettier-plugin-toml": "^2.0.1"
54
59
  },
60
+ "engines": {
61
+ "node": ">=22.0.0",
62
+ "pnpm": ">=10.0.0"
63
+ },
55
64
  "publishConfig": {
56
65
  "access": "public"
57
66
  },
58
67
  "scripts": {
59
- "build": "../../scripts/build.ts && pnpm mdat readme",
68
+ "build": "tsc && ../../scripts/build.ts",
60
69
  "cli": "node ./bin/cli.js"
61
70
  }
62
71
  }
package/readme.md CHANGED
@@ -21,9 +21,17 @@
21
21
 
22
22
  ## Overview
23
23
 
24
- It's a shared [Prettier](https://prettier.io) config.
24
+ It's a shared [Prettier](https://prettier.io) config, plus a command-line tool `kpi-prettier` to perform Prettier-related project initialization, linting, and fixing.
25
25
 
26
- **See [`@kitschpatrol/shared-config`](https://www.npmjs.com/package/@kitschpatrol/shared-config) for the recommended single-package approach.**
26
+ <!-- recommendation -->
27
+
28
+ > [!Important]
29
+ >
30
+ > **You can use this package on its own, but it's recommended to use [`@kitschpatrol/shared-config`](https://www.npmjs.com/package/@kitschpatrol/shared-config) instead for a single-dependency and single-package approach to linting and fixing your project.**
31
+ >
32
+ > This package is included as a dependency in [`@kitschpatrol/shared-config`](https://www.npmjs.com/package/@kitschpatrol/shared-config), which also automatically invokes the command line functionality in this package via its `kpi` command
33
+
34
+ <!-- /recommendation -->
27
35
 
28
36
  ## Setup
29
37
 
@@ -32,7 +40,7 @@ To use just this Prettier config in isolation:
32
40
  1. Install the `.npmrc` in your project root. This is required for correct PNPM behavior:
33
41
 
34
42
  ```sh
35
- pnpm dlx @kitschpatrol/repo-config --init
43
+ pnpm dlx @kitschpatrol/repo-config init
36
44
  ```
37
45
 
38
46
  2. Add the package:
@@ -44,7 +52,7 @@ To use just this Prettier config in isolation:
44
52
  3. Add the starter `.prettierrc.js` and `.prettierignore` files to your project root, and add any customizations you'd like:
45
53
 
46
54
  ```sh
47
- pnpm exec prettier-config --init
55
+ pnpm exec kpi-prettier init
48
56
  ```
49
57
 
50
58
  ## Usage
@@ -56,36 +64,134 @@ You can call it directly, or use the script bundled with the config.
56
64
  Integrate with your `package.json` scripts as you see fit, for example:
57
65
 
58
66
  ```json
59
- "scripts": {
60
- "lint": "prettier-config --check"
61
- "format": "prettier-config --fix"
67
+ {
68
+ "scripts": {
69
+ "lint": "kpi-prettier lint",
70
+ "fix": "kpi-prettier fix"
71
+ }
62
72
  }
63
73
  ```
64
74
 
65
- You might need to pass certain plugins in explicitly. The `shared-config --fix` and `shared-config --lint` scripts take care of this for you.
75
+ You might need to pass certain plugins in explicitly if you're calling `prettier` directly. The `kpi-prettier fix` and `kpi-prettier lint` scripts take care of this for you.
76
+
77
+ ### Configuration
78
+
79
+ To create a `prettier.config.js` in your project root:
80
+
81
+ ```sh
82
+ pnpm exec kpi-prettier init
83
+ ```
84
+
85
+ (Note that this will delete the `prettier` property in your `package.json`!)
86
+
87
+ _Or_
88
+
89
+ To create a `prettier` property in `package.json`:
90
+
91
+ ```sh
92
+ pnpm exec kpi-prettier init --location package
93
+ ```
94
+
95
+ (Note that this will delete the `prettier.config.js` file in your project root!)
66
96
 
67
97
  ### CLI
68
98
 
69
99
  <!-- cli-help -->
70
100
 
71
- #### Command: `prettier-config`
101
+ #### Command: `kpi-prettier`
102
+
103
+ Kitschpatrol's Prettier shared configuration tools.
104
+
105
+ This section lists top-level commands for `kpi-prettier`.
106
+
107
+ Usage:
108
+
109
+ ```txt
110
+ kpi-prettier <command>
111
+ ```
112
+
113
+ | Command | Argument | Description |
114
+ | -------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------- |
115
+ | `init` | | Initialize by copying starter config files to your project root or to your package.json file. |
116
+ | `lint` | `[files..]` | Check that files are formatted according to your Prettier configuration. Matches files below the current working directory by default. |
117
+ | `fix` | `[files..]` | Format files according to your Prettier configuration. Matches files below the current working directory by default. |
118
+ | `print-config` | | Print the effective Prettier configuration. Package-scoped.. Searches up to the root of a monorepo if necessary.. |
119
+
120
+ | Option | Description | Type |
121
+ | ------------------- | ------------------- | --------- |
122
+ | `--help`<br>`-h` | Show help | `boolean` |
123
+ | `--version`<br>`-v` | Show version number | `boolean` |
124
+
125
+ _See the sections below for more information on each subcommand._
126
+
127
+ #### Subcommand: `kpi-prettier init`
128
+
129
+ Initialize by copying starter config files to your project root or to your package.json file.
130
+
131
+ Usage:
132
+
133
+ ```txt
134
+ kpi-prettier init
135
+ ```
136
+
137
+ | Option | Description | Type | Default |
138
+ | ------------------- | ------------------- | -------------------- | -------- |
139
+ | `--location` | TK | `"file"` `"package"` | `"file"` |
140
+ | `--help`<br>`-h` | Show help | `boolean` | |
141
+ | `--version`<br>`-v` | Show version number | `boolean` | |
142
+
143
+ #### Subcommand: `kpi-prettier lint`
144
+
145
+ Check that files are formatted according to your Prettier configuration. Matches files below the current working directory by default.
146
+
147
+ Usage:
148
+
149
+ ```txt
150
+ kpi-prettier lint [files..]
151
+ ```
152
+
153
+ | Positional Argument | Description | Type | Default |
154
+ | ------------------- | ------------------------------ | ------- | ------- |
155
+ | `files` | Files or glob pattern to lint. | `array` | `"."` |
156
+
157
+ | Option | Description | Type |
158
+ | ------------------- | ------------------- | --------- |
159
+ | `--help`<br>`-h` | Show help | `boolean` |
160
+ | `--version`<br>`-v` | Show version number | `boolean` |
72
161
 
73
- Prettier configuration for @kitschpatrol/shared-config.
162
+ #### Subcommand: `kpi-prettier fix`
163
+
164
+ Format files according to your Prettier configuration. Matches files below the current working directory by default.
74
165
 
75
166
  Usage:
76
167
 
77
168
  ```txt
78
- prettier-config [<file|glob> ...]
169
+ kpi-prettier fix [files..]
79
170
  ```
80
171
 
81
- | Option | Argument | Description |
82
- | ------------------------ | -------- | ---------------------------------------------------------------- |
83
- | `--check`<br>`-c` | | Check for and report issues. Same as `prettier-config`. |
84
- | `--fix`<br>`-f` | | Fix all auto-fixable issues, and report the un-fixable. |
85
- | `--init`<br>`-i` | | Initialize by copying starter config files to your project root. |
86
- | `--print-config`<br>`-p` | `<path>` | Print the effective configuration at a certain path. |
87
- | `--help`<br>`-h` | | Print this help info. |
88
- | `--version`<br>`-v` | | Print the package version. |
172
+ | Positional Argument | Description | Type | Default |
173
+ | ------------------- | ----------------------------- | ------- | ------- |
174
+ | `files` | Files or glob pattern to fix. | `array` | `"."` |
175
+
176
+ | Option | Description | Type |
177
+ | ------------------- | ------------------- | --------- |
178
+ | `--help`<br>`-h` | Show help | `boolean` |
179
+ | `--version`<br>`-v` | Show version number | `boolean` |
180
+
181
+ #### Subcommand: `kpi-prettier print-config`
182
+
183
+ Print the effective Prettier configuration. Package-scoped.. Searches up to the root of a monorepo if necessary..
184
+
185
+ Usage:
186
+
187
+ ```txt
188
+ kpi-prettier print-config
189
+ ```
190
+
191
+ | Option | Description | Type |
192
+ | ------------------- | ------------------- | --------- |
193
+ | `--help`<br>`-h` | Show help | `boolean` |
194
+ | `--version`<br>`-v` | Show version number | `boolean` |
89
195
 
90
196
  <!-- /cli-help -->
91
197
 
@@ -105,11 +211,9 @@ Note: Do _not_ add `plugins: ['prettier-plugin-ruby']` to the per-file scope, it
105
211
 
106
212
  Tabs are unambiguously preferred wherever the file format specification does not mandate spaces.
107
213
 
108
- The reluctant exceptions are:
109
-
110
- ### JSON
214
+ Note that despite widely-accepted FUD regarding JSON requiring spaces, the [specification](https://www.json.org/json-en.html) indicates otherwise. So we use tabs.
111
215
 
112
- Despite widely accepted FUD regarding JSON requiring spaces, the [specification](https://www.json.org/json-en.html) indicates otherwise.
216
+ The reluctant exceptions are:
113
217
 
114
218
  ### YAML
115
219
 
@@ -1,16 +0,0 @@
1
- import sharedConfig from '@kitschpatrol/prettier-config'
2
-
3
- /** @type {import("prettier").Config} */
4
- const localConfig = {
5
- // Config overrides
6
- // overrides: [
7
- // ...sharedConfig.overrides,
8
- // {
9
- // // Per-file overrides overrides
10
- // },
11
- // ],
12
- }
13
- export default {
14
- ...sharedConfig,
15
- ...localConfig,
16
- }
@@ -1,59 +0,0 @@
1
- import { homedir } from 'node:os'
2
-
3
- /** @type {import("prettier").Config} */
4
- const config = {
5
- bracketSpacing: true,
6
- overrides: [
7
- {
8
- files: ['*.md', '*.mdx', '*.yml'],
9
- options: {
10
- useTabs: false,
11
- },
12
- },
13
- {
14
- files: '*.astro',
15
- options: {
16
- parser: 'astro',
17
- plugins: ['prettier-plugin-astro'],
18
- },
19
- },
20
- {
21
- files: '*.svelte',
22
- options: {
23
- parser: 'svelte',
24
- plugins: ['prettier-plugin-svelte'],
25
- },
26
- },
27
- {
28
- files: '*.rb',
29
- options: {
30
- rubyExecutablePath: `${homedir}/.rbenv/shims/ruby`,
31
- },
32
- },
33
- {
34
- files: ['*rc', '*ignore', '*.sh', '*.zsh', '*.bash', '*.fish'],
35
- options: {
36
- parser: 'sh',
37
- plugins: ['prettier-plugin-sh'],
38
- },
39
- },
40
- ],
41
- plugins: [
42
- '@prettier/plugin-php',
43
- '@prettier/plugin-ruby',
44
- '@prettier/plugin-xml',
45
- 'prettier-plugin-pkg',
46
- 'prettier-plugin-sh',
47
- 'prettier-plugin-sql',
48
- 'prettier-plugin-tailwindcss',
49
- 'prettier-plugin-toml',
50
- ],
51
- printWidth: 100,
52
- semi: false,
53
- singleQuote: true,
54
- tabWidth: 2,
55
- trailingComma: 'all',
56
- useTabs: true,
57
- }
58
-
59
- export default config