forked from Toniq-Labs/entrepot-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.prettierrc.js
61 lines (56 loc) · 1.66 KB
/
.prettierrc.js
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
const fs = require('fs');
const path = require('path');
function toPosixPath(input) {
return input.replace(/\\/g, '/').replace(/^\w+:/, '');
}
const packageDir = toPosixPath(path.dirname(__dirname));
const repoDir = __dirname;
const plugins = [
'prettier-plugin-toml',
'prettier-plugin-sort-json',
'prettier-plugin-packagejson',
'prettier-plugin-multiline-arrays',
'prettier-plugin-jsdoc',
].map(pluginName => {
const nestedNodeModulesPath = path.posix.join(packageDir, 'node_modules', pluginName);
const flattenedNodeModulesPath = path.posix.join(repoDir, 'node_modules', pluginName);
// account for installations where node_modules is flattened and installations where it's nested
if (fs.existsSync(nestedNodeModulesPath)) {
return nestedNodeModulesPath;
} else {
return flattenedNodeModulesPath;
}
});
/**
* @typedef {import('prettier-plugin-multiline-arrays').MultilineArrayOptions} MultilineOptions
*
* @typedef {import('prettier').Options} PrettierOptions
* @type {PrettierOptions & MultilineOptions}
*/
const prettierConfig = {
arrowParens: 'avoid',
bracketSameLine: false,
bracketSpacing: false,
endOfLine: 'lf',
htmlWhitespaceSensitivity: 'ignore',
jsonRecursiveSort: true,
plugins,
pluginSearchDirs: false,
printWidth: 100,
singleQuote: true,
tabWidth: 4,
trailingComma: 'all',
overrides: [
{
files: [
// 4 space tabs are huge in yaml files
'*.yaml',
'*.yml',
],
options: {
tabWidth: 2,
},
},
],
};
module.exports = prettierConfig;