@bfra.me/prettier-config 0.4.1 → 0.6.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/120-proof.d.ts CHANGED
@@ -1,39 +1,11 @@
1
+ import {Config} from 'prettier'
2
+
3
+ declare const preset: {
4
+ readonly printWidth: 120
5
+ }
1
6
  /**
2
7
  * Shared Prettier configuration for bfra.me projects with `printWidth` set to 120 characters.
3
8
  */
4
- declare const config: {
5
- printWidth: number
6
- overrides?: Array<{
7
- files: string | string[]
8
- excludeFiles?: string | string[]
9
- options?: import('prettier').Options
10
- }>
11
- semi?: boolean
12
- singleQuote?: boolean
13
- jsxSingleQuote?: boolean
14
- trailingComma?: 'none' | 'es5' | 'all'
15
- bracketSpacing?: boolean
16
- bracketSameLine?: boolean
17
- rangeStart?: number
18
- rangeEnd?: number
19
- parser?: import('prettier').LiteralUnion<import('prettier').BuiltInParserName>
20
- filepath?: string
21
- requirePragma?: boolean
22
- insertPragma?: boolean
23
- proseWrap?: 'always' | 'never' | 'preserve'
24
- arrowParens?: 'avoid' | 'always'
25
- plugins?: Array<string | import('prettier').Plugin>
26
- htmlWhitespaceSensitivity?: 'css' | 'strict' | 'ignore'
27
- endOfLine?: 'auto' | 'lf' | 'crlf' | 'cr'
28
- quoteProps?: 'as-needed' | 'consistent' | 'preserve'
29
- vueIndentScriptAndStyle?: boolean
30
- embeddedLanguageFormatting?: 'auto' | 'off'
31
- singleAttributePerLine?: boolean
32
- experimentalTernaries?: boolean
33
- jsxBracketSameLine?: boolean
34
- tabWidth?: number
35
- useTabs?: boolean
36
- parentParser?: string | undefined
37
- __embeddedInHtml?: boolean | undefined
38
- }
39
- export default config
9
+ declare const config: Config & typeof preset
10
+
11
+ export {config as default}
package/120-proof.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import prettierConfig from '@bfra.me/prettier-config'
2
- /**
3
- * Shared Prettier configuration for bfra.me projects with `printWidth` set to 120 characters.
4
- */
2
+ const preset = {
3
+ printWidth: 120,
4
+ }
5
5
  const config = {
6
6
  ...prettierConfig,
7
- printWidth: 120,
7
+ ...preset,
8
8
  }
9
- export default config
9
+ var proof_default = config
10
+ export {proof_default as default}
11
+ //# sourceMappingURL=120-proof.js.map
package/120-proof.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  import prettierConfig from '@bfra.me/prettier-config'
2
+ import type {Config} from 'prettier'
3
+
4
+ const preset = {printWidth: 120} as const
2
5
 
3
6
  /**
4
7
  * Shared Prettier configuration for bfra.me projects with `printWidth` set to 120 characters.
5
8
  */
6
- const config = {
9
+ const config: Config & typeof preset = {
7
10
  ...prettierConfig,
8
- printWidth: 120,
11
+ ...preset,
9
12
  }
10
13
 
11
14
  export default config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bfra.me/prettier-config",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "description": "Shared Prettier configuration for bfra.me",
5
5
  "keywords": [
6
6
  "bfra.me",
@@ -37,12 +37,18 @@
37
37
  "!*.map"
38
38
  ],
39
39
  "dependencies": {
40
- "@bfra.me/prettier-plugins": "0.2.1"
40
+ "@bfra.me/prettier-plugins": "0.3.0"
41
41
  },
42
42
  "devDependencies": {
43
+ "@types/fs-extra": "11.0.4",
44
+ "execa": "9.3.1",
45
+ "fast-glob": "3.3.2",
46
+ "fs-extra": "11.2.0",
43
47
  "prettier": "3.3.3",
48
+ "tsup": "8.2.0",
49
+ "vitest": "2.0.2",
44
50
  "@bfra.me/tsconfig": "0.6.0",
45
- "@bfra.me/prettier-config": "0.4.1"
51
+ "@bfra.me/prettier-config": "0.6.0"
46
52
  },
47
53
  "peerDependencies": {
48
54
  "prettier": "^3.0.0"
@@ -52,7 +58,8 @@
52
58
  "provenance": true
53
59
  },
54
60
  "scripts": {
55
- "build": "tsc --build && pnpm run format",
56
- "format": "prettier --ignore-path .prettierignore --log-level log --write ."
61
+ "build": "tsup && pnpm run format",
62
+ "format": "prettier --ignore-path .prettierignore --log-level log --write .",
63
+ "test": "vitest"
57
64
  }
58
65
  }
