Skip to content

Commit bfad24d

Browse files
committed
Merge pull request #404 from antonioru/feat/remove_index
Version 4.0.0 BREAKING CHANGE: removes index.ts file from src directory
2 parents cadce30 + df90cd3 commit bfad24d

File tree

130 files changed

+3312
-1894
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+3312
-1894
lines changed

.eslintrc

-45
This file was deleted.

.eslintrc.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true
5+
},
6+
extends: [
7+
'plugin:react/recommended',
8+
'standard-with-typescript'
9+
],
10+
parserOptions: {
11+
project: './tsconfig.json',
12+
ecmaVersion: 'latest',
13+
sourceType: 'module'
14+
},
15+
plugins: [
16+
'react'
17+
],
18+
rules: {
19+
'max-len': [
20+
'error',
21+
{
22+
code: 140
23+
}
24+
],
25+
semi: [
26+
2,
27+
'never'
28+
],
29+
'@typescript-eslint/semi': 'off',
30+
'linebreak-style': 'off',
31+
'object-curly-newline': 'off',
32+
'react/jsx-filename-extension': 'off',
33+
'import/no-named-as-default': 'off',
34+
'import/no-named-as-default-member': 'off',
35+
'@typescript-eslint/explicit-function-return-type': 'off',
36+
'@typescript-eslint/strict-boolean-expressions': 'off',
37+
'@typescript-eslint/no-non-null-assertion': 'off'
38+
},
39+
overrides: [
40+
{
41+
files: [
42+
'*.test.js',
43+
'*.spec.js',
44+
'*.test.jsx',
45+
'*.spec.jsx'
46+
],
47+
globals: {
48+
expect: 'readonly',
49+
should: 'readonly',
50+
sinon: 'readonly'
51+
},
52+
rules: {
53+
'no-unused-expressions': 'off'
54+
}
55+
}
56+
]
57+
}

.github/workflows/branch-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ on:
1111
jobs:
1212
test:
1313
if: "!contains(github.event.head_commit.message, 'skip ci')"
14-
runs-on: ${{ matrix.os }}
14+
runs-on: ubuntu-latest
1515

1616
strategy:
1717
matrix:
18-
node-version: 18
18+
node-version: [ 18.14 ]
1919

2020
steps:
2121
- uses: actions/checkout@v2

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717
- uses: actions/checkout@v2
1818
- uses: actions/setup-node@v1
1919
with:
20-
node-version: 18
20+
node-version: 18.14
2121
registry-url: https://registry.npmjs.org/
2222

2323
- name: NPM CI
24-
run: npm install --force
24+
run: npm install
2525

2626
- name: Repository build
2727
run: npm run build
@@ -45,7 +45,7 @@ jobs:
4545
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4646

4747
- name: Prepare distribution
48-
run: cp package.json README.md LICENSE CHANGELOG.md CONTRIBUTING.md CODE_OF_CONDUCT.md ./dist
48+
run: cp package.json README.md LICENSE.txt CHANGELOG.md CONTRIBUTING.md CODE_OF_CONDUCT.md ./dist
4949

5050
- name: Publish
5151
run: |

.nycrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"extension": [ ".js" ],
66
"include": [ "dist/*.js" ],
77
"exclude": [ "dist/index.js", "dist/_virtual/**/*.js" ],
8-
"branches": 60,
9-
"lines": 70,
8+
"branches": 50,
9+
"lines": 80,
1010
"functions": 70,
1111
"statements": 70
1212
}

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -999,3 +999,12 @@ Errored release
999999
### Fixes
10001000

10011001
- `useLocalStorage` and `useSessionStorage` no longer return a new `setValue` function everytime `setValue` is called
1002+
1003+
## [4.0.0] - 2023-03-13
1004+
1005+
### Breaking Changes
1006+
1007+
- Removes `index.ts` file from `src` folder
1008+
- Updates dependencies
1009+
- Improves documentation
1010+
- Improves types

HOOK_DOCUMENTATION_TEMPLATE.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# useYourHookName
22

3-
-- A short description of your hook --
3+
A hook that [...]
44

