Skip to content

Commit f516ffe

Browse files
committed
refactor: update repo
1 parent 6c0224b commit f516ffe

15 files changed

+4820
-3535
lines changed

.eslintignore

-2
This file was deleted.

.eslintrc

-5
This file was deleted.

.github/workflows/autofix.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: autofix.ci # needed to securely identify the workflow
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: ["main"]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
autofix:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- run: corepack enable
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
cache: "pnpm"
21+
- run: pnpm install
22+
- run: pnpm lint:fix
23+
- uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84
24+
with:
25+
commit-message: "chore: apply automated updates"

.github/workflows/ci.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ jobs:
1212
ci:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- run: corepack enable
17-
- uses: actions/setup-node@v3
17+
- uses: actions/setup-node@v4
1818
with:
19-
node-version: 16
19+
node-version: 20
2020
cache: "pnpm"
2121
- run: pnpm install
2222
- run: pnpm lint
23+
- run: pnpm test:types
2324
- run: pnpm build
2425
- run: pnpm vitest --coverage
25-
- uses: codecov/codecov-action@v3
26+
- uses: codecov/codecov-action@v4

.gitignore

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
.vscode
21
node_modules
3-
*.log*
4-
.DS_Store
52
coverage
63
dist
7-
types
8-
.conf*
4+
.vscode
5+
.DS_Store
6+
.eslintcache
7+
*.log*
8+
*.env*

README.md

+58-37
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# ♡ serve-placeholder
22

3-
> Smart placeholder for missing assets
3+
<!-- automd:badges color=yellow -->
44

