forked from SchemaStore/schemastore
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.prettierrc.cjs
98 lines (97 loc) · 2.62 KB
/
.prettierrc.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/** @type {unknown} */
let prettierPluginSortJson
try {
// When running scripts locally (through npm-run-script), the relative path of the plugin
// must be specified since 'require.resolve' will not find it by itself in subdirectory 'src'.
prettierPluginSortJson = require.resolve(
'./src/node_modules/prettier-plugin-sort-json',
)
} catch (err) {
// In pre-commit CI, 'prettier-plugin-sort-json' is installed to some directory (which is in $NODE_PATH).
// As as result, simply require.resolve to find the full path to the dependency.
prettierPluginSortJson = require.resolve('prettier-plugin-sort-json')
}
if (!prettierPluginSortJson) {
throw new Error(`Failed to import plugin: 'prettier-plugin-sort-json'`)
}
/** @type {import('./src/node_modules/prettier').Config} */
module.exports = {
plugins: [prettierPluginSortJson],
semi: false,
singleQuote: true,
trailingComma: 'all',
jsonRecursiveSort: true,
jsonSortOrder: JSON.stringify({
'/^[^\\d+]/': 'none',
'/^\\d+/': 'none',
}),
overrides: [
{
files: 'src/api/json/catalog.json',
options: {
jsonRecursiveSort: true,
jsonSortOrder: JSON.stringify({
$schema: null,
version: null,
name: null,
description: null,
fileMatch: null,
url: null,
versions: null,
'/^[^\\d+]/': 'none',
'/^\\d+/': 'none',
}),
},
},
{
files: 'src/schema-validation.json',
options: {
$schema: null,
$id: null,
$comment: null,
jsonRecursiveSort: true,
jsonSortOrder: JSON.stringify({
ajvNotStrictMode: null,
fileMatchConflict: null,
highSchemaVersion: null,
missingCatalogUrl: null,
skiptest: null,
catalogEntryNoLintNameOrDescription: null,
options: null,
'/^[^\\d+]/': 'lexical',
'/^\\d+/': 'numeric',
}),
},
},
{
files: 'src/{test,negative_test}/**',
options: {
jsonRecursiveSort: true,
jsonSortOrder: JSON.stringify({
'/^[^\\d+]/': null,
'/^\\d+/': null,
}),
},
},
{
files: 'src/schemas/json/**',
options: {
jsonRecursiveSort: true,
jsonSortOrder: JSON.stringify({
$schema: null,
$id: null,
$comment: null,
$ref: null,
'/^\\$.*/': null,
'/^[^\\d+]/': 'none',
'/^\\d+/': 'none',
if: null,
then: null,
else: null,
'/^[^\\d+]/': 'none',
'/^\\d+/': 'none',
}),
},
},
],
}