55
### 💡 Why?
66

@@ -9,12 +9,11 @@
99
### Basic Usage:
1010

1111
```jsx harmony
12-
import { yourHook } from 'beautiful-react-hooks';
13-
12+
import { yourHook } from 'beautiful-react-hooks';
1413

1514
const YourExample = () => {
1615
/* Your code goes here */
17-
16+
1817
return null;
1918
};
2019

@@ -26,12 +25,11 @@ const YourExample = () => {
2625
description of the use case
2726

2827
```jsx harmony
29-
import { yourHook } from 'beautiful-react-hooks';
30-
28+
import { yourHook } from 'beautiful-react-hooks';
3129

3230
const YourUseCase = () => {
3331
/* Your code goes here */
34-
32+
3533
return null;
3634
};
3735

@@ -41,9 +39,11 @@ const YourUseCase = () => {
4139
### Mastering the hooks
4240

4341
#### ✅ When to use
44-
42+
4543
- When it's good to use
4644

4745
#### 🛑 When not to use
4846

4947
- When it's not good to use
48+
49+
<!-- Types -->

LICENSE LICENSE.txt

File renamed without changes.

README.md

+26-26
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.or
1313
<br />
1414
<div>
1515
<p align="center">
16-
A collection of beautiful (and hopefully useful) React hooks to speed-up your
17-
components and hooks development
16+
A collection of tailor-made React hooks to enhance your development process and make it faster.
1817
</p>
1918
</div>
2019

2120
<div>
2221
<p align="center">
2322
<a href="https://antonioru.github.io/beautiful-react-hooks/" target="_blank">
24-
🌟 Live playground here 🌟
23+
🌟 Hooks Playground 🌟
2524
</a>
2625
</p>
2726
</div>
@@ -38,13 +37,13 @@ MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.or
3837

3938
## 💡 Why?
4039

41-
React custom hooks allow to abstract components' business logic into single reusable functions.<br />
42-
So far, we've found that most of the hooks we've created and therefore shared between our internal projects have quite often a similar gist
43-
that involves callback references, events and components' lifecycle. <br />
44-
For this reason we've tried to sum up that gist into `beautiful-react-hooks`: a collection of (*hopefully*) useful React hooks to possibly
45-
help other companies and professionals to speed up their development process.<br /><br />
46-
Furthermore, we created a concise yet concrete API having in mind the code readability, focusing to keep the learning curve as lower as
47-
possible so that the it can be used and shared in bigger teams.
40+
Custom React hooks allow developers to abstract the business logic of components into single, reusable functions.\
41+
I have noticed that many of the hooks I have created and shared across projects involve callbacks, references, events, and dealing with the
42+
component lifecycle.\
43+
Therefore, I have created `beautiful-react-hooks`, a collection of useful [React hooks](https://beta.reactjs.org/reference/react) that may
44+
help other developers speed up their development process.\
45+
Moreover, I have strived to create a concise and practical API that emphasizes code readability, while keeping the learning curve as low as
46+
possible, making it suitable for larger teams to use and share
4847

4948
**-- Please before using any hook, read its documentation! --**
5049

@@ -57,7 +56,7 @@ possible so that the it can be used and shared in bigger teams.
5756
<div>
5857
<p align="center">
5958
<a href="https://antonioru.github.io/beautiful-react-hooks/" target="_blank">
60-
🌟 Live playground here 🌟
59+
🌟 Hooks Playground 🌟
6160
</a>
6261
</p>
6362
</div>
@@ -76,6 +75,14 @@ by using `yarn`:
7675
$ yarn add beautiful-react-hooks
7776
```
7877

78+
## Basic usage
79+
80+
importing a hooks is as easy as the following straightforward line:
81+
82+
```ts static
83+
import useSomeHook from 'beautiful-react-hooks/useSomeHook'
84+
```
85+
7986
## 🎨 Hooks
8087

8188
* [useQueryParam](docs/useQueryParam.md)
@@ -127,36 +134,29 @@ $ yarn add beautiful-react-hooks
127134
<div>
128135
<p align="center">
129136
<a href="https://antonioru.github.io/beautiful-react-hooks/" target="_blank">
130-
🌟 Live playground here 🌟
137+
🌟 Hooks Playground 🌟
131138
</a>
132139
</p>
133140
</div>
134141

135142
## Peer dependencies
136143

137-
Some hooks are built on top of third-party libraries (rxjs, react-router-dom, redux), therefore you will notice those libraries listed as
138-
peer dependencies. You don't have to install these dependencies unless you directly use those hooks.
144+
Some hooks are built using third-party libraries (such as rxjs, react-router-dom, redux). As a result, you will see these libraries listed
145+
as peer dependencies.\
146+
Unless you are using these hooks directly, you need not install these dependencies.
139147

140148
## Contributing
141149

142150
Contributions are very welcome and wanted.
143151

144-
To submit your custom hook, please make sure your read our [CONTRIBUTING](./CONTRIBUTING.md) guidelines.
152+
To submit your custom hook, make sure you have thoroughly read and understood the [CONTRIBUTING](./CONTRIBUTING.md) guidelines.
145153

146-
**Before submitting** a new merge request, please make sure:
154+
**Prior to submitting your pull request**: please take note of the following
147155

148156
1. make sure to write tests for your code, run `npm test` and `npm build` before submitting your merge request.
149-
2. in case you're creating a custom hook, make sure you've added the documentation (*you can possibly use
157+
2. in case you're creating a custom hook, make sure you've added the documentation (*you may use
150158
the [HOOK_DOCUMENTATION_TEMPLATE](./HOOK_DOCUMENTATION_TEMPLATE.md) to document your custom hook*).
151159

152-
### Made with
153-
154-
* [React](https://reactjs.org/)
155-
* [Mocha](https://mochajs.org/)
156-
* [Chai](https://www.chaijs.com/)
157-
* [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro)
158-
* [@testing-library/react-hooks](https://react-hooks-testing-library.com/)
159-
160-
---
160+
## Credits
161161

162162
Icon made by [Freepik](https://www.flaticon.com/authors/freepik) from [www.flaticon.com](https://www.flaticon.com/free-icon/hook_1081812)

docs/Installation.md

+21-9
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,40 @@ import useSomeHook from 'beautiful-react-hoks/useSomeHook'
2121
**Please note**: always import your hook from the library as a single module to avoid importing unnecessary hooks and therefore unnecessary
2222
dependencies
2323

24+
## Peer dependencies
25+
26+
Some hooks are built on top of third-party libraries (rxjs, react-router-dom, redux), therefore you will notice those libraries listed as
27+
peer dependencies. You don't have to install these dependencies unless you directly use those hooks.
28+
2429
## Working with Refs in TypeScript
2530

2631
The documentation of this module is written in JavaScript, so you will see a lot of this:
2732

28-
```javascript
33+
```jsx static
2934
import { ref } from 'react';
3035

31-
const ref = useRef()
36+
const myCustomHook = () => {
37+
const ref = useRef()
38+
39+
/* your code */
40+
41+
return ref;
42+
}
3243
```
3344

3445
If you are in a TypeScript project, you should declare your ref as a `RefObject<T extends HTMLElement>`. For example:
3546

36-
```ts
47+
```ts static
3748
import { ref } from 'react';
3849

39-
const ref = useRef<HTMLDivElement>(null);
50+
const myCustomHook = () => {
51+
const ref = useRef<HTMLDivElement>(null);
52+
53+
/* your code */
54+
55+
return ref;
56+
}
4057
```
4158

4259
See [here](https://dev.to/wojciechmatuszewski/mutable-and-immutable-useref-semantics-with-react-typescript-30c9) for information on the
4360
difference between a `MutableRefObject` and a `RefObject`.
44-
45-
## Peer dependencies
46-
47-
Some hooks are built on top of third-party libraries (rxjs, react-router-dom, redux), therefore you will notice those libraries listed as
48-
peer dependencies. You don't have to install these dependencies unless you directly use those hooks.

0 commit comments

Comments
 (0)