-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
@bfra.me/prettier-plugins
package (#168)
- Loading branch information
1 parent
a9b8656
commit 3a3d2e0
Showing
13 changed files
with
182 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@bfra.me/prettier-plugins": minor | ||
"@bfra.me/prettier-config": minor | ||
--- | ||
|
||
Add `@bfra.me/prettier-plugins` and move inline `package.json` plugin from `@bfra.me/prettier-config` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
"license": "MIT", | ||
"author": "Marcus R. Brown <[email protected]>", | ||
"scripts": { | ||
"bootstrap": "pnpm install --frozen-lockfile && pnpm -r build", | ||
"bootstrap": "pnpm install && pnpm -r build", | ||
"build": "pnpm -r run build", | ||
"check-format": "prettier --check .", | ||
"clean": "rimraf --glob \"packages/**/lib\" \"**/*.tsbuildinfo\"", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"name": "@bfra.me/prettier-plugins", | ||
"version": "0.0.0", | ||
"description": "Plugins for Prettier used across bfra.me.", | ||
"license": "MIT", | ||
"author": "Marcus R. Brown <[email protected]>", | ||
"homepage": "https://github.com/bfra-me/works/tree/main/packages/prettier-plugins#readme", | ||
"repository": { | ||
"directory": "packages/prettier-plugins", | ||
"type": "git", | ||
"url": "https://github.com/bfra-me/works.git" | ||
}, | ||
"bugs": "https://github.com/bfra-me/works/issues", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"default": "./lib/index.js", | ||
"types": "./lib/index.d.ts" | ||
}, | ||
"./package-json": { | ||
"default": "./lib/package-json/index.js", | ||
"types": "./lib/package-json/index.d.ts" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib", | ||
"!**/*.map" | ||
], | ||
"scripts": { | ||
"build": "tsup" | ||
}, | ||
"sideEffects": false, | ||
"types": "lib/index.d.ts", | ||
"dependencies": { | ||
"prettier-package-json": "2.8.0" | ||
}, | ||
"peerDependencies": { | ||
"prettier": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@bfra.me/prettier-plugins": "workspace:*", | ||
"@bfra.me/tsconfig": "workspace:*", | ||
"prettier": "3.2.5", | ||
"tsup": "8.0.2" | ||
}, | ||
"keywords": [ | ||
"bfra.me", | ||
"plugins", | ||
"prettier", | ||
"prettier-plugins", | ||
"shared", | ||
"works" | ||
], | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# @bfra.me/prettier-plugins | ||
|
||
> Plugins for Prettier used across bfra.me. | ||
## Install | ||
|
||
### NPM | ||
|
||
```sh | ||
npm install --save-dev @bfra.me/prettier-plugins prettier | ||
``` | ||
|
||
### PNPM | ||
|
||
```sh | ||
pnpm add --save-dev @bfra.me/prettier-plugins prettier | ||
``` | ||
|
||
### Yarn | ||
|
||
```sh | ||
yarn add --dev @bfra.me/prettier-plugins prettier | ||
``` | ||
|
||
## Usage | ||
|
||
Add the following entry to your `.prettierrc` file: | ||
|
||
```json | ||
"plugins": ["@bfra.me/prettier-plugins/package-json"] | ||
``` | ||
|
||
## License | ||
|
||
[MIT](../../LICENSE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './package-json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type {Parser, ParserOptions} from 'prettier' | ||
import {parsers as babelParsers} from 'prettier/plugins/babel' | ||
import {format, type Options as PrettierPackageJsonOptions} from 'prettier-package-json' | ||
|
||
const jsonStringifyParser = babelParsers['json-stringify'] | ||
|
||
export const parsers = { | ||
'json-stringify': { | ||
...jsonStringifyParser, | ||
|
||
preprocess(text: string, options: ParserOptions) { | ||
if (jsonStringifyParser.preprocess) { | ||
text = jsonStringifyParser.preprocess(text, options) | ||
} | ||
if (/package.*json$/u.test(options.filepath)) { | ||
text = format(JSON.parse(text), { | ||
tabWidth: options.tabWidth, | ||
useTabs: options.useTabs === true, | ||
...((options['prettier-package-json'] ?? {}) as Partial<PrettierPackageJsonOptions>), | ||
}) | ||
} | ||
return text | ||
}, | ||
}, | ||
} satisfies Record<string, Parser> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": { | ||
"composite": false, | ||
"incremental": false, | ||
"noEmit": true, | ||
"outDir": "lib" | ||
}, | ||
"exclude": ["lib", "node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {defineConfig} from 'tsup' | ||
|
||
export default defineConfig({ | ||
entry: ['src/**/*.ts'], | ||
bundle: false, | ||
clean: true, | ||
dts: true, | ||
format: 'esm', | ||
outDir: 'lib', | ||
sourcemap: true, | ||
}) |
Oops, something went wrong.