Skip to content
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

ESLint custom rule #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
env: {
browser: true,
es6: true,
},
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
'react',
'@typescript-eslint',
'react-hooks',
'@react-hook-utilities',
],
rules: {
'react-hooks/rules-of-hooks': 'error',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

'react-hooks/exhaustive-deps': 'warn',
'@react-hook-utilities/exhaustive-deps': 'warn',
},
};
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
dist/
*.log
coverage/
docs/
docs/
pageDocs/
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,21 @@ A state that only resolves after setting truthy values.

# Typescript

react-hook-utilities sees Typescript is a first-class citizen. The library is built for and around Typescript and you'll get bonus points for using it. Nonetheless, pure JavaScript files are also available if you're _that_ guy.
**react-hook-utilities** sees Typescript is a first-class citizen. The library is built for and around Typescript and you'll get bonus points for using it. Nonetheless, pure JavaScript files are also available if you're _that_ guy.

# ESLint

If you're using ESLint and don't want to lose your errors and warnings regarding dependencies, **react-hook-utilities** comes packaged with an [ESLint plugin](eslint-plugin/README.md) to lint it's own hooks. It is recommended to install the plugin as a local dependency:

```sh
$ yarn add -D ./node_modules/react-hook-utilities/eslint-plugin
```

We recommend you read the [full documentation](eslint-plugin/README.md) on how to use the ESLint plugin

# Documentation

The documentation is available at: https://fjcaetano.github.com/react-hook-utilities

# [Full Documentation](https://fjcaetano.github.com/react-hook-utilities)

Expand Down
51 changes: 51 additions & 0 deletions eslint-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# @react-hook-utilities/eslint-plugin

ESLint rules for hook react-hook-utilities

## Installation

You'll first need to install [ESLint](http://eslint.org) and [react-hook-utilities](https://www.npmjs.com/package/react-hook-utilities)

```
$ npm i eslint react-hook-utilities --save-dev
```

Next, install `@react-hook-utilities/eslint-plugin` directly from the host dependency:

```
$ npm install ./node_modules/react-hook-utilities/eslint-plugin --save-dev
```

**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `react-hook-utilities` globally.

## Usage

Add `@react-hook-utilities` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:

```json
{
"plugins": [
"@react-hook-utilities"
]
}
```


Then configure the rules you want to use under the rules section.

```json
{
"rules": {
"@react-hook-utilities/exhaustive-deps": 2
}
}
```

## Supported Rules

* exhaustive-deps: Ensures all hooks external references have been declared as dependencies.





Loading