Skip to content

Commit

Permalink
enh: Add first version the shared prettier configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jan 30, 2024
1 parent 18f206e commit ec67d9d
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 12 deletions.
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* SPDX-FileCopyrightText: 2024 Ferdinand Thiessen <opensource@fthiessen.de>
* SPDX-License-Identifier: BSD-3-Clause
*/

import config from './prettier.config.js'

export default config
34 changes: 34 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 18 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
36 changes: 36 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* SPDX-FileCopyrightText: 2024 Ferdinand Thiessen <opensource@fthiessen.de>
* 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,
},
},
],
}

0 comments on commit ec67d9d

Please sign in to comment.