package/plugins.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import {Plugin} from 'prettier'
2
+
3
+ type InteropDefault<T> = T extends {
4
+ default: infer U
5
+ }
6
+ ? U
7
+ : T
8
+ declare const resolve: <T extends Plugin>(
9
+ resolver: (id: string) => string,
10
+ plugin: string,
11
+ ) => string | T
12
+
13
+ export {type InteropDefault, resolve}
package/plugins.js ADDED
@@ -0,0 +1,22 @@
1
+ var __defProp = Object.defineProperty
2
+ var __name = (target, value) => __defProp(target, 'name', {value, configurable: true})
3
+ function interopDefault(m) {
4
+ return m.default || m
5
+ }
6
+ __name(interopDefault, 'interopDefault')
7
+ import {default as pluginPackageJson} from '@bfra.me/prettier-plugins/package-json'
8
+ const resolvedPlugins = {
9
+ '@bfra.me/prettier-plugins/package-json': interopDefault(pluginPackageJson),
10
+ }
11
+ const resolve = /* @__PURE__ */ __name((resolver, plugin) => {
12
+ try {
13
+ if (resolvedPlugins[plugin]) {
14
+ return resolvedPlugins[plugin]
15
+ }
16
+ return resolver(plugin)
17
+ } finally {
18
+ return plugin
19
+ }
20
+ }, 'resolve')
21
+ export {resolve}
22
+ //# sourceMappingURL=plugins.js.map
package/plugins.ts ADDED
@@ -0,0 +1,26 @@
1
+ import type {Plugin} from 'prettier'
2
+
3
+ export type InteropDefault<T> = T extends {default: infer U} ? U : T
4
+
5
+ function interopDefault<T>(m: T): InteropDefault<T> {
6
+ return (m as any).default || m
7
+ }
8
+
9
+ import {default as pluginPackageJson} from '@bfra.me/prettier-plugins/package-json'
10
+ const resolvedPlugins: Record<string, Plugin> = {
11
+ '@bfra.me/prettier-plugins/package-json': interopDefault(pluginPackageJson),
12
+ }
13
+
14
+ export const resolve = <T extends Plugin>(
15
+ resolver: (id: string) => string,
16
+ plugin: string,
17
+ ): string | T => {
18
+ try {
19
+ if (resolvedPlugins[plugin]) {
20
+ return resolvedPlugins[plugin] as unknown as T
21
+ }
22
+ return resolver(plugin)
23
+ } finally {
24
+ return plugin
25
+ }
26
+ }
@@ -1,6 +1,8 @@
1
- import type {Config} from 'prettier'
1
+ import {Config} from 'prettier'
2
+
2
3
  /**
3
4
  * Shared Prettier configuration for bfra.me projects.
4
5
  */
5
6
  declare const config: Config
6
- export default config
7
+
8
+ export {config as default}
@@ -1,8 +1,7 @@
1
+ import {resolve} from './plugins.js'
1
2
  import {createRequire} from 'module'
