Skip to content

Commit 1a6cf99

Browse files
committed
Merge remote-tracking branch 'origin/improvement/GDL-12-add-new-prettier-config' into w/8.3/improvement/GDL-12-add-new-prettier-config
2 parents 9aa3b5c + 84380fd commit 1a6cf99

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 4
10+
11+
[*.{js,jsx,cjs,mjs,ts,tsx}]
12+
max_line_length = 120
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[{Makefile,*.go,go.*}]
18+
indent_style = tab
19+

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,52 @@ This project:
88
* Provides an `eslint-config-scality` package that can be added as a dependency
99
in other projects. That way, coding style can automatically be checked using
1010
eslint.
11+
12+
## Prettier baseline
13+
14+
This repository also provides a **baseline Prettier configuration** for Scality
15+
object repositories: 4-space JavaScript/TypeScript indentation, 120-character
16+
line length, single quotes, semicolons, trailing commas, and
17+
`quoteProps: 'as-needed'`.
18+
19+
The configuration lives in `prettier.config.cjs`.
20+
21+
To use it in a project:
22+
23+
1. Install Prettier in the project:
24+
25+
```sh
26+
yarn add --dev prettier
27+
# or
28+
npm install --save-dev prettier
29+
```
30+
31+
2. Copy or extend the configuration:
32+
33+
```js
34+
// prettier.config.cjs
35+
module.exports = require('eslint-config-scality/prettier.config.cjs');
36+
```
37+
38+
3. Add convenience scripts:
39+
40+
```json
41+
{
42+
"scripts": {
43+
"format": "prettier --write .",
44+
"format:check": "prettier --check ."
45+
}
46+
}
47+
```
48+
49+
Projects may override options locally (for example `tabWidth` or
50+
`printWidth`) if they have strong legacy constraints, but this configuration
51+
is intended to be the **default Scality baseline** for new or reformatted
52+
Node.js codebases. YAML/JSON/Markdown files default to a 2-space indentation
53+
and Markdown prose is left un-reflowed by default (`proseWrap: 'preserve'`),
54+
to avoid noisy diffs in existing documentation.
55+
56+
## Contributing
57+
58+
- See `CONTRIBUTING.md` for contribution guidelines and coding standards.
59+
- See `TESTING.md` for details on running the linters and tests in this repo.

prettier.config.cjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
tabWidth: 4,
3+
useTabs: false,
4+
printWidth: 120,
5+
singleQuote: true,
6+
quoteProps: 'as-needed',
7+
semi: true,
8+
trailingComma: 'all',
9+
arrowParens: 'avoid',
10+
bracketSpacing: true,
11+
endOfLine: 'lf',
12+
overrides: [
13+
{
14+
files: ['*.yml', '*.yaml'],
15+
options: {
16+
tabWidth: 2,
17+
},
18+
},
19+
{
20+
files: ['*.md'],
21+
options: {
22+
proseWrap: 'preserve',
23+
},
24+
},
25+
],
26+
};

0 commit comments

Comments
 (0)