Skip to content

Commit 76e8dc7

Browse files
Roland Grozarolandjitsu
authored andcommitted
build: modernize toolchain (TypeScript, tsdown, Vitest, oxlint/oxfmt)
1 parent b38214f commit 76e8dc7

22 files changed

Lines changed: 3831 additions & 16134 deletions

.babelrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

.codeclimate.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,35 @@ on:
77
- "[0-9]+.[0-9]+.x"
88

99
permissions:
10-
contents: read
10+
contents: read # for checkout
1111

1212
jobs:
1313
release:
1414
name: Release
1515
runs-on: ubuntu-latest
1616
permissions:
17-
contents: write
18-
issues: write
19-
pull-requests: write
20-
id-token: write
17+
contents: write # to be able to publish a GitHub release
18+
issues: write # to be able to comment on released issues
19+
pull-requests: write # to be able to comment on released pull requests
20+
id-token: write # OIDC for npm trusted publishing (+ provenance)
2121
steps:
2222
- name: Checkout repository
23-
uses: actions/checkout@v4
23+
uses: actions/checkout@v7
2424
with:
25-
fetch-depth: 0
25+
fetch-depth: 0 # fetch all history
2626

2727
- name: Setup Node.js
28-
uses: actions/setup-node@v4
28+
uses: actions/setup-node@v6
2929
with:
30-
node-version: 14
30+
node-version: 22
3131

3232
- name: Install dependencies
3333
run: npm ci
3434

35+
- name: Run build
36+
run: npm run build
37+
3538
- name: Release
36-
run: npx semantic-release@v19.0.5
3739
env:
3840
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
run: npx semantic-release@^25

.github/workflows/test.yml

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,53 @@ on:
88
pull_request:
99
types: [opened, synchronize, reopened]
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
15+
lint:
16+
name: Lint, format & types
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v7
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v6
25+
with:
26+
node-version: 24
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Type-check (tsc)
32+
run: npm run type-check
33+
34+
- name: Lint (oxlint)
35+
run: npm run lint
36+
37+
- name: Check formatting (oxfmt)
38+
run: npm run format:check
39+
40+
- name: Type-aware lint (oxlint + tsgolint)
41+
run: npm run lint:type-aware
42+
continue-on-error: true
43+
1244
test:
1345
name: Run tests on Node.js ${{ matrix.node-version }}
1446
runs-on: ubuntu-latest
1547
strategy:
48+
fail-fast: false
1649
matrix:
17-
node-version: [10, 12, 14]
50+
node-version: [20, 22, 24]
1851

1952
steps:
2053
- name: Checkout repository
21-
uses: actions/checkout@v4
54+
uses: actions/checkout@v7
2255

2356
- name: Setup Node.js
24-
uses: actions/setup-node@v4
57+
uses: actions/setup-node@v6
2558
with:
2659
node-version: ${{ matrix.node-version }}
2760

@@ -32,17 +65,26 @@ jobs:
3265
run: npm run test:cov
3366

3467
- name: Collect coverage
68+
if: matrix.node-version == 24
3569
uses: coverallsapp/github-action@v2
3670
with:
37-
flag-name: run-${{ join(matrix.*, '-') }}
38-
parallel: true
71+
file: ./coverage/lcov.info
3972

40-
coverage:
41-
name: Publish coverage
42-
needs: test
73+
size:
74+
name: Check bundle size
4375
runs-on: ubuntu-latest
76+
4477
steps:
45-
- name: Publish coverage
46-
uses: coverallsapp/github-action@v2
78+
- name: Checkout repository
79+
uses: actions/checkout@v7
80+
81+
- name: Setup Node.js
82+
uses: actions/setup-node@v6
4783
with:
48-
parallel-finished: true
84+
node-version: 24
85+
86+
- name: Install dependencies
87+
run: npm ci
88+
89+
- name: Check bundle size
90+
run: npm run size

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,3 @@ node_modules
3333
# Build files
3434
dist
3535
Changelog.md
36-
37-
# NPM files
38-
*lock.json

.npmrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# tsdown 0.22.x still declares a TypeScript peer range of `^5 || ^6`; its bundled
2+
# rolldown-plugin-dts already supports TS 7, but the top-level peer has not been widened.
3+
# We build on TypeScript 7, so relax peer resolution until tsdown ships a TS 7 peer range.
4+
legacy-peer-deps=true

.oxfmtrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"useTabs": false,
4+
"tabWidth": 2,
5+
"printWidth": 120,
6+
"singleQuote": false,
7+
"jsxSingleQuote": false,
8+
"quoteProps": "as-needed",
9+
"trailingComma": "none",
10+
"semi": true,
11+
"arrowParens": "avoid",
12+
"bracketSameLine": false,
13+
"bracketSpacing": false,
14+
"ignorePatterns": ["node_modules", "dist", "coverage"]
15+
}

.oxlintrc.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["typescript"],
4+
"categories": {
5+
"correctness": "error"
6+
},
7+
"rules": {
8+
"typescript/no-explicit-any": "off",
9+
"typescript/no-non-null-assertion": "off",
10+
"typescript/no-floating-promises": "error",
11+
"typescript/no-redundant-type-constituents": "off",
12+
"typescript/require-array-sort-compare": "off"
13+
},
14+
"overrides": [
15+
{
16+
"files": ["**/*.spec.ts"],
17+
"rules": {
18+
"typescript/no-floating-promises": "off"
19+
}
20+
}
21+
],
22+
"ignorePatterns": ["dist", "coverage"]
23+
}

README.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,53 @@
22
> JavaScript implementation of the "accept" attribute for HTML5 `<input type="file">`
33
44
[![npm](https://img.shields.io/npm/v/attr-accept.svg?style=flat-square)](https://www.npmjs.com/package/attr-accept)
5-
![Tests](https://img.shields.io/github/actions/workflow/status/react-dropzone/attr-accept/test.yml?branch=master&style=flat-square&label=tests)
5+
![Tests](https://img.shields.io/github/actions/workflow/status/react-dropzone/attr-accept/test.yml?branch=main&style=flat-square&label=tests)
66

77
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept for more information.
88

9+
Ships as both ES modules and CommonJS with bundled TypeScript type definitions.
10+
911
## Installation
1012
```sh
1113
npm install --save attr-accept
1214
```
1315

1416
## Usage
1517
```javascript
16-
var accept = require('attr-accept');
18+
import accept from "attr-accept";
19+
1720
accept({
18-
name: 'my file.png',
19-
type: 'image/png'
20-
}, 'image/*') // => true
21+
name: "my file.png",
22+
type: "image/png"
23+
}, "image/*"); // => true
2124

2225
accept({
23-
name: 'my file.json',
24-
type: 'application/json'
25-
}, 'image/*') // => false
26+
name: "my file.json",
27+
type: "application/json"
28+
}, "image/*"); // => false
2629

2730
accept({
28-
name: 'my file.srt',
29-
type: ''
30-
}, '.srt') // => true
31+
name: "my file.srt",
32+
type: ""
33+
}, ".srt"); // => true
3134
```
3235

3336
You can also pass multiple mime types as a comma delimited string or array.
3437
```javascript
3538
accept({
36-
name: 'my file.json',
37-
type: 'application/json'
38-
}, 'application/json,video/*') // => true
39+
name: "my file.json",
40+
type: "application/json"
41+
}, "application/json,video/*"); // => true
3942

4043
accept({
41-
name: 'my file.json',
42-
type: 'application/json'
43-
}, ['application/json', 'video/*']) // => true
44+
name: "my file.json",
45+
type: "application/json"
46+
}, ["application/json", "video/*"]); // => true
47+
```
48+
49+
In a CommonJS environment, use `require` instead:
50+
```javascript
51+
const accept = require("attr-accept");
4452
```
4553

4654
## Contributing

0 commit comments

Comments
 (0)