Skip to content

chore: update and cleanup deps #76

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

Merged
merged 7 commits into from
Nov 25, 2024
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
13 changes: 0 additions & 13 deletions .editorconfig

This file was deleted.

6 changes: 0 additions & 6 deletions .eslintrc

This file was deleted.

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
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
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
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