|
1 | | -<a href="https://travis-ci.org/adamdavies001/react-hooks-object-state"><img src="https://travis-ci.org/adamdavies001/react-hooks-object-state.svg?branch=master" alt="Travis Build Status"></a> |
2 | | -<a href="https://ci.appveyor.com/project/adamdavies001/react-hooks-object-state"><img src="https://ci.appveyor.com/api/projects/status/jc0a2g2t7t4logcu/branch/master?svg=true" alt="Windows Build Status"></a> |
3 | | -<a href="https://badge.fury.io/js/react-hooks-object-state"><img src="https://badge.fury.io/js/react-hooks-object-state.svg" alt="npm version"></a> |
| 1 | +eslint-plugin-suitescript |
| 2 | +=================== |
4 | 3 |
|
5 | | -## About |
| 4 | +NetSuite SuiteScript v1/v2 linting rules for ESLint |
6 | 5 |
|
7 | | -This package is a React hook for partially updating object states within functional components that avoids the default behavior of `useState` that overwrites the entire object state. It reflects the merge behavior of `setState` used in classical components. |
| 6 | +## Installation |
8 | 7 |
|
9 | | -**Use this** when you need an object state that shouldn't be split up into multiple states. |
10 | | -**Don't use this** if you only need an object state with a few simple properties. |
| 8 | +This repo currently does not have an NPM listing. To install it, download the source into a folder named `eslint-plugin-suitescript` and place it in your project's `node_modules` folder. From here, you can work with it exactly like any other NPM package. |
11 | 9 |
|
12 | | -## Features |
| 10 | +## Configuration |
13 | 11 |
|
14 | | -- Partially update object values in state without erasing any non-updated entries |
15 | | -- Calculate new values based on the previous state with a function argument |
| 12 | +Add "suitescript" to the plugins section of your ESLint config file. |
16 | 13 |
|
17 | | -## Install |
18 | | - |
19 | | -```bash |
20 | | -$ npm install react-hooks-object-state |
| 14 | +```json |
| 15 | +{ |
| 16 | + "plugins": [ |
| 17 | + "suitescript" |
| 18 | + ] |
| 19 | +} |
21 | 20 | ``` |
22 | 21 |
|
23 | | -Peer dependencies: react (^16.8.0) |
24 | | - |
25 | | -## Usage |
| 22 | +Enable the rules that you would like to use. |
26 | 23 |
|
27 | | -Within a functional component, simply declare and use the `useObjectState` hook to create a state object. Then pass any object updates to the returned setter function to update the original object. |
| 24 | +```json |
| 25 | + "rules": { |
| 26 | + "react/script-type": "error", |
| 27 | + "react/no-log-module": "error", |
| 28 | + } |
| 29 | +``` |
28 | 30 |
|
29 | | -```jsx |
30 | | -import React from 'react' |
31 | | -import useObjectState from 'react-hooks-object-state' |
| 31 | +## List of supported rules |
32 | 32 |
|
33 | | -const Example = () => { |
34 | | - const [myObject, setMyObject] = useObjectState({bool: true, string: 'foo'}) |
| 33 | +* [suitescript/api-version](docs/rules/api-version.md): Enforces valid `@NApiVersion` tag values |
| 34 | +* [suitescript/entry-points](docs/rules/entry-points.md): Enforces inclusion of at least one entry point based on `@NScriptType` |
| 35 | +* [suitescript/log-args](docs/rules/log-args.md): Enforces correct log arguments |
| 36 | +* [suitescript/module-vars](docs/rules/module-vars.md): Enforces correct module identifiers for each configured module |
| 37 | +* [suitescript/no-amd-name](docs/rules/no-amd-name.md): Restricts naming of AMD modules |
| 38 | +* [suitescript/no-extra-modules](docs/rules/no-extra-modules.md): Enforces equal number of module literals and identifiers |
| 39 | +* [suitescript/no-invalid-modules](docs/rules/no-invalid-modules.md): Enforces valid SuiteScript modules in `define` array |
| 40 | +* [suitescript/no-log-module](docs/rules/no-log-module.md): Restricts loading of the N/log module in favor of global `Log` |
| 41 | +* [suitescript/script-type](docs/rules/script-type.md): Enforces valid `@NScriptType` tag values |
35 | 42 |
|
36 | | - const updateObject = () => { |
37 | | - setMyObject({bool: false}) |
38 | | - } |
| 43 | +## License |
39 | 44 |
|
40 | | - return <button onClick={updateObject}>Update object</button> |
41 | | -} |
| 45 | +eslint-plugin-suitescript is licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php). |
42 | 46 |
|
43 | | -// myObject after update: |
44 | | -// { |
45 | | -// bool: false, |
46 | | -// string: 'foo' |
47 | | -// } |
48 | | -``` |
49 | 47 |
|
50 | | -#### Passing a function |
| 48 | +[npm-url]: https://npmjs.org/package/eslint-plugin-react |
| 49 | +[npm-image]: https://img.shields.io/npm/v/eslint-plugin-react.svg |
51 | 50 |
|
52 | | -Alternatively, you can pass a function to the setter if you need to use the previous state to calculate new state values. |
| 51 | +[travis-url]: https://travis-ci.org/yannickcr/eslint-plugin-react |
| 52 | +[travis-image]: https://img.shields.io/travis/yannickcr/eslint-plugin-react/master.svg |
53 | 53 |
|
54 | | -```jsx |
55 | | -const updateObject = () => { |
56 | | - setMyObject((state) => { |
57 | | - return { |
58 | | - string: state.str + 'bar' |
59 | | - } |
60 | | - }) |
61 | | -} |
62 | | -``` |
| 54 | +[deps-url]: https://david-dm.org/yannickcr/eslint-plugin-react |
| 55 | +[deps-image]: https://img.shields.io/david/dev/yannickcr/eslint-plugin-react.svg |
63 | 56 |
|
64 | | -The use of `props` in function arguments is not included since hooks are not able to read component props, and workarounds would not effectively replicate the classical `setState` behavior. |
| 57 | +[coverage-url]: https://coveralls.io/r/yannickcr/eslint-plugin-react?branch=master |
| 58 | +[coverage-image]: https://img.shields.io/coveralls/yannickcr/eslint-plugin-react/master.svg |
65 | 59 |
|
66 | | -#### Additional info |
| 60 | +[climate-url]: https://codeclimate.com/github/yannickcr/eslint-plugin-react |
| 61 | +[climate-image]: https://img.shields.io/codeclimate/maintainability/yannickcr/eslint-plugin-react.svg |
67 | 62 |
|
68 | | -An initial object **must** be provided to `useObjectState`. This hook deep-merges objects by copying common entries from a source to a target object. |
| 63 | +[status-url]: https://github.com/yannickcr/eslint-plugin-react/pulse |
| 64 | +[status-image]: https://img.shields.io/github/last-commit/yannickcr/eslint-plugin-react.svg |
69 | 65 |
|
70 | | -Like the classical `setState` method, this does not create entries if they don't already exist. Providing an empty initial object will always result in an empty object. |
| 66 | +[tidelift-url]: https://tidelift.com/subscription/pkg/npm-eslint-plugin-react?utm_source=npm-eslint-plugin-react&utm_medium=referral&utm_campaign=readme |
| 67 | +[tidelift-image]: https://tidelift.com/badges/github/yannickcr/eslint-plugin-react?style=flat |
0 commit comments