Skip to content

Commit 5a3544f

Browse files
jonkoopsrolandjitsu
authored andcommitted
chore: add Prettier to format code
Signed-off-by: Jon Koops <[email protected]>
1 parent b387ef8 commit 5a3544f

15 files changed

+2198
-2090
lines changed

.editorconfig

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

.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 # to enable use of OIDC for npm provenance
20+
id-token: write # to enable use of OIDC for npm provenance
2121
steps:
2222
- name: Checkout repository
2323
uses: actions/checkout@v4

.github/workflows/stale.yml

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

README.md

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111

1212
# Table of Contents
1313

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

2322
## Installation
2423

@@ -33,7 +32,7 @@ npm add file-selector
3332
If you are using a bundler such as [Vite](https://vite.dev/) or [Webpack](https://webpack.js.org/) you can import the package directly:
3433

3534
```js
36-
import {fromEvent} from 'file-selector';
35+
import { fromEvent } from "file-selector";
3736
```
3837

3938
### Browser
@@ -46,7 +45,7 @@ If you want to use a CDN, you can use [Skypack](https://www.skypack.dev/), or an
4645

4746
```html
4847
<script type="module">
49-
import {fromEvent} from 'https://cdn.skypack.dev/file-selector@^1.0.0';
48+
import { fromEvent } from "https://cdn.skypack.dev/file-selector@^1.0.0";
5049
</script>
5150
```
5251

@@ -56,7 +55,7 @@ Self hosting is also possible, make sure to copy or link the contents of the NPM
5655

5756
```html
5857
<script type="module">
59-
import {fromEvent} from './path/to/file-selector.js';
58+
import { fromEvent } from "./path/to/file-selector.js";
6059
</script>
6160
```
6261

@@ -66,17 +65,17 @@ To avoid repeating the import path and get an experience similar to a bundler yo
6665

6766
```html
6867
<script type="importmap">
69-
{
70-
"imports": {
71-
// Using the CDN
72-
"file-selector": "https://cdn.skypack.dev/file-selector@^1.0.0"
73-
// Or a path to your own self-hosted version.
74-
"file-selector": "./path/to/file-selector.js"
75-
}
68+
{
69+
"imports": {
70+
// Using the CDN
71+
"file-selector": "https://cdn.skypack.dev/file-selector@^1.0.0"
72+
// Or a path to your own self-hosted version.
73+
"file-selector": "./path/to/file-selector.js"
7674
}
75+
}
7776
</script>
7877
<script type="module">
79-
import {fromEvent} from 'file-selector';
78+
import { fromEvent } from "file-selector";
8079
</script>
8180
```
8281

@@ -85,64 +84,69 @@ To avoid repeating the import path and get an experience similar to a bundler yo
8584
Convert a [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent) to File objects:
8685

8786
```js
88-
import {fromEvent} from 'file-selector';
87+
import { fromEvent } from "file-selector";
8988

90-
document.addEventListener('drop', async (event) => {
91-
const files = await fromEvent(event);
92-
console.log(files);
89+
document.addEventListener("drop", async (event) => {
90+
const files = await fromEvent(event);
91+
console.log(files);
9392
});
9493
```
9594

9695
Convert a [change event](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event) for an input type file to File objects:
9796

9897
```js
99-
import {fromEvent} from 'file-selector';
98+
import { fromEvent } from "file-selector";
10099

101-
const input = document.getElementById('myInput');
102-
input.addEventListener('change', async (event) => {
103-
const files = await fromEvent(event);
104-
console.log(files);
100+
const input = document.getElementById("myInput");
101+
input.addEventListener("change", async (event) => {
102+
const files = await fromEvent(event);
103+
console.log(files);
105104
});
106105
```
107106

108107
Convert [FileSystemFileHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle) items to File objects:
109108

110109
```js
111-
import {fromEvent} from 'file-selector';
110+
import { fromEvent } from "file-selector";
112111

113-
const handles = await window.showOpenFilePicker({multiple: true});
112+
const handles = await window.showOpenFilePicker({ multiple: true });
114113
const files = await fromEvent(handles);
115114
console.log(files);
116115
```
117116

118-
> [!NOTE]
117+
> [!NOTE]
119118
> The above is experimental and subject to change.
120119
121120
## Browser Support
121+
122122
Most browser support basic File selection with drag 'n' drop or file input:
123-
* [File API](https://developer.mozilla.org/en-US/docs/Web/API/File#Browser_compatibility)
124-
* [Drag Event](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent#Browser_compatibility)
125-
* [DataTransfer](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer#Browser_compatibility)
126-
* [`<input type="file">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Browser_compatibility)
123+
124+
- [File API](https://developer.mozilla.org/en-US/docs/Web/API/File#Browser_compatibility)
125+
- [Drag Event](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent#Browser_compatibility)
126+
- [DataTransfer](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer#Browser_compatibility)
127+
- [`<input type="file">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Browser_compatibility)
127128

128129
For folder drop we use the [FileSystem API](https://developer.mozilla.org/en-US/docs/Web/API/FileSystem) which has very limited support:
129-
* [DataTransferItem.getAsFile()](https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/getAsFile#Browser_compatibility)
130-
* [DataTransferItem.webkitGetAsEntry()](https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry#Browser_compatibility)
131-
* [FileSystemEntry](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemEntry#Browser_compatibility)
132-
* [FileSystemFileEntry.file()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileEntry/file#Browser_compatibility)
133-
* [FileSystemDirectoryEntry.createReader()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry/createReader#Browser_compatibility)
134-
* [FileSystemDirectoryReader.readEntries()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryReader/readEntries#Browser_compatibility)
135130

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

137138
## Contribute
139+
138140
Checkout the organization [CONTRIBUTING.md](https://github.com/react-dropzone/.github/blob/main/CONTRIBUTING.md).
139141

140142
## Credits
141-
* [html5-file-selector](https://github.com/quarklemotion/html5-file-selector)
143+
144+
- [html5-file-selector](https://github.com/quarklemotion/html5-file-selector)
142145

143146
## Support
144147

145148
### Backers
149+
146150
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/react-dropzone#backer)]
147151

148152
<a href="https://opencollective.com/react-dropzone/backer/0/website" target="_blank"><img src="https://opencollective.com/react-dropzone/backer/0/avatar.svg"></a>
@@ -158,6 +162,7 @@ Support us with a monthly donation and help us continue our activities. [[Become
158162
<a href="https://opencollective.com/react-dropzone/backer/10/website" target="_blank"><img src="https://opencollective.com/react-dropzone/backer/10/avatar.svg"></a>
159163

160164
### Sponsors
165+
161166
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)]
162167

163168
<a href="https://opencollective.com/react-dropzone/sponsor/0/website" target="_blank"><img src="https://opencollective.com/react-dropzone/sponsor/0/avatar.svg"></a>
@@ -173,4 +178,5 @@ Become a sponsor and get your logo on our README on Github with a link to your s
173178
<a href="https://opencollective.com/react-dropzone/sponsor/10/website" target="_blank"><img src="https://opencollective.com/react-dropzone/sponsor/10/avatar.svg"></a>
174179

175180
## License
181+
176182
MIT

eslint.config.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import eslint from '@eslint/js';
2-
import tseslint from 'typescript-eslint';
1+
import eslint from "@eslint/js";
2+
import tseslint from "typescript-eslint";
3+
import eslintConfigPrettier from "eslint-config-prettier";
34

45
export default tseslint.config(
5-
eslint.configs.recommended,
6-
...tseslint.configs.recommended,
7-
{
8-
rules: {
9-
// TODO: Fix these rule and remove their overrides.
10-
'@typescript-eslint/no-empty-object-type': 'off',
11-
'@typescript-eslint/no-explicit-any': 'off',
12-
}
13-
}
6+
eslint.configs.recommended,
7+
...tseslint.configs.recommended,
8+
{
9+
rules: {
10+
// TODO: Fix these rule and remove their overrides.
11+
"@typescript-eslint/no-empty-object-type": "off",
12+
"@typescript-eslint/no-explicit-any": "off",
13+
},
14+
},
15+
eslintConfigPrettier,
1416
);

jest.config.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { createDefaultEsmPreset } from 'ts-jest'
1+
import { createDefaultEsmPreset } from "ts-jest";
22

3-
const defaultPreset = createDefaultEsmPreset()
3+
const defaultPreset = createDefaultEsmPreset();
44

55
/** @type {import('ts-jest').JestConfigWithTsJest} */
66
const jestConfig = {
7-
...defaultPreset,
8-
testEnvironment: 'jsdom',
9-
// Convert `.js` imports to one without an extension to support 'NodeNext' module resolution.
10-
moduleNameMapper: {
11-
'^(\\.{1,2}/.*)\\.js$': '$1'
12-
}
13-
}
7+
...defaultPreset,
8+
testEnvironment: "jsdom",
9+
// Convert `.js` imports to one without an extension to support 'NodeNext' module resolution.
10+
moduleNameMapper: {
11+
"^(\\.{1,2}/.*)\\.js$": "$1",
12+
},
13+
};
1414

15-
export default jestConfig
15+
export default jestConfig;

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
},
3737
"scripts": {
3838
"build": "rm -rf dist && tsc -p ./tsconfig.build.json",
39-
"lint": "eslint .",
39+
"lint": "prettier . --check && eslint .",
40+
"lint:fix": "prettier --write . && eslint . --fix",
4041
"test": "jest"
4142
},
4243
"devDependencies": {
@@ -45,8 +46,10 @@
4546
"@types/jest": "^29.5.13",
4647
"@types/node": "^22.7.5",
4748
"eslint": "^9.14.0",
49+
"eslint-config-prettier": "^9.1.0",
4850
"jest": "^29.7.0",
4951
"jest-environment-jsdom": "^29.7.0",
52+
"prettier": "^3.3.3",
5053
"ts-jest": "^29.2.5",
5154
"typescript": "^5.6.3",
5255
"typescript-eslint": "^8.12.2"

0 commit comments

Comments
 (0)