Skip to content

Commit eb34a89

Browse files
committed
Add rule docs
1 parent d95d891 commit eb34a89

File tree

10 files changed

+561
-34
lines changed

10 files changed

+561
-34
lines changed

README.md

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
eslint-plugin-suitescript
2-
===================
1+
# eslint-plugin-suitescript
32

43
NetSuite SuiteScript v1/v2 linting rules for ESLint
54

@@ -12,20 +11,16 @@ This repo currently does not have an NPM listing. To install it, download the so
1211
Add "suitescript" to the plugins section of your ESLint config file.
1312

1413
```json
15-
{
16-
"plugins": [
17-
"suitescript"
18-
]
19-
}
14+
"plugins": ["suitescript"]
2015
```
2116

2217
Enable the rules that you would like to use.
2318

2419
```json
25-
"rules": {
26-
"react/script-type": "error",
27-
"react/no-log-module": "error",
28-
}
20+
"rules": {
21+
"suitescript/script-type": "error",
22+
"suitescript/no-log-module": "error",
23+
}
2924
```
3025

3126
## List of supported rules
@@ -42,26 +37,4 @@ Enable the rules that you would like to use.
4237

4338
## License
4439

45-
eslint-plugin-suitescript is licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
46-
47-
48-
[npm-url]: https://npmjs.org/package/eslint-plugin-react
49-
[npm-image]: https://img.shields.io/npm/v/eslint-plugin-react.svg
50-
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-
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
56-
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
59-
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
62-
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
65-
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
40+
eslint-plugin-suitescript is licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php).

docs/rules/api-version.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# suitescript/api-version
2+
3+
Enforces valid `@NApiVersion` tag values in the header block comment of every SuiteScript file.
4+
5+
Does not report missing `@NApiVersion` tags.
6+
7+
## Rule Details
8+
9+
Valid tag values are `1.0`, `2.x`, `2.0`, and `2.1`.
10+
11+
:white_check_mark: Using one of these values, the following pattern is **correct**:
12+
13+
```js
14+
/* eslint suitescript/api-version: "error" */
15+
16+
/**
17+
* @NApiVersion [value]
18+
*/
19+
```
20+
21+
:x: The following patterns are **incorrect**:
22+
23+
```js
24+
/* eslint suitescript/api-version: "error" */
25+
26+
/**
27+
* @NApiVersion
28+
*/
29+
```
30+
```js
31+
/* eslint suitescript/api-version: "error" */
32+
33+
/**
34+
* @NApiVersion2
35+
*/
36+
```
37+
```js
38+
/* eslint suitescript/api-version: "error" */
39+
40+
/**
41+
* @NApiVersion 2
42+
*/
43+
```
44+
45+
## Version
46+
47+
This rule was introduced in version 1.0.0.
48+
49+
## Source
50+
51+
- [Rule source](../../lib/rules/api-version.js)