2
- const {resolve} = createRequire(import.meta.url)
3
- /**
4
- * Shared Prettier configuration for bfra.me projects.
5
- */
3
+ const require2 = createRequire(import.meta.url)
4
+ const resolvePlugin = resolve.bind(null, require2.resolve)
6
5
  const config = {
7
6
  arrowParens: 'avoid',
8
7
  bracketSpacing: false,
@@ -11,24 +10,6 @@ const config = {
11
10
  semi: false,
12
11
  singleQuote: true,
13
12
  overrides: [
14
- // VS Code configuration files:
15
- // Use 4 spaces for indentation to match the default VS Code settings.
16
- {
17
- files: ['.vscode/*.json', '.devcontainer/**/devcontainer*.json'],
18
- options: {
19
- tabWidth: 4,
20
- },
21
- },
22
- // Markdown:
23
- // - Disable single quotes for Markdown files.
24
- // - Disable `proseWrap` to avoid wrapping prose.
25
- {
26
- files: ['*.md'],
27
- options: {
28
- proseWrap: 'never',
29
- singleQuote: false,
30
- },
31
- },
32
13
  // Adapted from https://github.com/sxzz/prettier-config/blob/1e5cc3021e5816aceebe0b90af1d530239442ecf/index.js.
33
14
  // Require a pragma for paths typically not under version control or written by build tools.
34
15
  {
@@ -38,28 +19,55 @@ const config = {
38
19
  '**/lib/**',
39
20
  '**/coverage/**',
40
21
  '**/out/**',
22
+ '**/temp/**',
41
23
  '**/.idea/**',
24
+ '**/.next/**',
42
25
  '**/.nuxt/**',
26
+ '**/.output/**',
43
27
  '**/.vercel/**',
44
28
  '**/.vitepress/cache/**',
45
29
  '**/.vite-inspect/**',
46
30
  '**/__snapshots__/**',
31
+ '**/test/fixtures/**',
32
+ '**/auto-import?(s).d.ts',
47
33
  '**/.changeset/*.md',
48
34
  '**/CHANGELOG*.md',
49
35
  '**/changelog*.md',
36
+ '**/components.d.ts',
50
37
  '**/devcontainer-lock.json',
51
38
  '**/LICENSE*',
52
39
  '**/license*',
53
40
  '**/*.min.*',
54
- 'package-lock.json',
55
- 'pnpm-lock.yaml',
56
- 'yarn.lock',
41
+ '**/package-lock.json',
42
+ '**/pnpm-lock.yaml',
43
+ '**/typed-router.d.ts',
44
+ '**/yarn.lock',
57
45
  ],
58
46
  options: {
59
47
  requirePragma: true,
60
48
  },
61
49
  },
50
+ // VS Code configuration files:
51
+ // Use 4 spaces for indentation to match the default VS Code settings.
52
+ {
53
+ files: ['.vscode/*.json', '.devcontainer/**/devcontainer*.json'],
54
+ options: {
55
+ tabWidth: 4,
56
+ },
57
+ },
58
+ // Markdown:
59
+ // - Disable single quotes for Markdown files.
60
+ // - Disable `proseWrap` to avoid wrapping prose.
61
+ {
62
+ files: ['*.md'],
63
+ options: {
64
+ proseWrap: 'never',
65
+ singleQuote: false,
66
+ },
67
+ },
62
68
  ],
63
- plugins: ['@bfra.me/prettier-plugins/package-json'].map(plugin => resolve(plugin)),
69
+ plugins: ['@bfra.me/prettier-plugins/package-json'].map(resolvePlugin),
64
70
  }
65
- export default config
71
+ var prettier_config_default = config
72
+ export {prettier_config_default as default}
73
+ //# sourceMappingURL=prettier.config.js.map
@@ -1,7 +1,10 @@
1
- import {createRequire} from 'module'
1
+ import {resolve} from './plugins.js'
2
2
  import type {Config} from 'prettier'
3
3
 
4
- const {resolve} = createRequire(import.meta.url)
4
+ import {createRequire} from 'module'
5
+
6
+ const require = createRequire(import.meta.url)
7
+ const resolvePlugin = resolve.bind(null, require.resolve)
5
8
 
6
9
  /**
7
10
  * Shared Prettier configuration for bfra.me projects.
@@ -15,26 +18,6 @@ const config: Config = {
15
18
  singleQuote: true,
16
19
 
17
20
  overrides: [
18
- // VS Code configuration files:
19
- // Use 4 spaces for indentation to match the default VS Code settings.
20
- {
21
- files: ['.vscode/*.json', '.devcontainer/**/devcontainer*.json'],
22
- options: {
23
- tabWidth: 4,
24
- },
25
- },
26
-
27
- // Markdown:
28
- // - Disable single quotes for Markdown files.
29
- // - Disable `proseWrap` to avoid wrapping prose.
30
- {
31
- files: ['*.md'],
32
- options: {
33
- proseWrap: 'never',
34
- singleQuote: false,
35
- },
36
- },
37
-
38
21
  // Adapted from https://github.com/sxzz/prettier-config/blob/1e5cc3021e5816aceebe0b90af1d530239442ecf/index.js.
