Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sync main w/ beta #97

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
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.

13 changes: 0 additions & 13 deletions .editorconfig

This file was deleted.

7 changes: 0 additions & 7 deletions .eslintrc

This file was deleted.

16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ 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 # to enable use of OIDC for npm provenance
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 0 # fetch all history

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

- name: Install dependencies
run: npm ci

- name: Release
run: npx [email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
23 changes: 8 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10, 12, 14]
node-version: [18, 20, 22]

steps:
- name: Checkout repository
Expand All @@ -29,20 +29,13 @@ jobs:
run: npm ci

- name: Run tests
run: npm run test:cov
if: matrix.node-version != 22
run: npm test

- name: Collect coverage
uses: coverallsapp/github-action@v2
with:
flag-name: run-${{ join(matrix.*, '-') }}
parallel: true
- name: Run tests with coverage
if: matrix.node-version == 22
run: npm run test:coverage

coverage:
name: Publish coverage
needs: test
runs-on: ubuntu-latest
steps:
- name: Publish coverage
- name: Collect coverage
if: matrix.node-version == 22
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lib-cov

# Coverage directory used by tools like istanbul
coverage
.nyc_output
lcov.info

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
Expand All @@ -31,7 +31,6 @@ node_modules
.idea

# Build files
dist
Changelog.md

# NPM files
Expand Down
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit $1
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
4 changes: 0 additions & 4 deletions .releaserc.yaml

This file was deleted.

67 changes: 43 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# attr-accept

> 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)
Expand All @@ -7,40 +8,58 @@
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept for more information.

## Installation

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

## Usage

```javascript
var accept = require('attr-accept');
accept({
name: 'my file.png',
type: 'image/png'
}, 'image/*') // => true

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

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

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

accept(
{
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

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

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

## Contributing
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default { extends: ["@commitlint/config-conventional"] };
9 changes: 9 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import eslint from "@eslint/js";
import importPlugin from "eslint-plugin-import";
import eslintConfigPrettier from "eslint-config-prettier";

export default [
eslint.configs.recommended,
importPlugin.flatConfigs.recommended,
eslintConfigPrettier,
];
5 changes: 4 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export default function accept(file: { name?: string, type?: string }, acceptedFiles: string | string[]): boolean;
export default function accept(
file: { name?: string; type?: string },
acceptedFiles: string | string[],
): boolean;
Loading