Skip to content

Commit f09ac75

Browse files
committed
style: align oxfmt with react-dropzone, format all file types
1 parent 3c3d3c1 commit f09ac75

27 files changed

Lines changed: 2548 additions & 2542 deletions

‎.editorconfig‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ root = true
55

66
[*]
77
indent_style = space
8-
indent_size = 4
8+
indent_size = 2
9+
end_of_line = lf
910
charset = utf-8
1011
trim_trailing_whitespace = true
1112
insert_final_newline = true
1213

13-
[*{.yml}]
14-
indent_size = 2
15-
1614
[*.md]
1715
trim_trailing_whitespace = false
1816
max_line_length = off

‎.github/workflows/release.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
name: Release
1515
runs-on: ubuntu-latest
1616
permissions:
17-
contents: write # to be able to publish a GitHub release
18-
issues: write # to be able to comment on released issues
17+
contents: write # to be able to publish a GitHub release
18+
issues: write # to be able to comment on released issues
1919
pull-requests: write # to be able to comment on released pull requests
20-
id-token: write # OIDC for npm trusted publishing (+ provenance)
20+
id-token: write # OIDC for npm trusted publishing (+ provenance)
2121
steps:
2222
- name: Checkout repository
2323
uses: actions/checkout@v7

‎.oxfmtrc.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"$schema": "./node_modules/oxfmt/configuration_schema.json",
33
"useTabs": false,
4-
"tabWidth": 4,
4+
"tabWidth": 2,
55
"printWidth": 120,
6-
"singleQuote": true,
6+
"singleQuote": false,
77
"jsxSingleQuote": false,
88
"quoteProps": "as-needed",
99
"trailingComma": "none",
1010
"semi": true,
1111
"arrowParens": "avoid",
1212
"bracketSameLine": false,
1313
"bracketSpacing": false,
14-
"ignorePatterns": []
14+
"ignorePatterns": ["node_modules", "dist", "site", "coverage", "docs/dist", "docs/pages.gen.ts", ".vocs", "**/*.mdx"]
1515
}

‎.oxlintrc.json‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
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"]
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"]
2323
}

‎README.md‎

Lines changed: 78 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -13,159 +13,179 @@
1313

1414
# Table of Contents
1515

