Skip to content

Commit 3cd1dad

Browse files
committed
Initial implementation of shared Prettier config
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
1 parent d4a35eb commit 3cd1dad

File tree

10 files changed

+5434
-0
lines changed

10 files changed

+5434
-0
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* @bajtos @juliangruber @pyropy @NikolasHaimerl
2+
package.json
3+
package-lock.json

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'npm'
4+
directory: '/'
5+
schedule:
6+
interval: 'daily'
7+
time: '09:00'
8+
timezone: 'Europe/Berlin'
9+
commit-message:
10+
prefix: 'deps'
11+
prefix-development: 'deps(dev)'

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
- run: npm ci
15+
- run: npm run lint
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Dependabot auto-approve minor updates
2+
on: pull_request
3+
4+
permissions:
5+
pull-requests: write
6+
7+
jobs:
8+
dependabot:
9+
runs-on: ubuntu-latest
10+
if: ${{ github.actor == 'dependabot[bot]' }}
11+
strategy:
12+
matrix:
13+
dependencyStartsWith:
14+
- prettier
15+
- neostandard
16+
- eslint
17+
steps:
18+
- name: Dependabot metadata
19+
id: metadata
20+
uses: dependabot/fetch-metadata@v2
21+
with:
22+
github-token: '${{ secrets.GITHUB_TOKEN }}'
23+
- name: Approve a PR
24+
if: ${{startsWith(steps.metadata.outputs.dependency-names, matrix.dependencyStartsWith) && (steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor')}}
25+
run: gh pr review --approve "$PR_URL"
26+
env:
27+
PR_URL: ${{github.event.pull_request.html_url}}
28+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Dependabot auto-merge
2+
on: pull_request
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'dependabot[bot]' }}
12+
steps:
13+
- name: Enable auto-merge for Dependabot PRs
14+
run: gh pr merge --auto --squash "$PR_URL"
15+
env:
16+
PR_URL: ${{github.event.pull_request.html_url}}
17+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
11
# prettier-config
2+
23
Shared configuration for Prettier
4+
5+
## Usage
6+
7+
Add this package as a dev-dependency to your project and tell prettier to use it as the configuration:
8+
9+
```json
10+
{
11+
"prettier": "@CheckerNetwork/prettier-config"
12+
"devDependencies": {
13+
"@CheckerNetwork/prettier-config": "^1.0.0",
14+
"prettier": "^3.5.3"
15+
}
16+
}
17+
```
18+
19+
## Development
20+
21+
Publish a new version:
22+
23+
```bash
24+
$ npx np
25+
```

eslint.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import neostandard from 'neostandard'
2+
3+
export default neostandard({
4+
noStyle: true, // Disable style-related rules, we use Prettier
5+
ts: true,
6+
})

index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @typedef {import('prettier').Config} Config
3+
* @see https://prettier.io/docs/configuration
4+
*/
5+
6+
/** @type {Config} */
7+
export default {
8+
plugins: [
9+
// Order of plugins is important!
10+
// See https://github.com/electrovir/prettier-plugin-multiline-arrays?tab=readme-ov-file#compatibility
11+
'prettier-plugin-packagejson',
12+
'prettier-plugin-jsdoc',
13+
],
14+
15+
// built-in options
16+
semi: false,
17+
singleQuote: true,
18+
19+
// prettier-plugin-jsdoc
20+
tsdoc: true,
21+
}

0 commit comments

Comments
 (0)