39
22
  // Require a pragma for paths typically not under version control or written by build tools.
40
23
  {
@@ -44,32 +27,58 @@ const config: Config = {
44
27
  '**/lib/**',
45
28
  '**/coverage/**',
46
29
  '**/out/**',
30
+ '**/temp/**',
47
31
  '**/.idea/**',
32
+ '**/.next/**',
48
33
  '**/.nuxt/**',
34
+ '**/.output/**',
49
35
  '**/.vercel/**',
50
36
  '**/.vitepress/cache/**',
51
37
  '**/.vite-inspect/**',
52
38
  '**/__snapshots__/**',
39
+ '**/test/fixtures/**',
53
40
 
41
+ '**/auto-import?(s).d.ts',
54
42
  '**/.changeset/*.md',
55
43
  '**/CHANGELOG*.md',
56
44
  '**/changelog*.md',
45
+ '**/components.d.ts',
57
46
  '**/devcontainer-lock.json',
58
47
  '**/LICENSE*',
59
48
  '**/license*',
60
49
  '**/*.min.*',
61
-
62
- 'package-lock.json',
63
- 'pnpm-lock.yaml',
64
- 'yarn.lock',
50
+ '**/package-lock.json',
51
+ '**/pnpm-lock.yaml',
52
+ '**/typed-router.d.ts',
53
+ '**/yarn.lock',
65
54
  ],
66
55
  options: {
67
56
  requirePragma: true,
68
57
  },
69
58
  },
59
+
60
+ // VS Code configuration files:
61
+ // Use 4 spaces for indentation to match the default VS Code settings.
62
+ {
63
+ files: ['.vscode/*.json', '.devcontainer/**/devcontainer*.json'],
64
+ options: {
65
+ tabWidth: 4,
66
+ },
67
+ },
68
+
69
+ // Markdown:
70
+ // - Disable single quotes for Markdown files.
71
+ // - Disable `proseWrap` to avoid wrapping prose.
72
+ {
73
+ files: ['*.md'],
74
+ options: {
75
+ proseWrap: 'never',
76
+ singleQuote: false,
77
+ },
78
+ },
70
79
  ],
71
80
 
72
- plugins: ['@bfra.me/prettier-plugins/package-json'].map(plugin => resolve(plugin)),
81
+ plugins: ['@bfra.me/prettier-plugins/package-json'].map(resolvePlugin),
73
82
  }
74
83
 
75
84
  export default config
package/tsup.config.ts ADDED
@@ -0,0 +1,11 @@
1
+ import {defineConfig} from 'tsup'
2
+
3
+ export default defineConfig({
4
+ bundle: false,
5
+ dts: true,
6
+ entry: ['prettier.config.ts', '120-proof.ts', 'plugins.ts'],
7
+ format: ['esm'],
8
+ outDir: '.',
9
+ sourcemap: true,
10
+ splitting: false,
11
+ })