Skip to content

Commit

Permalink
feat(index): Removes index and updates dependencies.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: removes index file from src
  • Loading branch information
antonioru committed Mar 13, 2023
1 parent 83bb1bd commit df90cd3
Show file tree
Hide file tree
Showing 64 changed files with 563 additions and 536 deletions.
55 changes: 0 additions & 55 deletions .eslintrc

This file was deleted.

57 changes: 57 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'plugin:react/recommended',
'standard-with-typescript'
],
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: [
'react'
],
rules: {
'max-len': [
'error',
{
code: 140
}
],
semi: [
2,
'never'
],
'@typescript-eslint/semi': 'off',
'linebreak-style': 'off',
'object-curly-newline': 'off',
'react/jsx-filename-extension': 'off',
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/no-non-null-assertion': 'off'
},
overrides: [
{
files: [
'*.test.js',
'*.spec.js',
'*.test.jsx',
'*.spec.jsx'
],
globals: {
expect: 'readonly',
should: 'readonly',
sinon: 'readonly'
},
rules: {
'no-unused-expressions': 'off'
}
}
]
}
4 changes: 2 additions & 2 deletions .github/workflows/branch-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ on:
jobs:
test:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

strategy:
matrix:
node-version: 18
node-version: [ 18.14 ]

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 18
node-version: [ 18.14 ]
registry-url: https://registry.npmjs.org/

- name: NPM CI
run: npm install --force
run: npm install

- name: Repository build
run: npm run build
Expand All @@ -45,7 +45,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

- name: Publish
run: |
Expand Down
4 changes: 2 additions & 2 deletions .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"extension": [ ".js" ],
"include": [ "dist/*.js" ],
"exclude": [ "dist/index.js", "dist/_virtual/**/*.js" ],
"branches": 60,
"lines": 70,
"branches": 50,
"lines": 80,
"functions": 70,
"statements": 70
}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -999,3 +999,12 @@ Errored release
### Fixes

- `useLocalStorage` and `useSessionStorage` no longer return a new `setValue` function everytime `setValue` is called

## [4.0.0] - 2023-03-13

### Breaking Changes

- Removes `index.ts` file from `src` folder
- Updates dependencies
- Improves documentation
- Improves types
16 changes: 8 additions & 8 deletions HOOK_DOCUMENTATION_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# useYourHookName

-- A short description of your hook --
A hook that [...]

### 💡 Why?

Expand All @@ -9,12 +9,11 @@
### Basic Usage:

```jsx harmony
import { yourHook } from 'beautiful-react-hooks';

import { yourHook } from 'beautiful-react-hooks';

const YourExample = () => {
/* Your code goes here */

return null;
};

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

```jsx harmony
import { yourHook } from 'beautiful-react-hooks';

import { yourHook } from 'beautiful-react-hooks';

const YourUseCase = () => {
/* Your code goes here */

return null;
};

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

#### ✅ When to use

- When it's good to use

#### 🛑 When not to use

- When it's not good to use

