Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{js,jsx,ts,tsx}]
indent_style = space
indent_size = 4

[*.{json}]
indent_style = space
indent_size = 4

[*.{yml,yaml}]
indent_style = space
indent_size = 2

[*.md]
indent_style = space
indent_size = 4

[Makefile]
indent_style = tab

60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,63 @@ This project:
* Provides an `eslint-config-scality` package that can be added as a dependency
in other projects. That way, coding style can automatically be checked using
eslint.

## Prettier baseline

This repository also provides a **baseline Prettier configuration** for Scality
object repositories: 4-space JavaScript/TypeScript indentation, 120-character
line length, single quotes, semicolons, trailing commas, and
`quoteProps: 'as-needed'`.

The configuration lives in `prettier.config.cjs`.

To use it in a project:

1. Install Prettier in the project:

```sh
yarn add --dev prettier
# or
npm install --save-dev prettier
```

2. Copy or extend the configuration:

```js
// prettier.config.cjs
module.exports = require('eslint-config-scality/prettier.config.cjs');
```

3. Add convenience scripts:

```json
{
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check ."
}
}
```

Projects are free to override options locally (for example `tabWidth` or
`printWidth`) if they have strong legacy constraints, but this configuration
is intended to be the **default Scality baseline** for new or reformatted
Node.js codebases. YAML defaults to 2-space indentation, JSON and Markdown to
4-space indentation, and Markdown prose is left un-reflowed by default
(`proseWrap: 'preserve'`) to avoid noisy diffs in existing documentation.

## Editor configuration

For a consistent editor experience, you can copy or adapt the `.editorconfig`
from this repository. It aligns with the ESLint and Prettier baselines:

- **JS/TS**: spaces with 4-space indentation.
- **JSON/Markdown**: spaces with 4-space indentation.
- **YAML**: spaces with 2-space indentation.
- `end_of_line = lf`, `insert_final_newline = true`,
`trim_trailing_whitespace = true`.

## Contributing

- See `CONTRIBUTING.md` for contribution guidelines and coding standards.
- See `TESTING.md` for details on running the linters and tests in this repo.
26 changes: 26 additions & 0 deletions prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
tabWidth: 4,
useTabs: false,
printWidth: 120,
singleQuote: true,
quoteProps: 'as-needed',
semi: true,
trailingComma: 'all',
arrowParens: 'avoid',
bracketSpacing: true,
endOfLine: 'lf',
overrides: [
{
files: ['*.yml', '*.yaml'],
options: {
tabWidth: 2,
},
},
{
files: ['*.md'],
options: {
proseWrap: 'preserve',
},
},
],
};