@bfra.me/prettier-config 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/120-proof.d.ts +2 -35
- package/120-proof.ts +2 -1
- package/package.json +3 -3
- package/plugins.d.ts +10 -0
- package/plugins.js +17 -0
- package/plugins.ts +26 -0
- package/prettier.config.js +31 -23
- package/prettier.config.ts +35 -27
package/120-proof.d.ts
CHANGED
@@ -1,39 +1,6 @@
|
|
1
|
+
import type {Config} from 'prettier'
|
1
2
|
/**
|
2
3
|
* Shared Prettier configuration for bfra.me projects with `printWidth` set to 120 characters.
|
3
4
|
*/
|
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
|
-
}
|
5
|
+
declare const config: Config
|
39
6
|
export default config
|
package/120-proof.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import prettierConfig from '@bfra.me/prettier-config'
|
2
|
+
import type {Config} from 'prettier'
|
2
3
|
|
3
4
|
/**
|
4
5
|
* Shared Prettier configuration for bfra.me projects with `printWidth` set to 120 characters.
|
5
6
|
*/
|
6
|
-
const config = {
|
7
|
+
const config: Config = {
|
7
8
|
...prettierConfig,
|
8
9
|
printWidth: 120,
|
9
10
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@bfra.me/prettier-config",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.5.0",
|
4
4
|
"description": "Shared Prettier configuration for bfra.me",
|
5
5
|
"keywords": [
|
6
6
|
"bfra.me",
|
@@ -37,12 +37,12 @@
|
|
37
37
|
"!*.map"
|
38
38
|
],
|
39
39
|
"dependencies": {
|
40
|
-
"@bfra.me/prettier-plugins": "0.
|
40
|
+
"@bfra.me/prettier-plugins": "0.3.0"
|
41
41
|
},
|
42
42
|
"devDependencies": {
|
43
43
|
"prettier": "3.3.3",
|
44
44
|
"@bfra.me/tsconfig": "0.6.0",
|
45
|
-
"@bfra.me/prettier-config": "0.
|
45
|
+
"@bfra.me/prettier-config": "0.5.0"
|
46
46
|
},
|
47
47
|
"peerDependencies": {
|
48
48
|
"prettier": "^3.0.0"
|
package/plugins.d.ts
ADDED
package/plugins.js
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
function interopDefault(m) {
|
2
|
+
return m.default || m
|
3
|
+
}
|
4
|
+
import {default as pluginPackageJson} from '@bfra.me/prettier-plugins/package-json'
|
5
|
+
const resolvedPlugins = {
|
6
|
+
'@bfra.me/prettier-plugins/package-json': interopDefault(pluginPackageJson),
|
7
|
+
}
|
8
|
+
export const resolve = (resolver, plugin) => {
|
9
|
+
try {
|
10
|
+
if (resolvedPlugins[plugin]) {
|
11
|
+
return resolvedPlugins[plugin]
|
12
|
+
}
|
13
|
+
return resolver(plugin)
|
14
|
+
} finally {
|
15
|
+
return plugin
|
16
|
+
}
|
17
|
+
}
|
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
|
+
}
|
package/prettier.config.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
import {resolve} from './plugins.js'
|
1
2
|
import {createRequire} from 'module'
|
2
|
-
const
|
3
|
+
const require = createRequire(import.meta.url)
|
4
|
+
const resolvePlugin = resolve.bind(null, require.resolve)
|
3
5
|
/**
|
4
6
|
* Shared Prettier configuration for bfra.me projects.
|
5
7
|
*/
|
@@ -11,24 +13,6 @@ const config = {
|
|
11
13
|
semi: false,
|
12
14
|
singleQuote: true,
|
13
15
|
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
16
|
// Adapted from https://github.com/sxzz/prettier-config/blob/1e5cc3021e5816aceebe0b90af1d530239442ecf/index.js.
|
33
17
|
// Require a pragma for paths typically not under version control or written by build tools.
|
34
18
|
{
|
@@ -38,28 +22,52 @@ const config = {
|
|
38
22
|
'**/lib/**',
|
39
23
|
'**/coverage/**',
|
40
24
|
'**/out/**',
|
25
|
+
'**/temp/**',
|
41
26
|
'**/.idea/**',
|
27
|
+
'**/.next/**',
|
42
28
|
'**/.nuxt/**',
|
29
|
+
'**/.output/**',
|
43
30
|
'**/.vercel/**',
|
44
31
|
'**/.vitepress/cache/**',
|
45
32
|
'**/.vite-inspect/**',
|
46
33
|
'**/__snapshots__/**',
|
34
|
+
'**/auto-import?(s).d.ts',
|
47
35
|
'**/.changeset/*.md',
|
48
36
|
'**/CHANGELOG*.md',
|
49
37
|
'**/changelog*.md',
|
38
|
+
'**/components.d.ts',
|
50
39
|
'**/devcontainer-lock.json',
|
51
40
|
'**/LICENSE*',
|
52
41
|
'**/license*',
|
53
42
|
'**/*.min.*',
|
54
|
-
'package-lock.json',
|
55
|
-
'pnpm-lock.yaml',
|
56
|
-
'
|
43
|
+
'**/package-lock.json',
|
44
|
+
'**/pnpm-lock.yaml',
|
45
|
+
'**/typed-router.d.ts',
|
46
|
+
'**/yarn.lock',
|
57
47
|
],
|
58
48
|
options: {
|
59
49
|
requirePragma: true,
|
60
50
|
},
|
61
51
|
},
|
52
|
+
// VS Code configuration files:
|
53
|
+
// Use 4 spaces for indentation to match the default VS Code settings.
|
54
|
+
{
|
55
|
+
files: ['.vscode/*.json', '.devcontainer/**/devcontainer*.json'],
|
56
|
+
options: {
|
57
|
+
tabWidth: 4,
|
58
|
+
},
|
59
|
+
},
|
60
|
+
// Markdown:
|
61
|
+
// - Disable single quotes for Markdown files.
|
62
|
+
// - Disable `proseWrap` to avoid wrapping prose.
|
63
|
+
{
|
64
|
+
files: ['*.md'],
|
65
|
+
options: {
|
66
|
+
proseWrap: 'never',
|
67
|
+
singleQuote: false,
|
68
|
+
},
|
69
|
+
},
|
62
70
|
],
|
63
|
-
plugins: ['@bfra.me/prettier-plugins/package-json'].map(
|
71
|
+
plugins: ['@bfra.me/prettier-plugins/package-json'].map(resolvePlugin),
|
64
72
|
}
|
65
73
|
export default config
|
package/prettier.config.ts
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
import {
|
1
|
+
import {resolve} from './plugins.js'
|
2
2
|
import type {Config} from 'prettier'
|
3
3
|
|
4
|
-
|
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,57 @@ 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__/**',
|
53
39
|
|
40
|
+
'**/auto-import?(s).d.ts',
|
54
41
|
'**/.changeset/*.md',
|
55
42
|
'**/CHANGELOG*.md',
|
56
43
|
'**/changelog*.md',
|
44
|
+
'**/components.d.ts',
|
57
45
|
'**/devcontainer-lock.json',
|
58
46
|
'**/LICENSE*',
|
59
47
|
'**/license*',
|
60
48
|
'**/*.min.*',
|
61
|
-
|
62
|
-
'
|
63
|
-
'
|
64
|
-
'yarn.lock',
|
49
|
+
'**/package-lock.json',
|
50
|
+
'**/pnpm-lock.yaml',
|
51
|
+
'**/typed-router.d.ts',
|
52
|
+
'**/yarn.lock',
|
65
53
|
],
|
66
54
|
options: {
|
67
55
|
requirePragma: true,
|
68
56
|
},
|
69
57
|
},
|
58
|
+
|
59
|
+
// VS Code configuration files:
|
60
|
+
// Use 4 spaces for indentation to match the default VS Code settings.
|
61
|
+
{
|
62
|
+
files: ['.vscode/*.json', '.devcontainer/**/devcontainer*.json'],
|
63
|
+
options: {
|
64
|
+
tabWidth: 4,
|
65
|
+
},
|
66
|
+
},
|
67
|
+
|
68
|
+
// Markdown:
|
69
|
+
// - Disable single quotes for Markdown files.
|
70
|
+
// - Disable `proseWrap` to avoid wrapping prose.
|
71
|
+
{
|
72
|
+
files: ['*.md'],
|
73
|
+
options: {
|
74
|
+
proseWrap: 'never',
|
75
|
+
singleQuote: false,
|
76
|
+
},
|
77
|
+
},
|
70
78
|
],
|
71
79
|
|
72
|
-
plugins: ['@bfra.me/prettier-plugins/package-json'].map(
|
80
|
+
plugins: ['@bfra.me/prettier-plugins/package-json'].map(resolvePlugin),
|
73
81
|
}
|
74
82
|
|
75
83
|
export default config
|