<!-- Types -->
File renamed without changes.
81 changes: 38 additions & 43 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,67 +44,62 @@
"lodash.throttle": "^4.1.1"
},
"peerDependencies": {
"react": ">=16.0.0",
"react-dom": ">=16.0.0",
"react-router-dom": ">=5.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-router-dom": ">=5.0.0 <=6.0.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
"@ant-design/icons": "5.0.1",
"@babel/core": "7.18.2",
"@babel/preset-env": "7.18.2",
"@babel/preset-react": "7.17.12",
"@babel/register": "^7.17.7",
"@semantic-release/changelog": "6.0.1",
"@babel/core": "7.21.0",
"@babel/preset-env": "7.20.2",
"@babel/preset-react": "7.18.6",
"@babel/register": "^7.21.0",
"@semantic-release/changelog": "6.0.2",
"@semantic-release/commit-analyzer": "9.0.2",
"@semantic-release/exec": "6.0.3",
"@semantic-release/git": "10.0.1",
"@semantic-release/github": "8.0.4",
"@semantic-release/npm": "9.0.1",
"@testing-library/react": "13.3.0",
"@testing-library/react-hooks": "8.0.1",
"@semantic-release/github": "8.0.7",
"@semantic-release/npm": "9.0.2",
"@testing-library/react": "14.0.0",
"@testing-library/react-hooks": "6.0.0",
"@types/lodash.debounce": "4.0.7",
"@types/lodash.throttle": "4.1.7",
"@types/react-router-dom": "5.3.3",
"@typescript-eslint/eslint-plugin": "5.27.1",
"@typescript-eslint/parser": "5.27.1",
"antd": "5.2.2",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.5",
"antd": "5.3.1",
"babel-loader": "^9.1.2",
"babel-plugin-istanbul": "^6.1.1",
"babel-plugin-transform-require-ignore": "^0.1.1",
"chai": "^4.3.6",
"css-loader": "^6.7.1",
"eslint": "8.21.0",
"eslint-config-airbnb-base": "4.0.2",
"eslint-config-airbnb-typescript": "16.1.1",
"eslint-plugin-chai-expect": "^3.0.0",
"eslint-plugin-import": "1.11.0",
"eslint-plugin-jsx-a11y": "6.6.1",
"eslint-plugin-react": "7.30.1",
"eslint-plugin-react-hooks": "4.5.0",
"glob": "^8.0.3",
"husky": "^8.0.1",
"jsdoc-to-markdown": "^7.1.1",
"jsdom": "^19.0.0",
"chai": "^4.3.7",
"css-loader": "^6.7.3",
"eslint": "8.36.0",
"eslint-config-standard-with-typescript": "34.0.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-n": "15.6.1",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-react": "7.32.2",
"glob": "^9.2.1",
"husky": "^8.0.3",
"jsdoc-to-markdown": "^8.0.0",
"jsdom": "^21.1.1",
"jsdom-global": "^3.0.2",
"mocha": "10.0.0",
"mocha": "10.2.0",
"mock-local-storage": "1.1.23",
"mutation-observer": "1.0.3",
"nyc": "^15.1.0",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-router-dom": "5.3.3",
"react-styleguidist": "13.0.0",
"regenerator-runtime": "0.13.9",
"rxjs": "7.5.5",
"semantic-release": "^19.0.3",
"sinon": "^14.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-router-dom": "5.3.4",
"react-styleguidist": "13.1.1",
"regenerator-runtime": "0.13.11",
"rxjs": "7.8.0",
"semantic-release": "^20.1.1",
"sinon": "^15.0.2",
"style-loader": "^3.3.1",
"ts-loader": "9.3.0",
"typescript": "4.7.3",
"ts-loader": "9.4.2",
"typescript": "4.9.5",
"url-loader": "^4.1.1",
"webpack": "5.74.0"
"webpack": "5.76.1"
},
"exports": {
".": {
Expand Down
4 changes: 2 additions & 2 deletions src/factory/createHandlerSetter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RefObject, useRef } from 'react'
import { CallbackSetter, SomeCallback } from '../shared/types'
import { type RefObject, useRef } from 'react'
import { type CallbackSetter, type SomeCallback } from '../shared/types'

/**
* Returns an array where the first item is the [ref](https://reactjs.org/docs/hooks-reference.html#useref) to a
Expand Down
14 changes: 5 additions & 9 deletions src/factory/createStorageHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import isDevelopment from '../shared/isDevelopment'
import noop from '../shared/noop'
import warnOnce from '../shared/warnOnce'


/**
* A utility to quickly create hooks to access both Session Storage and Local Storage
*/
Expand All @@ -21,10 +20,7 @@ const createStorageHook = (type: 'session' | 'local') => {
/**
* the hook
*/
return function useStorageCreatedHook<TValue>(
storageKey: string,
defaultValue?: any,
): [TValue, SetValue<TValue>] {
return function useStorageCreatedHook<TValue> (storageKey: string, defaultValue?: any): [TValue | null, SetValue<TValue>] {
if (!isClient) {
if (isDevelopment) {
warnOnce(`Please be aware that ${storageName} could not be available during SSR`)
Expand All @@ -41,18 +37,18 @@ const createStorageHook = (type: 'session' | 'local') => {
}
}, [storage, storageKey])

const [storedValue, setStoredValue] = useState<TValue>(
const [storedValue, setStoredValue] = useState<TValue | null>(
() => {
let valueToStore: string
try {
valueToStore = storage.getItem(storageKey) || JSON.stringify(defaultValue)
valueToStore = storage.getItem(storageKey) ?? JSON.stringify(defaultValue)
} catch (e) {
valueToStore = JSON.stringify(defaultValue)
}

safelySetStorage(valueToStore)
return safelyParseJson(valueToStore)
},
}
)

const setValue: SetValue<TValue> = useCallback(
Expand All @@ -63,7 +59,7 @@ const createStorageHook = (type: 'session' | 'local') => {
return valueToStore
})
},
[safelySetStorage],
[safelySetStorage]
)

return [storedValue, setValue]
Expand Down

0 comments on commit df90cd3

Please sign in to comment.