5-
[![npm version][npm-version-src]][npm-version-href]
6-
[![npm downloads][npm-downloads-src]][npm-downloads-href]
7-
[![Github Actions][github-actions-src]][github-actions-href]
8-
[![Codecov][codecov-src]][codecov-href]
5+
[![npm version](https://img.shields.io/npm/v/serve-placeholder?color=yellow)](https://npmjs.com/package/serve-placeholder)
6+
[![npm downloads](https://img.shields.io/npm/dm/serve-placeholder?color=yellow)](https://npmjs.com/package/serve-placeholder)
7+
8+
<!-- /automd -->
9+
10+
Smart placeholder for missing assets
911

1012
## Why?
1113

@@ -25,25 +27,35 @@ Instead of indexing invalid URLs with HTML pages, we properly send 404 and the r
2527

2628
Install package:
2729

30+
<!-- automd:pm-install -->
31+
2832
```sh
33+
# ✨ Auto-detect
34+
npx nypm install serve-placeholder
35+
2936
# npm
3037
npm install serve-placeholder
3138

3239
# yarn
33-
yarn install serve-placeholder
40+
yarn add serve-placeholder
3441

3542
# pnpm
3643
pnpm install serve-placeholder
44+
45+
# bun
46+
bun install serve-placeholder
3747
```
3848

49+
<!-- /automd -->
50+
3951
Import:
4052

4153
```js
4254
// ESM
43-
import { servePlaceholder } from 'serve-placeholder'
55+
import { servePlaceholder } from "serve-placeholder";
4456

4557
// CommonJS
46-
const { servePlaceholder } = require('serve-placeholder')
58+
const { servePlaceholder } = require("serve-placeholder");
4759
```
4860

4961
Create and add server middleware between serve-static and router middleware:
@@ -67,7 +79,7 @@ app.use('/', router)
6779

6880
### `handlers`
6981

70-
A mapping from file extensions to the handler. Extensions should start with *dot* like `.js`.
82+
A mapping from file extensions to the handler. Extensions should start with _dot_ like `.js`.
7183

7284
You can disable any of the handlers by setting the value to `null`
7385

@@ -108,11 +120,11 @@ Set headers to prevent accidentally caching 404 resources.
108120
When enabled, these headers will be sent:
109121

110122
```js
111-
{
112-
'cache-control': 'no-cache, no-store, must-revalidate',
113-
'expires': '0',
114-
'pragma': 'no-cache'
115-
}
123+
const headers = {
124+
"cache-control": "no-cache, no-store, must-revalidate",
125+
expires: "0",
126+
pragma: "no-cache",
127+
};
116128
```
117129

118130
### `placeholderHeader`
@@ -125,39 +137,48 @@ Sets an `X-Placeholder` header with value of handler name.
125137

126138
These are [default handlers](./src/defaults.ts). You can override every of them using provided options.
127139

128-
Handler | Extensions | Mime type | Placeholder
129-
-----------|------------------------|--------------------------|-------------------
130-
`default` | any unknown extension | - | -
131-
`css` | `.css` | `text/css` | `/* style not found */`
132-
`html` | `.html`, `.htm` | `text/html` | `<!-- page not found -->`
133-
`js` | `.js` | `application/javascript` | `/* script not found */`
134-
`json` | `.json` | `application/json` | `{}`
135-
`map` | `.map` | `application/json` | [empty sourcemap v3 json]
136-
`plain` | `.txt`, `.text`, `.md` | `text/plain` | [empty]
137-
`image` | `.png`, `.jpg`, `.jpeg`, `.gif`, `.svg`, `.webp`, `.bmp`, `.ico` | `image/gif` | [transparent 1x1 image]
140+
| Handler | Extensions | Mime type | Placeholder |
141+
| --------- | ---------------------------------------------------------------- | ------------------------ | ------------------------- |
142+
| `default` | any unknown extension | - | - |
143+
| `css` | `.css` | `text/css` | `/* style not found */` |
144+
| `html` | `.html`, `.htm` | `text/html` | `<!-- page not found -->` |
145+
| `js` | `.js` | `application/javascript` | `/* script not found */` |
146+
| `json` | `.json` | `application/json` | `{}` |
147+
| `map` | `.map` | `application/json` | [empty sourcemap v3 json] |
148+
| `plain` | `.txt`, `.text`, `.md` | `text/plain` | [empty] |
149+
| `image` | `.png`, `.jpg`, `.jpeg`, `.gif`, `.svg`, `.webp`, `.bmp`, `.ico` | `image/gif` | [transparent 1x1 image] |
150+
151+
## Development
152+
153+
<details>
138154

139-
## 💻 Development
155+
<summary>local development</summary>
140156

141157
- Clone this repository
142-
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10)
158+
- Install latest LTS version of [Node.js](https://nodejs.org/en/)
159+
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
143160
- Install dependencies using `pnpm install`
144161
- Run interactive tests using `pnpm dev`
145162

163+
</details>
164+
146165
## License
147166

148-
Made with 💛
167+
<!-- automd:contributors author=pi0 license=MIT -->
168+
169+
Published under the [MIT](https://github.com/unjs/serve-placeholder/blob/main/LICENSE) license.
170+
Made by [@pi0](https://github.com/pi0) and [community](https://github.com/unjs/serve-placeholder/graphs/contributors) 💛
171+
<br><br>
172+
<a href="https://github.com/unjs/serve-placeholder/graphs/contributors">
173+
<img src="https://contrib.rocks/image?repo=unjs/serve-placeholder" />
174+
</a>
149175

150-
Published under [MIT License](./LICENSE).
176+
<!-- /automd -->
151177

152-
<!-- Badges -->
153-
[npm-version-src]: https://img.shields.io/npm/v/serve-placeholder?style=flat-square
154-
[npm-version-href]: https://npmjs.com/package/serve-placeholder
178+
<!-- automd:with-automd -->
155179

156-
[npm-downloads-src]: https://img.shields.io/npm/dm/serve-placeholder?style=flat-square
157-
[npm-downloads-href]: https://npmjs.com/package/serve-placeholder
180+
---
158181

159-
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/unjs/serve-placeholder/ci.yml?style=flat-square&branch=main
160-
[github-actions-href]: https://github.com/unjs/serve-placeholder/actions?query=workflow%3Aci
182+
_🤖 auto updated with [automd](https://automd.unjs.io)_
161183

162-
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/serve-placeholder/main?style=flat-square
163-
[codecov-href]: https://codecov.io/gh/unjs/serve-placeholder
184+
<!-- /automd -->

biome.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.7.1/schema.json",
3+
"formatter": {
4+
"indentStyle": "space"
5+
},
6+
"files": {
7+
"ignore": []
8+
},
9+
"javascript": {
10+
"formatter": {
11+
"arrowParentheses": "always"
12+
}
13+
},
14+
"vcs": {
15+
"enabled": true,
16+
"clientKind": "git",
17+
"useIgnoreFile": true
18+
}
19+
}

eslint.config.mjs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import unjs from "eslint-config-unjs";
2+
3+
export default unjs({
4+
ignores: [
5+
// ignore paths
6+
],
7+
rules: {
8+
// rule overrides
9+
},
10+
markdown: {
11+
rules: {
12+
// markdown rule overrides
13+
},
14+
},
15+
});

package.json

+21-19
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,40 @@
88
"type": "module",
99
"exports": {
1010
".": {
11+
"types": "./dist/index.d.ts",
1112
"import": "./dist/index.mjs",
1213
"require": "./dist/index.cjs"
1314
}
1415
},
1516
"main": "./dist/index.cjs",
1617
"module": "./dist/index.mjs",
1718
"types": "./dist/index.d.ts",
18-
"files": [
19-
"dist"
20-
],
19+
"files": ["dist"],
2120
"scripts": {
2221
"build": "unbuild",
2322
"dev": "vitest dev",
24-
"lint": "eslint --ext .ts,.js,.mjs,.cjs .",
25-
"prepack": "unbuild",
26-
"release": "pnpm test && standard-version && git push --follow-tags && pnpm publish",
27-
"test": "pnpm lint && vitest run"
23+
"lint": "eslint . && biome check .",
24+
"lint:fix": "automd && eslint . --fix && biome check --apply .",
25+
"prepack": "pnpm build",
26+
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
27+
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
28+
"test:types": "tsc --noEmit --skipLibCheck"
2829
},
2930
"dependencies": {
30-
"defu": "^6.0.0"
31+
"defu": "^6.1.4"
3132
},
3233
"devDependencies": {
33-
"@nuxtjs/eslint-config-typescript": "latest",
34-
"c8": "^7.11.0",
35-
"eslint": "latest",
36-
"h3": "^0.7.2",
37-
"listhen": "^0.2.8",
38-
"ohmyfetch": "^0.4.15",
39-
"standard-version": "latest",
40-
"typescript": "latest",
41-
"unbuild": "latest",
42-
"vitest": "^0.9.2"
34+
"@biomejs/biome": "^1.7.2",
35+
"@types/node": "^20.12.7",
36+
"@vitest/coverage-v8": "^1.5.3",
37+
"automd": "^0.3.7",
38+
"changelogen": "^0.5.5",
39+
"eslint": "^9.1.1",
40+
"eslint-config-unjs": "^0.3.2",
41+
"jiti": "^1.21.0",
42+
"typescript": "^5.4.5",
43+
"unbuild": "^2.0.0",
44+
"vitest": "^1.5.3"
4345
},
44-
"packageManager": "pnpm@6.32.4"
46+
"packageManager": "pnpm@9.0.6"
4547
}

0 commit comments

Comments
 (0)