From ec67d9d8088858697dac968e28979682c1758844 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 30 Jan 2024 15:56:23 +0100 Subject: [PATCH] enh: Add first version the shared prettier configuration Signed-off-by: Ferdinand Thiessen --- index.js | 8 ++++++++ package-lock.json | 34 ++++++++++++++++++++++++++++++++++ package.json | 30 ++++++++++++++++++------------ prettier.config.js | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 index.js create mode 100644 package-lock.json create mode 100644 prettier.config.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..9a7dea5 --- /dev/null +++ b/index.js @@ -0,0 +1,8 @@ +/** + * SPDX-FileCopyrightText: 2024 Ferdinand Thiessen + * SPDX-License-Identifier: BSD-3-Clause + */ + +import config from './prettier.config.js' + +export default config diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e9e68ea --- /dev/null +++ b/package-lock.json @@ -0,0 +1,34 @@ +{ + "name": "@nextcloud/prettier-config", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@nextcloud/prettier-config", + "version": "1.0.0", + "license": "BSD-3-Clause", + "devDependencies": { + "prettier": "^3.2.4" + }, + "peerDependencies": { + "prettier": ">=3.0.0" + } + }, + "node_modules/prettier": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.4.tgz", + "integrity": "sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + } + } +} diff --git a/package.json b/package.json index 389408e..8ed11f6 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,11 @@ "name": "@nextcloud/prettier-config", "version": "1.0.0", "description": "Shared stylistic rules for Nextcloud apps and libraries", - "type": "module", - "main": "index.js", - "exports": { - "default": "./index.js" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "author": "Ferdinand Thiessen", + "license": "BSD-3-Clause", + "homepage": "https://github.com/nextcloud-libraries/nextcloud-prettier-config#readme", + "bugs": { + "url": "https://github.com/nextcloud-libraries/nextcloud-prettier-config/issues" }, "repository": { "type": "git", @@ -18,10 +16,18 @@ "Nextcloud", "prettier" ], - "author": "Ferdinand Thiessen", - "license": "BSD-3-Clause", - "bugs": { - "url": "https://github.com/nextcloud-libraries/nextcloud-prettier-config/issues" + "type": "module", + "main": "index.js", + "exports": { + "default": "./index.js" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "peerDependencies": { + "prettier": ">=3.0.0" }, - "homepage": "https://github.com/nextcloud-libraries/nextcloud-prettier-config#readme" + "devDependencies": { + "prettier": "^3.2.4" + } } diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..9fcee21 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,36 @@ +/** + * SPDX-FileCopyrightText: 2024 Ferdinand Thiessen + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @type {import("prettier").Config} + */ +export default { + // We always use tabs with 4 spaces tab width + useTabs: true, + tabWidth: 4, + // Allow brackets to be on the same line, required for Vue + bracketSameLine: true, + // Never enforce semicolons if not required + semi: false, + // Always use single quote over double quote (' instead of ") + singleQuote: true, + // Enforce parenthesis for arrow functions + arrowParens: 'always', + // Always enfore a trailing comma + trailingComma: 'all', + // This is not a hard limit! We need 90 to keep changes from ESLint migration small + printWidth: 90, + + overrides: [ + // For package.json we need other indention as Node decided to only support spaces, so otherwise it would be reformatted on every npm install + { + files: ['package.json', 'package-lock.json'], + options: { + tabWidth: 2, + useTabs: false, + }, + }, + ], +}