diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d39a796 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 + +[*.{js,jsx,cjs,mjs,ts,tsx}] +max_line_length = 120 + +[*.{yml,yaml}] +indent_size = 2 + +[{Makefile,*.go,go.*}] +indent_style = tab + diff --git a/README.md b/README.md index a047e81..5a0bb48 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,52 @@ 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 may 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. + +## 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/package.json b/package.json index 0fa47d9..ee33d25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-scality", - "version": "8.2.1", + "version": "8.2.2", "description": "ESLint config for Scality's Node.js coding guidelines", "bin": { "mdlint": "./bin/mdlint.js" diff --git a/prettier.config.cjs b/prettier.config.cjs new file mode 100644 index 0000000..bcf3695 --- /dev/null +++ b/prettier.config.cjs @@ -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', + }, + }, + ], +};