docs/rules/entry-points.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# suitescript/entry-points
2+
3+
Enforces the inclusion of at least one entry point based on the value provided in the `@NScriptType` tag. If no tag is provided, no entry point will be enforced.
4+
5+
## Rule Details
6+
7+
:white_check_mark: The following patterns are **correct**:
8+
9+
```js
10+
/* eslint suitescript/entry-points: "error" */
11+
12+
/**
13+
* @NScriptType UserEventScript
14+
*/
15+
16+
define([], function() {
17+
return {
18+
beforeLoad: function() {}
19+
}
20+
});
21+
```
22+
```js
23+
/* eslint suitescript/entry-points: "error" */
24+
25+
/**
26+
* @NScriptType ClientScript
27+
*/
28+
29+
define([], function() {
30+
return {
31+
pageInit: function() {},
32+
somethingElse: function() {}
33+
}
34+
});
35+
```
36+
```js
37+
/* eslint suitescript/entry-points: "error" */
38+
39+
// No @NScriptType tag
40+
41+
define([], function() {
42+
return {
43+
somethingElse: function() {}
44+
}
45+
});
46+
```
47+
48+
:x: The following patterns are **incorrect**:
49+
50+
```js
51+
/* eslint suitescript/entry-points: "error" */
52+
53+
/**
54+
* @NScriptType UserEventScript
55+
*/
56+
57+
define([], function() {});
58+
```
59+
```js
60+
/* eslint suitescript/entry-points: "error" */
61+
62+
/**
63+
* @NScriptType ClientScript
64+
*/
65+
66+
define([], function() {
67+
return {
68+
somethingElse: function() {}
69+
}
70+
});
71+
```
72+
73+
### Script Types and Their Respective Entry Points
74+
75+
- BundleInstallationScript
76+
- afterInstall
77+
- afterUpdate
78+
- beforeInstall
79+
- beforeUninstall
80+
- beforeUpdate
81+
- ClientScript
82+
- fieldChanged
83+
- lineInit
84+
- pageInit
85+
- postSourcing
86+
- saveRecord
87+
- sublistChanged
88+
- validateDelete
89+
- validateField
90+
- validateInsert
91+
- validateLine
92+
- localizationContextEnter
93+
- localizationContextExit
94+
- MapReduceScript
95+
- getInputData
96+
- map
97+
- reduce
98+
- summarize
99+
- MassUpdateScript
100+
- each
101+
- Portlet
102+
- render
103+
- Restlet
104+
- delete
105+
- get
106+
- post
107+
- put
108+
- ScheduledScript
109+
- execute
110+
- SDFInstallationScript
111+
- run
112+
- Suitelet
113+
- onRequest
114+
- UserEventScript
115+
- afterSubmit
116+
- beforeLoad
117+
- beforeSubmit
118+
- WorkflowActionScript
119+
- onAction
120+
121+
## Version
122+
123+
This rule was introduced in version 1.0.0.
124+
125+
## Source
126+
127+
- [Rule source](../../lib/rules/entry-points.js)

docs/rules/log-args.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# suitescript/log-args
2+
3+
Enforces correct log arguments (title and details) in all `Log` methods.
4+
5+
## Rule Details
6+
7+
If no options are provided, the rule will require both title and details.
8+
9+
:white_check_mark: The following patterns are **correct**:
10+
11+
```js
12+
/* eslint suitescript/log-args: "error" */
13+
14+
log.debug({ title: 'Title', details: 'Details' });
15+
```
16+
```js
17+
/* eslint suitescript/log-args: "error" */
18+
19+
log.audit('Title', 'Details');
20+
```
21+
```js
22+
/* eslint suitescript/log-args: "error" */
23+
24+
log.error('', 'Details');
25+
```
26+
27+
:x: The following patterns are **incorrect**:
28+
29+
```js
30+
/* eslint suitescript/log-args: "error" */
31+
32+
log.debug('Title');
33+
```
34+
```js
35+
/* eslint suitescript/log-args: "error" */
36+
37+
log.audit({ details: 'Details' });
38+
```
39+
40+
## Rule Options
41+
42+
```js
43+
'suitescript/log-args': [<enabled>, {
44+
requireTitle: <boolean>,
45+
requireDetails: <boolean>
46+
}]
47+
```
48+
49+
> **Note**: Setting both options to `false` is the same as not using the rule at all. Setting both options to `true` is the same as not providing options.
50+
51+
### `requireTitle`
52+
53+
Explicitly requires a `title` argument no matter what.
54+
55+
```js
56+
/* eslint suitescript/log-args: ["error", { requireTitle: true }] */
57+
58+
log.debug({ title: 'Title' });
59+
```
60+
61+
### `requireDetails`
62+
63+
Explicitly requires a `details` argument no matter what.
64+
65+
```js
66+
/* eslint suitescript/log-args: ["error", { requireDetails: true }] */
67+
68+
log.debug({ details: 'Details' });
69+
```
70+
71+
## Version
72+
73+
This rule was introduced in version 1.0.0.
74+
75+
## Source
76+
77+
- [Rule source](../../lib/rules/log-args.js)

0 commit comments

Comments
 (0)