Skip to content

Commit

Permalink
feat: add prettier-config (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusrbrown committed Mar 19, 2024
1 parent a29076b commit e38636f
Show file tree
Hide file tree
Showing 11 changed files with 246 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-hairs-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bfra.me/prettier-config": minor
---

Add the `prettier-config` shareable Prettier configuration.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ root = true
charset = utf-8
end_of_line = lf
insert_final_newline = true
max_line_length = 100
trim_trailing_whitespace = true
12 changes: 1 addition & 11 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
arrowParens: avoid
bracketSpacing: false
overrides:
- files:
- '.vscode/*.json'
options:
tabWidth: 4
singleQuote: true
semi: false
printWidth: 100
tabWidth: 2
'@bfra.me/prettier-config'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
}
},
"dependencies": {
"@bfra.me/prettier-config": "workspace:*",
"@bfra.me/tsconfig": "workspace:*",
"@changesets/cli": "2.27.1",
"@manypkg/cli": "0.21.3",
Expand Down
50 changes: 50 additions & 0 deletions packages/prettier-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@bfra.me/prettier-config",
"description": "Shared Prettier configuration for bfra.me",
"version": "0.0.0",
"author": "Marcus R. Brown <contact@bfra.me>",
"license": "MIT",
"type": "module",
"main": "prettier.config.js",
"types": "prettier.config.d.ts",
"homepage": "https://github.com/bfra-me/works/tree/main/packages/prettier-config#readme",
"repository": {
"directory": "packages/prettier-config",
"type": "git",
"url": "https://github.com/bfra-me/works.git"
},
"bugs": "https://github.com/bfra-me/works/issues",
"keywords": [
"bfra.me",
"works",
"prettier",
"prettier-config",
"config",
"shared"
],
"publishConfig": {
"access": "public",
"provenance": true
},
"files": [
"prettier.config.*",
"!*.map"
],
"exports": {
".": {
"import": "./prettier.config.js",
"types": "./prettier.config.d.ts"
},
"./package.json": "./package.json"
},
"devDependencies": {
"@bfra.me/tsconfig": "workspace:*",
"prettier": "3.2.5"
},
"peerDependencies": {
"prettier": "^3.0.0"
},
"scripts": {
"build": "tsc && prettier --log-level silent --write prettier.config.*"
}
}
6 changes: 6 additions & 0 deletions packages/prettier-config/prettier.config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type {Config} from 'prettier'
/**
* Shared Prettier configuration for bfra.me projects.
*/
declare const config: Config
export default config
59 changes: 59 additions & 0 deletions packages/prettier-config/prettier.config.js

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

65 changes: 65 additions & 0 deletions packages/prettier-config/prettier.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import type {Config} from 'prettier'

/**
* Shared Prettier configuration for bfra.me projects.
*/
const config: Config = {
arrowParens: 'avoid',
bracketSpacing: false,
endOfLine: 'auto',
printWidth: 100,
semi: false,
singleQuote: true,

overrides: [
// VS Code configuration files:
// Use 4 spaces for indentation to match the default VS Code settings.
{
files: ['.vscode/*.json'],
options: {
tabWidth: 4,
},
},

// Markdown:
// - Disable single quotes for Markdown files.
// - Disable `proseWrap` to avoid wrapping prose.
{
files: ['*.md'],
options: {
proseWrap: 'never',
singleQuote: false,
},
},

// Adapted from https://github.com/sxzz/prettier-config/blob/1e5cc3021e5816aceebe0b90af1d530239442ecf/index.js.
// Require a pragma for paths typically not under version control or written by build tools.
{
files: [
'**/node_modules/**',
'**/dist/**',
'**/lib/**',
'**/coverage/**',
'**/out/**',
'**/.changeset/**',
'**/.idea/**',
'**/.nuxt/**',
'**/.vercel/**',
'**/.vitepress/cache/**',
'**/.vite-inspect/**',
'**/__snapshots__/**',

'**/CHANGELOG*.md',
'**/changelog*.md',
'**/LICENSE*',
'**/license*',
'**/*.min.*',
],
options: {
requirePragma: true,
},
},
],
}

export default config
35 changes: 35 additions & 0 deletions packages/prettier-config/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# @bfra.me/prettier-config

> Shared Prettier configuration for bfra.me.
## Install

### NPM

```sh
npm install --save-dev @bfra.me/prettier-config prettier
```

### PNPM

```sh
pnpm add --save-dev @bfra.me/prettier-config prettier
```

### Yarn

```sh
yarn add --dev @bfra.me/prettier-config prettier
```

## Usage

Add the following entry to your `package.json` file:

```json
"prettier": "@bfra.me/prettier-config"
```

## License

[MIT](../../LICENSE.md)
11 changes: 11 additions & 0 deletions packages/prettier-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "@bfra.me/tsconfig",
"compilerOptions": {
"inlineSourceMap": true,
"sourceMap": false,
"outDir": ".",
"rootDir": "."
},
"exclude": ["node_modules"]
}
13 changes: 12 additions & 1 deletion pnpm-lock.yaml

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

0 comments on commit e38636f

Please sign in to comment.