biome-plugin-suitescript 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +149 -149
- package/configs/suitescript2.json +5 -5
- package/dist/bin/biome-plugin-suitescript.js +23 -23
- package/dist/rules/noAmdName.grit +9 -9
- package/dist/rules/noModuleExtensions.grit +12 -12
- package/package.json +83 -83
- package/schema.json +21 -21
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Eric Nemchik
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Eric Nemchik
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,149 +1,149 @@
|
|
|
1
|
-
# biome-plugin-suitescript
|
|
2
|
-
|
|
3
|
-
[Biome](https://biomejs.dev) lint plugins and a tag checker for NetSuite **SuiteScript 2.1**, ported from
|
|
4
|
-
[acdvs/eslint-plugin-suitescript](https://github.com/acdvs/eslint-plugin-suitescript) and
|
|
5
|
-
[btonasse/eslint-plugin-suitescript](https://github.com/btonasse/eslint-plugin-suitescript).
|
|
6
|
-
|
|
7
|
-
Requires Biome **>= 2.6.4** (npm-distributed plugins use `biome-manifest.json`) and Node >= 22 for the CLI.
|
|
8
|
-
Rules work on both AMD `define()` and ES `import`/`export` source, in `.js` and `.ts`.
|
|
9
|
-
|
|
10
|
-
## Install
|
|
11
|
-
|
|
12
|
-
```sh
|
|
13
|
-
npm i -D @biomejs/biome biome-plugin-suitescript
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Use
|
|
17
|
-
|
|
18
|
-
```jsonc
|
|
19
|
-
// biome.json
|
|
20
|
-
{
|
|
21
|
-
"extends": ["biome-plugin-suitescript/configs/suitescript2"], // globals: define, require, log, util
|
|
22
|
-
"plugins": [
|
|
23
|
-
"biome-plugin-suitescript/presets/recommended",
|
|
24
|
-
"biome-plugin-suitescript/noLogModule" // add individual rules on top of a preset
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Run the tag checker beside `biome check` (see [Tag checker](#tag-checker)):
|
|
30
|
-
|
|
31
|
-
```sh
|
|
32
|
-
npx biome-plugin-suitescript check
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Rules
|
|
36
|
-
|
|
37
|
-
Each rule has one fixed severity: `error` for things that fail at runtime or on upload, `warn` for conventions.
|
|
38
|
-
Biome plugins cannot be reconfigured per project, so you choose by enabling rules, scoping them, or generating one.
|
|
39
|
-
|
|
40
|
-
| Rule | Severity | Description | ESLint equivalent |
|
|
41
|
-
| ------------------------------ | -------- | ---------------------------------------------------------------------------------- | --------------------------- |
|
|
42
|
-
| `noAmdName` (fixable) | error | No module id as the first `define` argument | `no-amd-name` |
|
|
43
|
-
| `noExtraModules` | error | Dependency array and callback parameters must match in count | `no-extra-modules` |
|
|
44
|
-
| `noInvalidModules` | error | Unknown `N/...` modules | `no-invalid-modules` |
|
|
45
|
-
| `noModuleExtensions` (fixable) | error | No `.js` in `define` dependency names | `no-module-extensions` |
|
|
46
|
-
| `moduleVars` | warn | Conventional identifier per `N/` module (`N/record` → `record`) | `module-vars` |
|
|
47
|
-
| `logRequireTitle` | warn | `log.debug/audit/error/emergency({...})` needs `title` | `log-args` `requireTitle` |
|
|
48
|
-
| `logRequireDetails` | warn | ...needs `details` | `log-args` `requireDetails` |
|
|
49
|
-
| `noLogModule` | warn | Use the global `log`, not `N/log` | `no-log-module` |
|
|
50
|
-
| `entryPoints` | error | Returned entry points must belong to one script type and include its required ones | `entry-points` |
|
|
51
|
-
|
|
52
|
-
`noAmdName`, `noExtraModules` and `noModuleExtensions` only apply to `define()`. The rest cover `import` too.
|
|
53
|
-
|
|
54
|
-
| Preset | Contents |
|
|
55
|
-
| --------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
56
|
-
| `presets/recommended` | every rule above except `noLogModule` and `entryPoints` (no false positives on libraries or client scripts) |
|
|
57
|
-
| `presets/minimal` | `noExtraModules`, `noInvalidModules` |
|
|
58
|
-
| `presets/all` | `recommended` + `noLogModule` + `entryPoints` |
|
|
59
|
-
|
|
60
|
-
Suppress a diagnostic with `// biome-ignore lint/plugin: reason`.
|
|
61
|
-
|
|
62
|
-
### `entryPoints` and script types
|
|
63
|
-
|
|
64
|
-
Biome plugins cannot read comments, so the script type is **inferred from what the module returns**
|
|
65
|
-
(`beforeLoad` → User Event, `onRequest` → Suitelet, ...). The rule reports mixed entry points
|
|
66
|
-
(`pageInit` with `execute`) and missing required ones (Map/Reduce needs `getInputData` and `map` or `reduce`).
|
|
67
|
-
Modules that return no distinctive entry point are libraries and are ignored. Generic names such as
|
|
68
|
-
`get`, `post`, `map` and `run` alone never make a module a script.
|
|
69
|
-
|
|
70
|
-
### Choosing what to enforce
|
|
71
|
-
|
|
72
|
-
- **Pick rules.** `log-args`' two options are the separate `logRequireTitle` / `logRequireDetails` rules.
|
|
73
|
-
- **Scope with `includes`.** For example, the global `log` is not available in client scripts:
|
|
74
|
-
|
|
75
|
-
```jsonc
|
|
76
|
-
{ "path": "biome-plugin-suitescript/noLogModule", "includes": ["src/**", "!src/**/client/**"] }
|
|
77
|
-
```
|
|
78
|
-
- **Custom module identifiers.** Generate a rule with your own mapping (and omit `moduleVars`):
|
|
79
|
-
|
|
80
|
-
```sh
|
|
81
|
-
npx biome-plugin-suitescript generate module-vars --set N/record=nRecord --out plugins/module-vars.js
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
then add `"./plugins/module-vars.js"` to `plugins`.
|
|
85
|
-
|
|
86
|
-
## Tag checker
|
|
87
|
-
|
|
88
|
-
`@NApiVersion` and `@NScriptType` live in comments, which no Biome plugin can read, so a small CLI checks them.
|
|
89
|
-
It is **report-only**: it never edits files.
|
|
90
|
-
|
|
91
|
-
```sh
|
|
92
|
-
npx biome-plugin-suitescript check # uses biome-plugin-suitescript.json
|
|
93
|
-
npx biome-plugin-suitescript check "src/**/*.ts" # or explicit globs
|
|
94
|
-
npx biome-plugin-suitescript check --format github # text (default) | json | github
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
It reports:
|
|
98
|
-
|
|
99
|
-
- `@NApiVersion` other than `2.1` (2.0, 2.x, 1.0 and invalid values), or missing when the file is a script.
|
|
100
|
-
- `@NScriptType` with no or an invalid value, or missing when the returned entry points imply one.
|
|
101
|
-
- A declared script type that does not match the returned entry points, or lacks its required ones.
|
|
102
|
-
|
|
103
|
-
Files with no tags and no implied entry points (libraries) are skipped. For scripts still on 1.0, 2.0 or 2.x, the
|
|
104
|
-
output points to Oracle's
|
|
105
|
-
[`netsuite-suitescript-upgrade`](https://github.com/oracle/netsuite-suitecloud-sdk/tree/master/packages/agent-skills/netsuite-suitescript-upgrade)
|
|
106
|
-
agent skill for the conversion.
|
|
107
|
-
|
|
108
|
-
Exit codes: `0` clean, `1` problems found, `2` usage or configuration error.
|
|
109
|
-
|
|
110
|
-
### Configuration
|
|
111
|
-
|
|
112
|
-
List only the **script sources**: files deployed to the file cabinet, or the sources they are transpiled from (not
|
|
113
|
-
the transpiled output, and not build files such as `swc.mts`). The CLI refuses to run without a list rather than
|
|
114
|
-
guessing from `deploy.xml`.
|
|
115
|
-
|
|
116
|
-
```jsonc
|
|
117
|
-
// biome-plugin-suitescript.json
|
|
118
|
-
{
|
|
119
|
-
"$schema": "./node_modules/biome-plugin-suitescript/schema.json",
|
|
120
|
-
"includes": ["src/TypeScripts/**/*.{js,ts}", "!**/*.d.ts", "!**/*.test.*"]
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
`!` negation works as in Biome's `includes`. Reuse the same globs in the plugin `includes` in `biome.json` to scope the
|
|
125
|
-
Biome rules identically.
|
|
126
|
-
|
|
127
|
-
## Development
|
|
128
|
-
|
|
129
|
-
The source is TypeScript under `src/`, compiled by `tsc` to `dist/` (the only code that is published). Scripts and
|
|
130
|
-
tests are TypeScript too and run directly on Node. Node and npm versions come from `devEngines` in `package.json`
|
|
131
|
-
(also in `.nvmrc` and `.tool-versions`).
|
|
132
|
-
|
|
133
|
-
```sh
|
|
134
|
-
npm install
|
|
135
|
-
npm run build # tsc -> dist/, copies GritQL rules, regenerates biome-manifest.json
|
|
136
|
-
npm run typecheck # tsc --noEmit over src, scripts and tests
|
|
137
|
-
npm run check # biome check (npm run format applies fixes)
|
|
138
|
-
npm run sync-modules # refreshes the N/ module list from @hitc/netsuite-types
|
|
139
|
-
npm test # builds first, then tests the built package
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
Git hooks (lefthook) run Biome on staged files before commit and reinstall dependencies after checkout or merge.
|
|
143
|
-
|
|
144
|
-
Commits follow [Conventional Commits](https://www.conventionalcommits.org); release-please opens a release PR and
|
|
145
|
-
publishes to npm when it is merged, using npm trusted publishing (OIDC, no token; the package settings on npmjs.com
|
|
146
|
-
allow this repo and `release.yml`). Dependencies are managed by Renovate: dev
|
|
147
|
-
dependencies are pinned, the `@biomejs/biome` peer range stays a caret, and Biome and `@biomejs/runtime` update together.
|
|
148
|
-
|
|
149
|
-
MIT licensed. Module and script-type data and rule behavior derive from the MIT-licensed ESLint plugins above.
|
|
1
|
+
# biome-plugin-suitescript
|
|
2
|
+
|
|
3
|
+
[Biome](https://biomejs.dev) lint plugins and a tag checker for NetSuite **SuiteScript 2.1**, ported from
|
|
4
|
+
[acdvs/eslint-plugin-suitescript](https://github.com/acdvs/eslint-plugin-suitescript) and
|
|
5
|
+
[btonasse/eslint-plugin-suitescript](https://github.com/btonasse/eslint-plugin-suitescript).
|
|
6
|
+
|
|
7
|
+
Requires Biome **>= 2.6.4** (npm-distributed plugins use `biome-manifest.json`) and Node >= 22 for the CLI.
|
|
8
|
+
Rules work on both AMD `define()` and ES `import`/`export` source, in `.js` and `.ts`.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm i -D @biomejs/biome biome-plugin-suitescript
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Use
|
|
17
|
+
|
|
18
|
+
```jsonc
|
|
19
|
+
// biome.json
|
|
20
|
+
{
|
|
21
|
+
"extends": ["biome-plugin-suitescript/configs/suitescript2"], // globals: define, require, log, util
|
|
22
|
+
"plugins": [
|
|
23
|
+
"biome-plugin-suitescript/presets/recommended",
|
|
24
|
+
"biome-plugin-suitescript/noLogModule" // add individual rules on top of a preset
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Run the tag checker beside `biome check` (see [Tag checker](#tag-checker)):
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npx biome-plugin-suitescript check
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Rules
|
|
36
|
+
|
|
37
|
+
Each rule has one fixed severity: `error` for things that fail at runtime or on upload, `warn` for conventions.
|
|
38
|
+
Biome plugins cannot be reconfigured per project, so you choose by enabling rules, scoping them, or generating one.
|
|
39
|
+
|
|
40
|
+
| Rule | Severity | Description | ESLint equivalent |
|
|
41
|
+
| ------------------------------ | -------- | ---------------------------------------------------------------------------------- | --------------------------- |
|
|
42
|
+
| `noAmdName` (fixable) | error | No module id as the first `define` argument | `no-amd-name` |
|
|
43
|
+
| `noExtraModules` | error | Dependency array and callback parameters must match in count | `no-extra-modules` |
|
|
44
|
+
| `noInvalidModules` | error | Unknown `N/...` modules | `no-invalid-modules` |
|
|
45
|
+
| `noModuleExtensions` (fixable) | error | No `.js` in `define` dependency names | `no-module-extensions` |
|
|
46
|
+
| `moduleVars` | warn | Conventional identifier per `N/` module (`N/record` → `record`) | `module-vars` |
|
|
47
|
+
| `logRequireTitle` | warn | `log.debug/audit/error/emergency({...})` needs `title` | `log-args` `requireTitle` |
|
|
48
|
+
| `logRequireDetails` | warn | ...needs `details` | `log-args` `requireDetails` |
|
|
49
|
+
| `noLogModule` | warn | Use the global `log`, not `N/log` | `no-log-module` |
|
|
50
|
+
| `entryPoints` | error | Returned entry points must belong to one script type and include its required ones | `entry-points` |
|
|
51
|
+
|
|
52
|
+
`noAmdName`, `noExtraModules` and `noModuleExtensions` only apply to `define()`. The rest cover `import` too.
|
|
53
|
+
|
|
54
|
+
| Preset | Contents |
|
|
55
|
+
| --------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
56
|
+
| `presets/recommended` | every rule above except `noLogModule` and `entryPoints` (no false positives on libraries or client scripts) |
|
|
57
|
+
| `presets/minimal` | `noExtraModules`, `noInvalidModules` |
|
|
58
|
+
| `presets/all` | `recommended` + `noLogModule` + `entryPoints` |
|
|
59
|
+
|
|
60
|
+
Suppress a diagnostic with `// biome-ignore lint/plugin: reason`.
|
|
61
|
+
|
|
62
|
+
### `entryPoints` and script types
|
|
63
|
+
|
|
64
|
+
Biome plugins cannot read comments, so the script type is **inferred from what the module returns**
|
|
65
|
+
(`beforeLoad` → User Event, `onRequest` → Suitelet, ...). The rule reports mixed entry points
|
|
66
|
+
(`pageInit` with `execute`) and missing required ones (Map/Reduce needs `getInputData` and `map` or `reduce`).
|
|
67
|
+
Modules that return no distinctive entry point are libraries and are ignored. Generic names such as
|
|
68
|
+
`get`, `post`, `map` and `run` alone never make a module a script.
|
|
69
|
+
|
|
70
|
+
### Choosing what to enforce
|
|
71
|
+
|
|
72
|
+
- **Pick rules.** `log-args`' two options are the separate `logRequireTitle` / `logRequireDetails` rules.
|
|
73
|
+
- **Scope with `includes`.** For example, the global `log` is not available in client scripts:
|
|
74
|
+
|
|
75
|
+
```jsonc
|
|
76
|
+
{ "path": "biome-plugin-suitescript/noLogModule", "includes": ["src/**", "!src/**/client/**"] }
|
|
77
|
+
```
|
|
78
|
+
- **Custom module identifiers.** Generate a rule with your own mapping (and omit `moduleVars`):
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
npx biome-plugin-suitescript generate module-vars --set N/record=nRecord --out plugins/module-vars.js
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
then add `"./plugins/module-vars.js"` to `plugins`.
|
|
85
|
+
|
|
86
|
+
## Tag checker
|
|
87
|
+
|
|
88
|
+
`@NApiVersion` and `@NScriptType` live in comments, which no Biome plugin can read, so a small CLI checks them.
|
|
89
|
+
It is **report-only**: it never edits files.
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
npx biome-plugin-suitescript check # uses biome-plugin-suitescript.json
|
|
93
|
+
npx biome-plugin-suitescript check "src/**/*.ts" # or explicit globs
|
|
94
|
+
npx biome-plugin-suitescript check --format github # text (default) | json | github
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
It reports:
|
|
98
|
+
|
|
99
|
+
- `@NApiVersion` other than `2.1` (2.0, 2.x, 1.0 and invalid values), or missing when the file is a script.
|
|
100
|
+
- `@NScriptType` with no or an invalid value, or missing when the returned entry points imply one.
|
|
101
|
+
- A declared script type that does not match the returned entry points, or lacks its required ones.
|
|
102
|
+
|
|
103
|
+
Files with no tags and no implied entry points (libraries) are skipped. For scripts still on 1.0, 2.0 or 2.x, the
|
|
104
|
+
output points to Oracle's
|
|
105
|
+
[`netsuite-suitescript-upgrade`](https://github.com/oracle/netsuite-suitecloud-sdk/tree/master/packages/agent-skills/netsuite-suitescript-upgrade)
|
|
106
|
+
agent skill for the conversion.
|
|
107
|
+
|
|
108
|
+
Exit codes: `0` clean, `1` problems found, `2` usage or configuration error.
|
|
109
|
+
|
|
110
|
+
### Configuration
|
|
111
|
+
|
|
112
|
+
List only the **script sources**: files deployed to the file cabinet, or the sources they are transpiled from (not
|
|
113
|
+
the transpiled output, and not build files such as `swc.mts`). The CLI refuses to run without a list rather than
|
|
114
|
+
guessing from `deploy.xml`.
|
|
115
|
+
|
|
116
|
+
```jsonc
|
|
117
|
+
// biome-plugin-suitescript.json
|
|
118
|
+
{
|
|
119
|
+
"$schema": "./node_modules/biome-plugin-suitescript/schema.json",
|
|
120
|
+
"includes": ["src/TypeScripts/**/*.{js,ts}", "!**/*.d.ts", "!**/*.test.*"]
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`!` negation works as in Biome's `includes`. Reuse the same globs in the plugin `includes` in `biome.json` to scope the
|
|
125
|
+
Biome rules identically.
|
|
126
|
+
|
|
127
|
+
## Development
|
|
128
|
+
|
|
129
|
+
The source is TypeScript under `src/`, compiled by `tsc` to `dist/` (the only code that is published). Scripts and
|
|
130
|
+
tests are TypeScript too and run directly on Node. Node and npm versions come from `devEngines` in `package.json`
|
|
131
|
+
(also in `.nvmrc` and `.tool-versions`).
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
npm install
|
|
135
|
+
npm run build # tsc -> dist/, copies GritQL rules, regenerates biome-manifest.json
|
|
136
|
+
npm run typecheck # tsc --noEmit over src, scripts and tests
|
|
137
|
+
npm run check # biome check (npm run format applies fixes)
|
|
138
|
+
npm run sync-modules # refreshes the N/ module list from @hitc/netsuite-types
|
|
139
|
+
npm test # builds first, then tests the built package
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Git hooks (lefthook) run Biome on staged files before commit and reinstall dependencies after checkout or merge.
|
|
143
|
+
|
|
144
|
+
Commits follow [Conventional Commits](https://www.conventionalcommits.org); release-please opens a release PR and
|
|
145
|
+
publishes to npm when it is merged, using npm trusted publishing (OIDC, no token; the package settings on npmjs.com
|
|
146
|
+
allow this repo and `release.yml`). Dependencies are managed by Renovate: dev
|
|
147
|
+
dependencies are pinned, the `@biomejs/biome` peer range stays a caret, and Biome and `@biomejs/runtime` update together.
|
|
148
|
+
|
|
149
|
+
MIT licensed. Module and script-type data and rule behavior derive from the MIT-licensed ESLint plugins above.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"javascript": {
|
|
3
|
-
"globals": ["define", "require", "log", "util"]
|
|
4
|
-
}
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"javascript": {
|
|
3
|
+
"globals": ["define", "require", "log", "util"]
|
|
4
|
+
}
|
|
5
|
+
}
|
|
@@ -5,11 +5,11 @@ import { glob } from "tinyglobby";
|
|
|
5
5
|
import { analyzeSource } from "../cli/analyze.js";
|
|
6
6
|
import { format } from "../cli/format.js";
|
|
7
7
|
import { MODULES } from "../lib/modules.js";
|
|
8
|
-
const USAGE = `Usage:
|
|
9
|
-
biome-plugin-suitescript check [globs...] [--config file] [--format text|json|github]
|
|
10
|
-
biome-plugin-suitescript generate module-vars [--set N/module=identifier]... [--out file.js]
|
|
11
|
-
|
|
12
|
-
check reads "includes" from biome-plugin-suitescript.json unless globs are given.
|
|
8
|
+
const USAGE = `Usage:
|
|
9
|
+
biome-plugin-suitescript check [globs...] [--config file] [--format text|json|github]
|
|
10
|
+
biome-plugin-suitescript generate module-vars [--set N/module=identifier]... [--out file.js]
|
|
11
|
+
|
|
12
|
+
check reads "includes" from biome-plugin-suitescript.json unless globs are given.
|
|
13
13
|
Exit codes: 0 clean, 1 problems found, 2 usage or configuration error.`;
|
|
14
14
|
function fail(message) {
|
|
15
15
|
console.error(`${message}\n\n${USAGE}`);
|
|
@@ -99,24 +99,24 @@ function generate(args) {
|
|
|
99
99
|
map[name] = id;
|
|
100
100
|
}
|
|
101
101
|
const out = flags.out?.[0] ?? "suitescript-module-vars.js";
|
|
102
|
-
writeFileSync(out, `// Generated by biome-plugin-suitescript. Add to biome.json "plugins".
|
|
103
|
-
import { defineRule, ast, registerDiagnostic } from "@biomejs/runtime/plugin";
|
|
104
|
-
|
|
105
|
-
${inline("define.js")}
|
|
106
|
-
${inline("biome-modules.js")}
|
|
107
|
-
const MODULES = ${JSON.stringify(map, null, 2)};
|
|
108
|
-
|
|
109
|
-
export const moduleVars = defineRule({
|
|
110
|
-
\tquery: ast("JS_CALL_EXPRESSION", "JS_IMPORT"),
|
|
111
|
-
\trun(node) {
|
|
112
|
-
\t\tfor (const { name, param } of dependencies(node)) {
|
|
113
|
-
\t\t\tconst expected = name && Object.hasOwn(MODULES, name) ? MODULES[name] : undefined;
|
|
114
|
-
\t\t\tif (expected && param && param.text !== expected) {
|
|
115
|
-
\t\t\t\tregisterDiagnostic(param, "warning", \`Identifier for \${name} should be '\${expected}'.\`);
|
|
116
|
-
\t\t\t}
|
|
117
|
-
\t\t}
|
|
118
|
-
\t},
|
|
119
|
-
});
|
|
102
|
+
writeFileSync(out, `// Generated by biome-plugin-suitescript. Add to biome.json "plugins".
|
|
103
|
+
import { defineRule, ast, registerDiagnostic } from "@biomejs/runtime/plugin";
|
|
104
|
+
|
|
105
|
+
${inline("define.js")}
|
|
106
|
+
${inline("biome-modules.js")}
|
|
107
|
+
const MODULES = ${JSON.stringify(map, null, 2)};
|
|
108
|
+
|
|
109
|
+
export const moduleVars = defineRule({
|
|
110
|
+
\tquery: ast("JS_CALL_EXPRESSION", "JS_IMPORT"),
|
|
111
|
+
\trun(node) {
|
|
112
|
+
\t\tfor (const { name, param } of dependencies(node)) {
|
|
113
|
+
\t\t\tconst expected = name && Object.hasOwn(MODULES, name) ? MODULES[name] : undefined;
|
|
114
|
+
\t\t\tif (expected && param && param.text !== expected) {
|
|
115
|
+
\t\t\t\tregisterDiagnostic(param, "warning", \`Identifier for \${name} should be '\${expected}'.\`);
|
|
116
|
+
\t\t\t}
|
|
117
|
+
\t\t}
|
|
118
|
+
\t},
|
|
119
|
+
});
|
|
120
120
|
`);
|
|
121
121
|
console.log(`Wrote ${out}`);
|
|
122
122
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
engine biome(1.0)
|
|
2
|
-
language js(typescript, jsx)
|
|
3
|
-
|
|
4
|
-
// Anonymous AMD modules only: NetSuite/bundlers assign the module ID.
|
|
5
|
-
`define($id, $deps, $cb)` as $call where {
|
|
6
|
-
$id <: JsStringLiteralExpression(),
|
|
7
|
-
register_diagnostic(span=$id, message="No AMD module name should be provided.", severity="error", fix_kind="safe"),
|
|
8
|
-
$call => `define($deps, $cb)`
|
|
9
|
-
}
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript, jsx)
|
|
3
|
+
|
|
4
|
+
// Anonymous AMD modules only: NetSuite/bundlers assign the module ID.
|
|
5
|
+
`define($id, $deps, $cb)` as $call where {
|
|
6
|
+
$id <: JsStringLiteralExpression(),
|
|
7
|
+
register_diagnostic(span=$id, message="No AMD module name should be provided.", severity="error", fix_kind="safe"),
|
|
8
|
+
$call => `define($deps, $cb)`
|
|
9
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
engine biome(1.0)
|
|
2
|
-
language js(typescript, jsx)
|
|
3
|
-
|
|
4
|
-
// Dependencies in the define() array must not carry a `.js` extension.
|
|
5
|
-
`define($args)` where {
|
|
6
|
-
$args <: contains JsArrayExpression() as $deps,
|
|
7
|
-
$deps <: contains JsStringLiteralExpression() as $dep where {
|
|
8
|
-
$dep <: r"(['\"])(.*)\.js(['\"])"($q1, $name, $q2),
|
|
9
|
-
register_diagnostic(span=$dep, message="Module name should not include file extension.", severity="error", fix_kind="safe"),
|
|
10
|
-
$dep => `$q1$name$q2`
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript, jsx)
|
|
3
|
+
|
|
4
|
+
// Dependencies in the define() array must not carry a `.js` extension.
|
|
5
|
+
`define($args)` where {
|
|
6
|
+
$args <: contains JsArrayExpression() as $deps,
|
|
7
|
+
$deps <: contains JsStringLiteralExpression() as $dep where {
|
|
8
|
+
$dep <: r"(['\"])(.*)\.js(['\"])"($q1, $name, $q2),
|
|
9
|
+
register_diagnostic(span=$dep, message="Module name should not include file extension.", severity="error", fix_kind="safe"),
|
|
10
|
+
$dep => `$q1$name$q2`
|
|
11
|
+
}
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "biome-plugin-suitescript",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Biome lint plugins and
|
|
5
|
-
"keywords": [
|
|
6
|
-
"biome-plugin",
|
|
7
|
-
"biome",
|
|
8
|
-
"suitescript",
|
|
9
|
-
"netsuite",
|
|
10
|
-
"lint"
|
|
11
|
-
],
|
|
12
|
-
"homepage": "https://github.com/nemchik/biome-plugin-suitescript#readme",
|
|
13
|
-
"bugs": "https://github.com/nemchik/biome-plugin-suitescript/issues",
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/nemchik/biome-plugin-suitescript.git"
|
|
17
|
-
},
|
|
18
|
-
"license": "MIT",
|
|
19
|
-
"author": "Eric Nemchik",
|
|
20
|
-
"type": "module",
|
|
21
|
-
"exports": {
|
|
22
|
-
"./schema.json": "./schema.json",
|
|
23
|
-
"biome": "./biome-manifest.json"
|
|
24
|
-
},
|
|
25
|
-
"bin": {
|
|
26
|
-
"biome-plugin-suitescript": "./dist/bin/biome-plugin-suitescript.js"
|
|
27
|
-
},
|
|
28
|
-
"files": [
|
|
29
|
-
"biome-manifest.json",
|
|
30
|
-
"configs",
|
|
31
|
-
"dist",
|
|
32
|
-
"schema.json",
|
|
33
|
-
"README.md",
|
|
34
|
-
"LICENSE"
|
|
35
|
-
],
|
|
36
|
-
"scripts": {
|
|
37
|
-
"prebuild": "node -e \"require(\\\"node:fs\\\").rmSync(\\\"dist\\\",{recursive:true,force:true})\"",
|
|
38
|
-
"build": "tsc -p tsconfig.build.json && node scripts/build-manifest.ts",
|
|
39
|
-
"check": "biome check",
|
|
40
|
-
"preformat": "npm run typecheck",
|
|
41
|
-
"format": "biome check --write",
|
|
42
|
-
"lint": "biome lint",
|
|
43
|
-
"prepack": "npm run build",
|
|
44
|
-
"sync-modules": "node scripts/sync-modules.ts",
|
|
45
|
-
"pretest": "npm run build",
|
|
46
|
-
"test": "node --test test/*.test.ts",
|
|
47
|
-
"typecheck": "tsc"
|
|
48
|
-
},
|
|
49
|
-
"dependencies": {
|
|
50
|
-
"oxc-parser": "^0.156.0",
|
|
51
|
-
"tinyglobby": "^0.2.17"
|
|
52
|
-
},
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
"@biomejs/biome": "2.6.4",
|
|
55
|
-
"@biomejs/runtime": "2.6.4",
|
|
56
|
-
"@hitc/netsuite-types": "2026.2.4",
|
|
57
|
-
"@types/node": "24.19.2",
|
|
58
|
-
"git-pull-run": "2.1.0",
|
|
59
|
-
"lefthook": "2.2.2",
|
|
60
|
-
"typescript": "7.0.2"
|
|
61
|
-
},
|
|
62
|
-
"peerDependencies": {
|
|
63
|
-
"@biomejs/biome": "^2.6.4"
|
|
64
|
-
},
|
|
65
|
-
"engines": {
|
|
66
|
-
"node": ">=24"
|
|
67
|
-
},
|
|
68
|
-
"devEngines": {
|
|
69
|
-
"runtime": {
|
|
70
|
-
"name": "node",
|
|
71
|
-
"version": "24.22.2",
|
|
72
|
-
"onFail": "error"
|
|
73
|
-
},
|
|
74
|
-
"packageManager": {
|
|
75
|
-
"name": "npm",
|
|
76
|
-
"version": "12.2.1",
|
|
77
|
-
"onFail": "warn"
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
"allowScripts": {
|
|
81
|
-
"lefthook": true
|
|
82
|
-
}
|
|
83
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "biome-plugin-suitescript",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Biome lint plugins and a tag checker for NetSuite SuiteScript 2.1, ported from eslint-plugin-suitescript.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"biome-plugin",
|
|
7
|
+
"biome",
|
|
8
|
+
"suitescript",
|
|
9
|
+
"netsuite",
|
|
10
|
+
"lint"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/nemchik/biome-plugin-suitescript#readme",
|
|
13
|
+
"bugs": "https://github.com/nemchik/biome-plugin-suitescript/issues",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/nemchik/biome-plugin-suitescript.git"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "Eric Nemchik",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
"./schema.json": "./schema.json",
|
|
23
|
+
"biome": "./biome-manifest.json"
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"biome-plugin-suitescript": "./dist/bin/biome-plugin-suitescript.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"biome-manifest.json",
|
|
30
|
+
"configs",
|
|
31
|
+
"dist",
|
|
32
|
+
"schema.json",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"prebuild": "node -e \"require(\\\"node:fs\\\").rmSync(\\\"dist\\\",{recursive:true,force:true})\"",
|
|
38
|
+
"build": "tsc -p tsconfig.build.json && node scripts/build-manifest.ts",
|
|
39
|
+
"check": "biome check",
|
|
40
|
+
"preformat": "npm run typecheck",
|
|
41
|
+
"format": "biome check --write",
|
|
42
|
+
"lint": "biome lint",
|
|
43
|
+
"prepack": "npm run build",
|
|
44
|
+
"sync-modules": "node scripts/sync-modules.ts",
|
|
45
|
+
"pretest": "npm run build",
|
|
46
|
+
"test": "node --test test/*.test.ts",
|
|
47
|
+
"typecheck": "tsc"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"oxc-parser": "^0.156.0",
|
|
51
|
+
"tinyglobby": "^0.2.17"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@biomejs/biome": "2.6.4",
|
|
55
|
+
"@biomejs/runtime": "2.6.4",
|
|
56
|
+
"@hitc/netsuite-types": "2026.2.4",
|
|
57
|
+
"@types/node": "24.19.2",
|
|
58
|
+
"git-pull-run": "2.1.0",
|
|
59
|
+
"lefthook": "2.2.2",
|
|
60
|
+
"typescript": "7.0.2"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@biomejs/biome": "^2.6.4"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=24"
|
|
67
|
+
},
|
|
68
|
+
"devEngines": {
|
|
69
|
+
"runtime": {
|
|
70
|
+
"name": "node",
|
|
71
|
+
"version": "24.22.2",
|
|
72
|
+
"onFail": "error"
|
|
73
|
+
},
|
|
74
|
+
"packageManager": {
|
|
75
|
+
"name": "npm",
|
|
76
|
+
"version": "12.2.1",
|
|
77
|
+
"onFail": "warn"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"allowScripts": {
|
|
81
|
+
"lefthook": true
|
|
82
|
+
}
|
|
83
|
+
}
|
package/schema.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$id": "https://github.com/nemchik/biome-plugin-suitescript/schema.json",
|
|
3
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
-
"additionalProperties": false,
|
|
5
|
-
"description": "Configuration for the `biome-plugin-suitescript check` command.",
|
|
6
|
-
"properties": {
|
|
7
|
-
"$schema": { "type": "string" },
|
|
8
|
-
"includes": {
|
|
9
|
-
"description": "Glob patterns of SuiteScript source files to check: files deployed to the file cabinet, or the sources they are transpiled from (not the transpiled output). Prefix a pattern with ! to exclude, as in Biome's `includes`.",
|
|
10
|
-
"examples": [
|
|
11
|
-
["src/TypeScripts/**/*.{js,ts}", "!**/*.d.ts", "!**/*.test.*"]
|
|
12
|
-
],
|
|
13
|
-
"items": { "minLength": 1, "type": "string" },
|
|
14
|
-
"minItems": 1,
|
|
15
|
-
"type": "array"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"required": ["includes"],
|
|
19
|
-
"title": "biome-plugin-suitescript configuration",
|
|
20
|
-
"type": "object"
|
|
21
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$id": "https://github.com/nemchik/biome-plugin-suitescript/schema.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"description": "Configuration for the `biome-plugin-suitescript check` command.",
|
|
6
|
+
"properties": {
|
|
7
|
+
"$schema": { "type": "string" },
|
|
8
|
+
"includes": {
|
|
9
|
+
"description": "Glob patterns of SuiteScript source files to check: files deployed to the file cabinet, or the sources they are transpiled from (not the transpiled output). Prefix a pattern with ! to exclude, as in Biome's `includes`.",
|
|
10
|
+
"examples": [
|
|
11
|
+
["src/TypeScripts/**/*.{js,ts}", "!**/*.d.ts", "!**/*.test.*"]
|
|
12
|
+
],
|
|
13
|
+
"items": { "minLength": 1, "type": "string" },
|
|
14
|
+
"minItems": 1,
|
|
15
|
+
"type": "array"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"required": ["includes"],
|
|
19
|
+
"title": "biome-plugin-suitescript configuration",
|
|
20
|
+
"type": "object"
|
|
21
|
+
}
|