From 6f250d910e9786eb630444dedda663e5a0f615b8 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Tue, 16 Dec 2025 17:01:13 +0100 Subject: [PATCH 1/4] prettier addition --- .editorconfig | 23 +++++++++++++++++++ README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++ prettier.config.cjs | 47 +++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 .editorconfig create mode 100644 prettier.config.cjs diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0598ba3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,23 @@ +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,yml,yaml}] +indent_style = space +indent_size = 2 + +[*.md] +indent_style = space +indent_size = 2 + +[Makefile] +indent_style = tab + diff --git a/README.md b/README.md index a047e81..35ade37 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,59 @@ 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** that matches +the rules exported by `eslint-config-scality` (4-space indentation, 120-character +line length, single quotes, semicolons, trailing commas). + +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. + +## 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/YAML/Markdown**: 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. diff --git a/prettier.config.cjs b/prettier.config.cjs new file mode 100644 index 0000000..de7d359 --- /dev/null +++ b/prettier.config.cjs @@ -0,0 +1,47 @@ +// Scality baseline Prettier configuration. +// This is designed to align with the rules exported by `eslint-config-scality` +// in `index.js` (4-space indent, max line length 120, single quotes, semicolons). +// +// Recommended usage in a consuming project: +// 1. Install Prettier as a dev dependency: +// yarn add --dev prettier +// or: npm install --save-dev prettier +// 2. Copy or extend this config in your project: +// // prettier.config.cjs +// module.exports = require('eslint-config-scality/prettier'); +// (once this package exposes such an entry point) +// 3. Add scripts such as: +// "format": "prettier --write .", +// "format:check": "prettier --check ." +// +// Projects are free to override any option (for example, `tabWidth` or +// `printWidth`) if local constraints require it, but this file should serve +// as the common baseline. + +module.exports = { + // Match `indent: [2, 4]` + tabWidth: 4, + useTabs: false, + + // Match `max-len: [2, 120, 4]` + printWidth: 120, + + // Match `quotes: [1, 'single', 'avoid-escape']` + singleQuote: true, + + // Match `semi: [2, 'always']` + semi: true, + + // Closest match to `comma-dangle: 2` (require dangling commas where valid) + trailingComma: 'all', + + // ESLint uses `arrow-parens: [1, 'as-needed']` + arrowParens: 'avoid', + + // Keep object spacing conventional and readable + bracketSpacing: true, + + // Normalise line endings across platforms while avoiding noisy diffs + endOfLine: 'lf', +}; + From ee14ffbf866e5d0a544a05dae8887a1d19ee8643 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Tue, 16 Dec 2025 17:14:22 +0100 Subject: [PATCH 2/4] additional improvements --- README.md | 7 +++++-- prettier.config.cjs | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 35ade37..9c69e5f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,8 @@ This project: This repository also provides a **baseline Prettier configuration** that matches the rules exported by `eslint-config-scality` (4-space indentation, 120-character -line length, single quotes, semicolons, trailing commas). +line length, single quotes, semicolons, trailing commas, `quoteProps: +consistent-as-needed`), with small overrides for non-JavaScript files. The configuration lives in `prettier.config.cjs`. @@ -48,7 +49,9 @@ To use it in a project: 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. +Node.js codebases. YAML/JSON/Markdown files default to a 2-space indentation +and Markdown prose is left un-reflowed by default (`proseWrap: 'preserve'`), +to avoid noisy diffs in existing documentation. ## Editor configuration diff --git a/prettier.config.cjs b/prettier.config.cjs index de7d359..ec88ff6 100644 --- a/prettier.config.cjs +++ b/prettier.config.cjs @@ -28,6 +28,8 @@ module.exports = { // Match `quotes: [1, 'single', 'avoid-escape']` singleQuote: true, + // Match `quote-props: [2, 'consistent-as-needed']` + quoteProps: 'consistent-as-needed', // Match `semi: [2, 'always']` semi: true, @@ -43,5 +45,22 @@ module.exports = { // Normalise line endings across platforms while avoiding noisy diffs endOfLine: 'lf', -}; + // Per-language tweaks to align with common Scality usage and `.editorconfig` + overrides: [ + { + files: ['*.yml', '*.yaml', '*.json'], + options: { + tabWidth: 2, + }, + }, + { + files: ['*.md'], + options: { + tabWidth: 2, + // Avoid reflowing existing prose by default + proseWrap: 'preserve', + }, + }, + ], +}; From e1706b915525e28ee78cb2dde19b263d99e986d2 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Tue, 16 Dec 2025 17:54:47 +0100 Subject: [PATCH 3/4] additional improvements --- .editorconfig | 2 +- README.md | 4 ++-- prettier.config.cjs | 50 ++------------------------------------------- 3 files changed, 5 insertions(+), 51 deletions(-) diff --git a/.editorconfig b/.editorconfig index 0598ba3..9059305 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,7 +8,7 @@ trim_trailing_whitespace = true [*.{js,jsx,ts,tsx}] indent_style = space -indent_size = 4 +indent_size = 2 [*.{json,yml,yaml}] indent_style = space diff --git a/README.md b/README.md index 9c69e5f..db0c70a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This project: ## Prettier baseline This repository also provides a **baseline Prettier configuration** that matches -the rules exported by `eslint-config-scality` (4-space indentation, 120-character +the rules exported by `eslint-config-scality` (2-space indentation, 160-character line length, single quotes, semicolons, trailing commas, `quoteProps: consistent-as-needed`), with small overrides for non-JavaScript files. @@ -58,7 +58,7 @@ to avoid noisy diffs in existing documentation. 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. +- **JS/TS**: spaces with 2-space indentation. - **JSON/YAML/Markdown**: spaces with 2-space indentation. - `end_of_line = lf`, `insert_final_newline = true`, `trim_trailing_whitespace = true`. diff --git a/prettier.config.cjs b/prettier.config.cjs index ec88ff6..416f143 100644 --- a/prettier.config.cjs +++ b/prettier.config.cjs @@ -1,64 +1,18 @@ -// Scality baseline Prettier configuration. -// This is designed to align with the rules exported by `eslint-config-scality` -// in `index.js` (4-space indent, max line length 120, single quotes, semicolons). -// -// Recommended usage in a consuming project: -// 1. Install Prettier as a dev dependency: -// yarn add --dev prettier -// or: npm install --save-dev prettier -// 2. Copy or extend this config in your project: -// // prettier.config.cjs -// module.exports = require('eslint-config-scality/prettier'); -// (once this package exposes such an entry point) -// 3. Add scripts such as: -// "format": "prettier --write .", -// "format:check": "prettier --check ." -// -// Projects are free to override any option (for example, `tabWidth` or -// `printWidth`) if local constraints require it, but this file should serve -// as the common baseline. - module.exports = { - // Match `indent: [2, 4]` - tabWidth: 4, + tabWidth: 2, useTabs: false, - - // Match `max-len: [2, 120, 4]` - printWidth: 120, - - // Match `quotes: [1, 'single', 'avoid-escape']` + printWidth: 160, singleQuote: true, - // Match `quote-props: [2, 'consistent-as-needed']` quoteProps: 'consistent-as-needed', - - // Match `semi: [2, 'always']` semi: true, - - // Closest match to `comma-dangle: 2` (require dangling commas where valid) trailingComma: 'all', - - // ESLint uses `arrow-parens: [1, 'as-needed']` arrowParens: 'avoid', - - // Keep object spacing conventional and readable bracketSpacing: true, - - // Normalise line endings across platforms while avoiding noisy diffs endOfLine: 'lf', - - // Per-language tweaks to align with common Scality usage and `.editorconfig` overrides: [ - { - files: ['*.yml', '*.yaml', '*.json'], - options: { - tabWidth: 2, - }, - }, { files: ['*.md'], options: { - tabWidth: 2, - // Avoid reflowing existing prose by default proseWrap: 'preserve', }, }, From 42093e970e9179315c996c1a7d7f5d402ab05259 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Mon, 9 Mar 2026 16:30:45 +0100 Subject: [PATCH 4/4] Align shared Prettier and editor baselines with object squad standards. Update Guidelines defaults to 4-space JS/TS and JSON formatting, keep YAML at 2 spaces, and document the baseline so downstream repos can import consistent settings. --- .editorconfig | 10 +++++++--- README.md | 19 ++++++++++--------- prettier.config.cjs | 12 +++++++++--- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9059305..1718460 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,15 +8,19 @@ trim_trailing_whitespace = true [*.{js,jsx,ts,tsx}] indent_style = space -indent_size = 2 +indent_size = 4 + +[*.{json}] +indent_style = space +indent_size = 4 -[*.{json,yml,yaml}] +[*.{yml,yaml}] indent_style = space indent_size = 2 [*.md] indent_style = space -indent_size = 2 +indent_size = 4 [Makefile] indent_style = tab diff --git a/README.md b/README.md index db0c70a..82c0546 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,10 @@ This project: ## Prettier baseline -This repository also provides a **baseline Prettier configuration** that matches -the rules exported by `eslint-config-scality` (2-space indentation, 160-character -line length, single quotes, semicolons, trailing commas, `quoteProps: -consistent-as-needed`), with small overrides for non-JavaScript files. +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`. @@ -49,17 +49,18 @@ To use it in a project: 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/JSON/Markdown files default to a 2-space indentation -and Markdown prose is left un-reflowed by default (`proseWrap: 'preserve'`), -to avoid noisy diffs in existing documentation. +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 2-space indentation. -- **JSON/YAML/Markdown**: spaces with 2-space indentation. +- **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`. diff --git a/prettier.config.cjs b/prettier.config.cjs index 416f143..bcf3695 100644 --- a/prettier.config.cjs +++ b/prettier.config.cjs @@ -1,15 +1,21 @@ module.exports = { - tabWidth: 2, + tabWidth: 4, useTabs: false, - printWidth: 160, + printWidth: 120, singleQuote: true, - quoteProps: 'consistent-as-needed', + quoteProps: 'as-needed', semi: true, trailingComma: 'all', arrowParens: 'avoid', bracketSpacing: true, endOfLine: 'lf', overrides: [ + { + files: ['*.yml', '*.yaml'], + options: { + tabWidth: 2, + }, + }, { files: ['*.md'], options: {