Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .babelrc

This file was deleted.

48 changes: 0 additions & 48 deletions .codeclimate.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .eslintrc

This file was deleted.

24 changes: 13 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,35 @@ on:
- "[0-9]+.[0-9]+.x"

permissions:
contents: read
contents: read # for checkout

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # OIDC for npm trusted publishing (+ provenance)
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-depth: 0 # fetch all history

- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: 14
node-version: 22

- name: Install dependencies
run: npm ci

- name: Run build
run: npm run build

- name: Release
run: npx semantic-release@v19.0.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release@^25
64 changes: 53 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,53 @@ on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
lint:
name: Lint, format & types
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24

- name: Install dependencies
run: npm ci

- name: Type-check (tsc)
run: npm run type-check

- name: Lint (oxlint)
run: npm run lint

- name: Check formatting (oxfmt)
run: npm run format:check

- name: Type-aware lint (oxlint + tsgolint)
run: npm run lint:type-aware
continue-on-error: true

test:
name: Run tests on Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [10, 12, 14]
node-version: [20, 22, 24]

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -32,17 +65,26 @@ jobs:
run: npm run test:cov

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

coverage:
name: Publish coverage
needs: test
size:
name: Check bundle size
runs-on: ubuntu-latest

steps:
- name: Publish coverage
uses: coverallsapp/github-action@v2
- name: Checkout repository
uses: actions/checkout@v7

- name: Setup Node.js
uses: actions/setup-node@v6
with:
parallel-finished: true
node-version: 24

- name: Install dependencies
run: npm ci

- name: Check bundle size
run: npm run size
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,3 @@ node_modules
# Build files
dist
Changelog.md

# NPM files
*lock.json
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# tsdown 0.22.x still declares a TypeScript peer range of `^5 || ^6`; its bundled
# rolldown-plugin-dts already supports TS 7, but the top-level peer has not been widened.
# We build on TypeScript 7, so relax peer resolution until tsdown ships a TS 7 peer range.
legacy-peer-deps=true
15 changes: 15 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"useTabs": false,
"tabWidth": 2,
"printWidth": 120,
"singleQuote": false,
"jsxSingleQuote": false,
"quoteProps": "as-needed",
"trailingComma": "none",
"semi": true,
"arrowParens": "avoid",
"bracketSameLine": false,
"bracketSpacing": false,
"ignorePatterns": ["node_modules", "dist", "coverage"]
}
23 changes: 23 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["typescript"],
"categories": {
"correctness": "error"
},
"rules": {
"typescript/no-explicit-any": "off",
"typescript/no-non-null-assertion": "off",
"typescript/no-floating-promises": "error",
"typescript/no-redundant-type-constituents": "off",
"typescript/require-array-sort-compare": "off"
},
"overrides": [
{
"files": ["**/*.spec.ts"],
"rules": {
"typescript/no-floating-promises": "off"
}
}
],
"ignorePatterns": ["dist", "coverage"]
}
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,53 @@
> JavaScript implementation of the "accept" attribute for HTML5 `<input type="file">`

[![npm](https://img.shields.io/npm/v/attr-accept.svg?style=flat-square)](https://www.npmjs.com/package/attr-accept)
![Tests](https://img.shields.io/github/actions/workflow/status/react-dropzone/attr-accept/test.yml?branch=master&style=flat-square&label=tests)
![Tests](https://img.shields.io/github/actions/workflow/status/react-dropzone/attr-accept/test.yml?branch=main&style=flat-square&label=tests)

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

Ships as both ES modules and CommonJS with bundled TypeScript type definitions.

## Installation
```sh
npm install --save attr-accept
```

## Usage
```javascript
var accept = require('attr-accept');
import accept from "attr-accept";

accept({
name: 'my file.png',
type: 'image/png'
}, 'image/*') // => true
name: "my file.png",
type: "image/png"
}, "image/*"); // => true

accept({
name: 'my file.json',
type: 'application/json'
}, 'image/*') // => false
name: "my file.json",
type: "application/json"
}, "image/*"); // => false

accept({
name: 'my file.srt',
type: ''
}, '.srt') // => true
name: "my file.srt",
type: ""
}, ".srt"); // => true
```

You can also pass multiple mime types as a comma delimited string or array.
```javascript
accept({
name: 'my file.json',
type: 'application/json'
}, 'application/json,video/*') // => true
name: "my file.json",
type: "application/json"
}, "application/json,video/*"); // => true

accept({
name: 'my file.json',
type: 'application/json'
}, ['application/json', 'video/*']) // => true
name: "my file.json",
type: "application/json"
}, ["application/json", "video/*"]); // => true
```

In a CommonJS environment, use `require` instead:
```javascript
const accept = require("attr-accept");
```

## Contributing
Expand Down
1 change: 0 additions & 1 deletion index.d.ts

This file was deleted.

Loading