-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprettier.config.js
More file actions
52 lines (48 loc) · 1.24 KB
/
prettier.config.js
File metadata and controls
52 lines (48 loc) · 1.24 KB
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
function prettier_plugin_packagejson() {
// Modified from https://github.com/matzkoh/prettier-plugin-packagejson to use the custom sort-package.json package
function requireSafe(path) {
try {
return require(path)
} catch (error) {}
}
const { parsers } = requireSafe("prettier/parser-babel") || requireSafe("prettier/parser-babylon")
const sortPackageJson = require("sort-package-json")
const parser = parsers["json-stringify"]
return {
parsers: {
"json-stringify": {
...parser,
preprocess(text, options) {
if (parser.preprocess) {
text = parser.preprocess(text, options)
}
return options.filepath && /(^|\\|\/)package\.json$/.test(options.filepath) ? sortPackageJson(text) : text
},
},
},
}
}
module.exports = {
plugins: ["prettier-plugin-jsdoc", prettier_plugin_packagejson(), "prettier-plugin-toml"],
tabWidth: 2,
printWidth: 120,
semi: false,
singleQuote: false,
tsdoc: true,
overrides: [
{
files: "{*.json}",
options: {
parser: "json",
trailingComma: "es5",
},
},
{
files: "{*.md}",
options: {
parser: "markdown",
proseWrap: "preserve",
},
},
],
}