16-
* [Installation](#installation)
17-
* [Usage](#usage)
18-
* [Browser Support](#browser-support)
19-
* [Contribute](#contribute)
20-
* [Credits](#credits)
21-
* [Support](#support)
22-
* [License](#license)
23-
16+
- [Installation](#installation)
17+
- [Usage](#usage)
18+
- [Browser Support](#browser-support)
19+
- [Contribute](#contribute)
20+
- [Credits](#credits)
21+
- [Support](#support)
22+
- [License](#license)
2423

2524
## Installation
25+
2626
You can install this package from [NPM](https://www.npmjs.com):
27+
2728
```bash
2829
npm add file-selector
2930
```
3031

3132
### CDN
33+
3234
For CDN usage, load the ESM build directly from a CDN such as [esm.sh](https://esm.sh) or [jsDelivr](https://www.jsdelivr.com/package/npm/file-selector):
35+
3336
```html
3437
<script type="module">
35-
import {fromEvent} from 'https://esm.sh/file-selector';
38+
import {fromEvent} from "https://esm.sh/file-selector";
3639
37-
document.addEventListener('drop', async evt => {
38-
const files = await fromEvent(evt);
39-
console.log(files);
40-
});
40+
document.addEventListener("drop", async evt => {
41+
const files = await fromEvent(evt);
42+
console.log(files);
43+
});
4144
</script>
4245
```
4346

44-
4547
## Usage
4648

4749
### ES6
50+
4851
Convert a [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent) to File objects:
52+
4953
```ts
50-
import {fromEvent} from 'file-selector';
51-
document.addEventListener('drop', async evt => {
52-
const files = await fromEvent(evt);
53-
console.log(files);
54+
import {fromEvent} from "file-selector";
55+
document.addEventListener("drop", async evt => {
56+
const files = await fromEvent(evt);
57+
console.log(files);
5458
});
5559
```
5660

5761
Convert a [change event](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event) for an input type file to File objects:
62+
5863
```ts
59-
import {fromEvent} from 'file-selector';
60-
const input = document.getElementById('myInput');
61-
input.addEventListener('change', async evt => {
62-
const files = await fromEvent(evt);
63-
console.log(files);
64+
import {fromEvent} from "file-selector";
65+
const input = document.getElementById("myInput");
66+
input.addEventListener("change", async evt => {
67+
const files = await fromEvent(evt);
68+
console.log(files);
6469
});
6570
```
6671

6772
Convert [FileSystemFileHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle) items to File objects:
73+
6874
```ts
69-
import {fromEvent} from 'file-selector';
75+
import {fromEvent} from "file-selector";
7076

7177
// Open file picker
7278
const handles = await window.showOpenFilePicker({multiple: true});
7379
// Get the files
7480
const files = await fromEvent(handles);
7581
console.log(files);
7682
```
83+
7784
**NOTE** The above is experimental and subject to change.
7885

7986
### CommonJS
87+
8088
Convert a `DragEvent` to File objects:
89+
8190
```ts
82-
const {fromEvent} = require('file-selector');
83-
document.addEventListener('drop', async evt => {
84-
const files = await fromEvent(evt);
85-
console.log(files);
91+
const {fromEvent} = require("file-selector");
92+
document.addEventListener("drop", async evt => {
93+
const files = await fromEvent(evt);
94+
console.log(files);
8695
});
8796
```
8897

8998
### MIME types
99+
90100
When the browser doesn't set a File's `type`, `fromEvent` infers one from the file extension. By default it uses a small built-in table of the most common types, keeping the bundle lean.
91101

92102
If you need broader coverage, import the full extension-to-MIME table from the `file-selector/mime` subpath and pass it via the `mimeTypes` option. Because it's a separate entry point, the full table (~1,200 entries) is only included in your bundle when you import it:
103+
93104
```ts
94-
import {fromEvent} from 'file-selector';
95-
import {COMMON_MIME_TYPES} from 'file-selector/mime';
105+
import {fromEvent} from "file-selector";
106+
import {COMMON_MIME_TYPES} from "file-selector/mime";
96107

97108
const files = await fromEvent(evt, {mimeTypes: COMMON_MIME_TYPES});
98109
```
99110

100111
You can also pass your own `Map<extension, mimeType>` to restrict or extend the lookup:
112+
101113
```ts
102-
const files = await fromEvent(evt, {mimeTypes: new Map([['dwg', 'image/vnd.dwg']])});
114+
const files = await fromEvent(evt, {mimeTypes: new Map([["dwg", "image/vnd.dwg"]])});
103115
```
104116

105-
106117
## Browser Support
118+
107119
Most browser support basic File selection with drag 'n' drop or file input:
108-
* [File API](https://developer.mozilla.org/en-US/docs/Web/API/File#Browser_compatibility)
109-
* [Drag Event](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent#Browser_compatibility)
110-
* [DataTransfer](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer#Browser_compatibility)
111-
* [`<input type="file">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Browser_compatibility)
120+
121+
- [File API](https://developer.mozilla.org/en-US/docs/Web/API/File#Browser_compatibility)
122+
- [Drag Event](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent#Browser_compatibility)
123+
- [DataTransfer](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer#Browser_compatibility)
124+
- [`<input type="file">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Browser_compatibility)
112125

113126
For folder drop we use the [FileSystem API](https://developer.mozilla.org/en-US/docs/Web/API/FileSystem) which has very limited support:
114-
* [DataTransferItem.getAsFile()](https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/getAsFile#Browser_compatibility)
115-
* [DataTransferItem.webkitGetAsEntry()](https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry#Browser_compatibility)
116-
* [FileSystemEntry](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemEntry#Browser_compatibility)
117-
* [FileSystemFileEntry.file()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileEntry/file#Browser_compatibility)
118-
* [FileSystemDirectoryEntry.createReader()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry/createReader#Browser_compatibility)
119-
* [FileSystemDirectoryReader.readEntries()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryReader/readEntries#Browser_compatibility)
120127

128+
- [DataTransferItem.getAsFile()](https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/getAsFile#Browser_compatibility)
129+
- [DataTransferItem.webkitGetAsEntry()](https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry#Browser_compatibility)
130+
- [FileSystemEntry](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemEntry#Browser_compatibility)
131+
- [FileSystemFileEntry.file()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileEntry/file#Browser_compatibility)
132+
- [FileSystemDirectoryEntry.createReader()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry/createReader#Browser_compatibility)
133+
- [FileSystemDirectoryReader.readEntries()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryReader/readEntries#Browser_compatibility)
121134

122135
## Contribute
136+
123137
Checkout the organization [CONTRIBUTING.md](https://github.com/react-dropzone/.github/blob/main/CONTRIBUTING.md).
124138

125139
### Development
126140

127141
Development requires [Node.js](https://nodejs.org) >= 20. Install the dependencies with:
142+
128143
```bash
129144
npm install
130145
```
131146

132147
The project is built with [tsdown](https://tsdown.dev) (Rolldown), type-checked with [TypeScript](https://www.typescriptlang.org), tested with [Vitest](https://vitest.dev) and linted/formatted with [oxlint](https://oxc.rs) and [oxfmt](https://oxc.rs).
133148

134-
| Command | Description |
135-
| --- | --- |
136-
| `npm test` | Run the test suite in watch mode. |
137-
| `npm run test:cov` | Run the tests once with coverage (runs type-check, lint and format check first). |
138-
| `npm run type-check` | Type-check the sources without emitting. |
139-
| `npm run lint` | Lint the sources (oxlint). |
140-
| `npm run lint:fix` | Apply safe lint fixes. |
141-
| `npm run lint:type-aware` | Type-aware lint via tsgolint (alpha). |
142-
| `npm run format` | Format the sources (oxfmt). |
143-
| `npm run format:check` | Check formatting without writing. |
144-
| `npm run build` | Build the outputs into `dist/`. |
145-
| `npm run dev` | Build in watch mode. |
146-
| `npm run docs:dev` | Run the [Vocs](https://vocs.dev) docs site locally. |
147-
| `npm run docs:build` | Build the docs site into `site/`. |
148-
| `npm run docs:preview` | Preview the built docs site. |
149+
| Command | Description |
150+
| ------------------------- | -------------------------------------------------------------------------------- |
151+
| `npm test` | Run the test suite in watch mode. |
152+
| `npm run test:cov` | Run the tests once with coverage (runs type-check, lint and format check first). |
153+
| `npm run type-check` | Type-check the sources without emitting. |
154+
| `npm run lint` | Lint the sources (oxlint). |
155+
| `npm run lint:fix` | Apply safe lint fixes. |
156+
| `npm run lint:type-aware` | Type-aware lint via tsgolint (alpha). |
157+
| `npm run format` | Format the sources (oxfmt). |
158+
| `npm run format:check` | Check formatting without writing. |
159+
| `npm run build` | Build the outputs into `dist/`. |
160+
| `npm run dev` | Build in watch mode. |
161+
| `npm run docs:dev` | Run the [Vocs](https://vocs.dev) docs site locally. |
162+
| `npm run docs:build` | Build the docs site into `site/`. |
163+
| `npm run docs:preview` | Preview the built docs site. |
149164

150165
The build emits into `dist/`:
166+
151167
- `dist/index.js` — ES module
152168
- `dist/index.cjs` — CommonJS module
153169
- `dist/index.d.ts` — TypeScript declarations
154170

155171
## Credits
156-
* [html5-file-selector](https://github.com/quarklemotion/html5-file-selector)
172+
173+
- [html5-file-selector](https://github.com/quarklemotion/html5-file-selector)
157174

158175
## Support
159176

160177
### Backers
178+
161179
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/react-dropzone#backer)]
162180

163181
<a href="https://opencollective.com/react-dropzone#backers" target="_blank"><img src="https://opencollective.com/react-dropzone/backers.svg?width=890"></a>
164182

165183
### Sponsors
184+
166185
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/react-dropzone#sponsor)]
167186

168187
<a href="https://opencollective.com/react-dropzone#sponsors" target="_blank"><img src="https://opencollective.com/react-dropzone/sponsors.svg?width=890"></a>
169188

170189
## License
190+
171191
MIT

0 commit comments

Comments
 (0)