eslint-plugin-greasemonkey 1.5.1 → 1.6.0
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/README.md +309 -164
- package/package.json +3 -3
- package/src/data/apis.js +0 -1
- package/src/data/deprecations.js +7 -2
- package/src/data/headers.js +12 -6
- package/src/index.js +20 -27
- package/src/rules/meta-order.js +22 -7
- package/src/rules/meta-spacing.js +21 -2
- package/src/rules/require-required-fields.js +7 -2
- package/src/rules/require-sri-hashing.js +1 -1
- package/src/rules/valid-field-values.js +23 -0
- package/src/utils.js +46 -6
- /package/src/rules/{valid-grants.js → no-invalid-grants.js} +0 -0
package/README.md
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
<a href="#license">
|
|
8
8
|
<img alt="[License: MIT]" src="https://img.shields.io/badge/License-MIT-f1f20a.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
9
9
|
<a target="_blank" href="https://eslint.org/">
|
|
10
|
-
<img alt="[Requires ESLint >=9.0.0]"src="https://img.shields.io/badge/Requires-ESLint_%3E%3D9.0.0-4B32C3?style=for-the-badge&logo=eslint"
|
|
10
|
+
<img alt="[Requires ESLint >=9.0.0]" src="https://img.shields.io/badge/Requires-ESLint_%3E%3D9.0.0-4B32C3?style=for-the-badge&logo=eslint"></a>
|
|
11
|
+
<br><br>
|
|
11
12
|
|
|
12
13
|
ESLint rules for Greasemonkey userscripts.
|
|
13
14
|
|
|
@@ -25,7 +26,12 @@ npm i -D eslint-plugin-greasemonkey
|
|
|
25
26
|
|
|
26
27
|
---
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
<h2 id="usage">
|
|
30
|
+
Usage
|
|
31
|
+
<a title="Copy section URL" target="_blank"
|
|
32
|
+
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23usage">
|
|
33
|
+
<img height=17 width=22 alt="[Copy section URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="bottom"></a>
|
|
34
|
+
</h2>
|
|
29
35
|
|
|
30
36
|
Add a bundled config to your `eslint.config.*js`:
|
|
31
37
|
|
|
@@ -40,7 +46,7 @@ export default [
|
|
|
40
46
|
rules: {
|
|
41
47
|
...greasemonkey.configs.recommended.rules,
|
|
42
48
|
'greasemonkey/no-unused-resources': 'off', // selectively disable rule
|
|
43
|
-
'greasemonkey/meta-spacing': ['error', 2]
|
|
49
|
+
'greasemonkey/meta-spacing': ['error', { spaces: 2 }] // selectively tweak rule
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
]
|
|
@@ -52,31 +58,12 @@ Avaialble bundles: `recommended`, `strict`, `tampermonkey`, `violentmonkey`, `gr
|
|
|
52
58
|
|
|
53
59
|
---
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
| [`no-duplicate-keys`](#no-duplicate-keys) | Disallows duplicate metadata keys | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
62
|
-
| [`no-invalid-headers`](#no-invalid-headers) | Disallows invalid or unsupported metadata headers | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
63
|
-
| [`no-missing-grants`](#no-missing-grants) | Flags API calls w/o a matching `@grant` | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
64
|
-
| [`no-missing-resources`](#no-missing-resources) | Flags `@resource` references w/o a matching declaration | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
65
|
-
| [`no-unused-grants`](#no-unused-grants) | Flags `@grant` entries whose APIs are never used | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
66
|
-
| [`no-unused-resources`](#no-unused-resources) | Flags `@resource` entries that are never referenced | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
67
|
-
| [`prefer-match`](#prefer-match) | Prefers `@match` over `@include` | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
68
|
-
| [`require-blank-line-after-meta-block`](#require-blank-line-after-meta-block) | Requires a blank line between the metadata and code | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
69
|
-
| [`require-homepage-pair`](#require-homepage-pair) | Requires `@homepage` and `@homepageURL` to be used together | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> |
|
|
70
|
-
| [`require-matching-localized-fields`](#require-matching-localized-fields) | Requires matching localized `@name:xx` / `@description:xx` pairs | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
71
|
-
| [`require-required-fields`](#require-required-fields) | Requires essential metadata fields | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
72
|
-
| [`require-space-before-meta-key`](#require-space-before-meta-key) | Requires exactly one space between `//` and metadata keys | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
73
|
-
| [`require-sri-hashing`](#require-sri-hashing) | Requires SRI hashes for external `@require` URLs | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
74
|
-
| [`require-update-download-pair`](#require-update-download-pair) | Requires `@updateURL` and `@downloadURL` to be used together | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> |
|
|
75
|
-
| [`require-user-js-filename`](#require-user-js-filename) | Requires userscript filenames end in `.user.js` | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
76
|
-
| [`valid-field-values`](#valid-field-values) | Validates `@version` and URL fields | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
77
|
-
| [`valid-grants`](#valid-grants) | Disallows invalid or unsupported `@grant` values | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> | <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> |
|
|
78
|
-
|
|
79
|
-
---
|
|
61
|
+
<h2 id="supported-rules">
|
|
62
|
+
Supported rules
|
|
63
|
+
<a title="Copy section URL" target="_blank"
|
|
64
|
+
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23supported-rules">
|
|
65
|
+
<img height=17 width=22 alt="[Copy section URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="bottom"></a>
|
|
66
|
+
</h2>
|
|
80
67
|
|
|
81
68
|
<h3 id="meta-order">
|
|
82
69
|
<code>meta-order</code>
|
|
@@ -84,26 +71,22 @@ Avaialble bundles: `recommended`, `strict`, `tampermonkey`, `violentmonkey`, `gr
|
|
|
84
71
|
<img height=18 alt="[Strict only]" src="https://img.shields.io/badge/Strict_only-ff8c42?style=flat-square" align="middle"></a>
|
|
85
72
|
<a title="Accepts eslint --fix" target="_blank" href="https://eslint.org/docs/latest/use/command-line-interface#--fix">
|
|
86
73
|
<img height=18 alt="[Auto-fixable]" src="https://img.shields.io/badge/Auto--fixable-e8357a?style=flat-square" align="middle"></a>
|
|
87
|
-
<a title="Doesn't
|
|
74
|
+
<a title="Doesn't prevent bugs" href="#meta-order">
|
|
88
75
|
<img height=18 alt="[Stylistic]" src="https://img.shields.io/badge/Stylistic-af68ff?style=flat-square" align="middle"></a>
|
|
89
|
-
<a title="Accepts array w/ options"
|
|
76
|
+
<a title="Accepts array w/ options" href="#usage">
|
|
90
77
|
<img height=18 alt="[Configurable]" src="https://img.shields.io/badge/Configurable-black?style=flat-square" align="middle"></a>
|
|
91
78
|
<a title="Copy rule URL" target="_blank"
|
|
92
79
|
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23meta-order">
|
|
93
80
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
94
81
|
</h3>
|
|
95
82
|
|
|
96
|
-
>
|
|
97
|
-
|
|
98
|
-
#### Options
|
|
83
|
+
<details>
|
|
99
84
|
|
|
100
|
-
|
|
85
|
+
<summary>Enforces a preferred order for metadata keys.</summary>
|
|
101
86
|
|
|
102
|
-
|
|
87
|
+
#### Options
|
|
103
88
|
|
|
104
|
-
|
|
105
|
-
/* eslint greasemonkey/meta-order: ['error', ['run-in', 'inject-into']] */
|
|
106
|
-
```
|
|
89
|
+
- `order` (default `[]`) – metadata keys in custom order
|
|
107
90
|
|
|
108
91
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
109
92
|
|
|
@@ -115,12 +98,6 @@ For example:
|
|
|
115
98
|
! // @namespace example.com
|
|
116
99
|
// @author John Doe
|
|
117
100
|
! // @license MIT
|
|
118
|
-
// @icon https://example.com/icon.png
|
|
119
|
-
! // @match https://example.com/*
|
|
120
|
-
// @grant GM_setValue
|
|
121
|
-
// @require https://example.com/lib.js
|
|
122
|
-
// @resource logo https://example.com/logo.png
|
|
123
|
-
! // @connect example.com
|
|
124
101
|
// ==/UserScript==
|
|
125
102
|
```
|
|
126
103
|
|
|
@@ -137,16 +114,6 @@ For example:
|
|
|
137
114
|
+ // @namespace example.com
|
|
138
115
|
+ // @version 1.0.0
|
|
139
116
|
+ // @license MIT
|
|
140
|
-
// @icon https://example.com/icon.png
|
|
141
|
-
- // @match https://example.com/*
|
|
142
|
-
+ // @connect example.com
|
|
143
|
-
// @grant GM_setValue
|
|
144
|
-
- // @require https://example.com/lib.js
|
|
145
|
-
- // @resource logo https://example.com/logo.png
|
|
146
|
-
- // @connect example.com
|
|
147
|
-
+ // @match https://example.com/*
|
|
148
|
-
+ // @require https://example.com/lib.js
|
|
149
|
-
+ // @resource logo https://example.com/logo.png
|
|
150
117
|
// ==/UserScript==
|
|
151
118
|
```
|
|
152
119
|
|
|
@@ -154,6 +121,10 @@ For example:
|
|
|
154
121
|
|
|
155
122
|
If you don't care about the order of metadata fields.
|
|
156
123
|
|
|
124
|
+
#### Introduced in
|
|
125
|
+
|
|
126
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.5.0">v1.5.0</a> (September 15, 2026)
|
|
127
|
+
|
|
157
128
|
#### See also
|
|
158
129
|
|
|
159
130
|
- [`meta-spacing`](#meta-spacing)
|
|
@@ -167,31 +138,35 @@ If you don't care about the order of metadata fields.
|
|
|
167
138
|
|
|
168
139
|
---
|
|
169
140
|
|
|
141
|
+
</details>
|
|
142
|
+
|
|
170
143
|
<h3 id="meta-spacing">
|
|
171
144
|
<code>meta-spacing</code>
|
|
172
145
|
<a title="Included in recommended config" href="#usage">
|
|
173
146
|
<img height=18 alt="[Recommended]" src="https://img.shields.io/badge/Recommended-f1f20a?style=flat-square" align="middle"></a>
|
|
174
147
|
<a title="Accepts eslint --fix" target="_blank" href="https://eslint.org/docs/latest/use/command-line-interface#--fix">
|
|
175
148
|
<img height=18 alt="[Auto-fixable]" src="https://img.shields.io/badge/Auto--fixable-e8357a?style=flat-square" align="middle"></a>
|
|
176
|
-
<a title="Doesn't
|
|
149
|
+
<a title="Doesn't prevent bugs" href="#meta-spacing">
|
|
177
150
|
<img height=18 alt="[Stylistic]" src="https://img.shields.io/badge/Stylistic-af68ff?style=flat-square" align="middle"></a>
|
|
178
|
-
<a title="Accepts array w/ options"
|
|
151
|
+
<a title="Accepts array w/ options" href="#usage">
|
|
179
152
|
<img height=18 alt="[Configurable]" src="https://img.shields.io/badge/Configurable-black?style=flat-square" align="middle"></a>
|
|
180
153
|
<a title="Copy rule URL" target="_blank"
|
|
181
154
|
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23meta-spacing">
|
|
182
155
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
183
156
|
</h3>
|
|
184
157
|
|
|
185
|
-
>
|
|
158
|
+
<details>
|
|
159
|
+
|
|
160
|
+
<summary>Aligns metadata values to the column after the longest key.</summary>
|
|
186
161
|
|
|
187
162
|
#### Options
|
|
188
163
|
|
|
189
|
-
- `
|
|
164
|
+
- `spaces` (default `3`) – minimum spaces after the longest key
|
|
190
165
|
|
|
191
166
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
192
167
|
|
|
193
168
|
```diff
|
|
194
|
-
/* eslint greasemonkey/meta-spacing: ['error', 1] */
|
|
169
|
+
/* eslint greasemonkey/meta-spacing: ['error', { spaces: 1 }] */
|
|
195
170
|
|
|
196
171
|
// ==UserScript==
|
|
197
172
|
! // @name My Script
|
|
@@ -203,7 +178,7 @@ If you don't care about the order of metadata fields.
|
|
|
203
178
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> Correct code
|
|
204
179
|
|
|
205
180
|
```diff
|
|
206
|
-
/* eslint greasemonkey/meta-spacing: ['error', 1] */
|
|
181
|
+
/* eslint greasemonkey/meta-spacing: ['error', { spaces: 1 }] */
|
|
207
182
|
|
|
208
183
|
// ==UserScript==
|
|
209
184
|
- // @name My Script
|
|
@@ -218,6 +193,10 @@ If you don't care about the order of metadata fields.
|
|
|
218
193
|
|
|
219
194
|
If you don't care about visual alignment in metadata blocks.
|
|
220
195
|
|
|
196
|
+
#### Introduced in
|
|
197
|
+
|
|
198
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.0.0">v1.0.0</a> (September 9, 2026)
|
|
199
|
+
|
|
221
200
|
#### See also
|
|
222
201
|
|
|
223
202
|
- [`require-blank-line-after-meta-block`](#require-blank-line-after-meta-block)
|
|
@@ -231,6 +210,8 @@ If you don't care about visual alignment in metadata blocks.
|
|
|
231
210
|
|
|
232
211
|
---
|
|
233
212
|
|
|
213
|
+
</details>
|
|
214
|
+
|
|
234
215
|
<h3 id="no-duplicate-keys">
|
|
235
216
|
<code>no-duplicate-keys</code>
|
|
236
217
|
<a title="Included in recommended config" href="#usage">
|
|
@@ -240,7 +221,9 @@ If you don't care about visual alignment in metadata blocks.
|
|
|
240
221
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
241
222
|
</h3>
|
|
242
223
|
|
|
243
|
-
>
|
|
224
|
+
<details>
|
|
225
|
+
|
|
226
|
+
<summary>Disallows duplicate single-value metadata keys.</summary>
|
|
244
227
|
|
|
245
228
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
246
229
|
|
|
@@ -250,6 +233,8 @@ If you don't care about visual alignment in metadata blocks.
|
|
|
250
233
|
! // @name Bar
|
|
251
234
|
! // @version 1.0.0
|
|
252
235
|
! // @version 2.0.0
|
|
236
|
+
// @match https://a.example.com/*
|
|
237
|
+
// @match https://b.example.com/*
|
|
253
238
|
// ==/UserScript==
|
|
254
239
|
```
|
|
255
240
|
|
|
@@ -259,12 +244,12 @@ If you don't care about visual alignment in metadata blocks.
|
|
|
259
244
|
// ==UserScript==
|
|
260
245
|
- // @name Foo
|
|
261
246
|
- // @name Bar
|
|
247
|
+
+ // @name My Script
|
|
262
248
|
- // @version 1.0.0
|
|
263
249
|
- // @version 2.0.0
|
|
264
|
-
+ // @name My Script
|
|
265
250
|
+ // @version 1.0.0
|
|
266
|
-
|
|
267
|
-
|
|
251
|
+
// @match https://a.example.com/*
|
|
252
|
+
// @match https://b.example.com/*
|
|
268
253
|
// ==/UserScript==
|
|
269
254
|
```
|
|
270
255
|
|
|
@@ -272,6 +257,10 @@ If you don't care about visual alignment in metadata blocks.
|
|
|
272
257
|
|
|
273
258
|
If you intentionally repeat single-value keys.
|
|
274
259
|
|
|
260
|
+
#### Introduced in
|
|
261
|
+
|
|
262
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.2.0">v1.2.0</a> (September 11, 2026)
|
|
263
|
+
|
|
275
264
|
#### See also
|
|
276
265
|
|
|
277
266
|
- [`require-matching-localized-fields`](#require-matching-localized-fields)
|
|
@@ -285,22 +274,109 @@ If you intentionally repeat single-value keys.
|
|
|
285
274
|
|
|
286
275
|
---
|
|
287
276
|
|
|
277
|
+
</details>
|
|
278
|
+
|
|
279
|
+
<h3 id="no-invalid-grants"><a deprecated id="valid-grants"></a>
|
|
280
|
+
<code>no-invalid-grants</code>
|
|
281
|
+
<a title="Included in recommended config" href="#usage">
|
|
282
|
+
<img height=18 alt="[Recommended]" src="https://img.shields.io/badge/Recommended-f1f20a?style=flat-square" align="middle"></a>
|
|
283
|
+
<a title="Accepts array w/ options" href="#usage">
|
|
284
|
+
<img height=18 alt="[Configurable]" src="https://img.shields.io/badge/Configurable-black?style=flat-square" align="middle"></a>
|
|
285
|
+
<a title="Copy rule URL" target="_blank"
|
|
286
|
+
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23no-invalid-grants">
|
|
287
|
+
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
288
|
+
</h3>
|
|
289
|
+
|
|
290
|
+
<details>
|
|
291
|
+
|
|
292
|
+
<summary>Disallows invalid or unsupported <code>@grant</code> values.</summary>
|
|
293
|
+
|
|
294
|
+
#### Options
|
|
295
|
+
|
|
296
|
+
- `target` (default `'all'`) – manager(s) whose grants to validate against (`'all'`, `'tampermonkey'`, `'violentmonkey'`, `'greasemonkey'`, `'scriptcat'`), as a single string or array
|
|
297
|
+
- `allowedGrants` (default `[]`) – additional `@grant` values to allow beyond the built-in list (covering Tampermonkey, Violentmonkey and ScriptCat), as a single string or array
|
|
298
|
+
|
|
299
|
+
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
300
|
+
|
|
301
|
+
```diff
|
|
302
|
+
/* eslint greasemonkey/no-invalid-grants: ['error', { target: 'tampermonkey' }] */
|
|
303
|
+
|
|
304
|
+
// ==UserScript==
|
|
305
|
+
// @grant GM_getTab
|
|
306
|
+
! // @grant CAT.agent.dom
|
|
307
|
+
// ==/UserScript==
|
|
308
|
+
|
|
309
|
+
/* eslint greasemonkey/no-invalid-grants: ['error', { target: 'scriptcat' }] */
|
|
310
|
+
|
|
311
|
+
// ==UserScript==
|
|
312
|
+
! // @grant GM_getTab
|
|
313
|
+
// @grant CAT.agent.dom
|
|
314
|
+
// ==/UserScript==
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> Correct code
|
|
318
|
+
|
|
319
|
+
```diff
|
|
320
|
+
/* eslint greasemonkey/no-invalid-grants: ['error', { target: 'tampermonkey' }] */
|
|
321
|
+
|
|
322
|
+
// ==UserScript==
|
|
323
|
+
// @grant GM_getTab
|
|
324
|
+
- // @grant CAT.agent.dom
|
|
325
|
+
// ==/UserScript==
|
|
326
|
+
|
|
327
|
+
/* eslint greasemonkey/no-invalid-grants: ['error', { target: 'scriptcat' }] */
|
|
328
|
+
|
|
329
|
+
// ==UserScript==
|
|
330
|
+
- // @grant GM_getTab
|
|
331
|
+
// @grant CAT.agent.dom
|
|
332
|
+
// ==/UserScript==
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
#### When not to use it
|
|
336
|
+
|
|
337
|
+
If you don't want `@grant` validation at all. For individual uncovered grants, prefer whitelisting via `allowedGrants` over disabling the rule.
|
|
338
|
+
|
|
339
|
+
#### Introduced in
|
|
340
|
+
|
|
341
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.2.0">v1.2.0</a> (September 11, 2026) as `valid-grants`
|
|
342
|
+
|
|
343
|
+
#### Renamed in
|
|
344
|
+
|
|
345
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.5.2">v1.5.2</a> (September 16, 2026) to `no-invalid-grants`
|
|
346
|
+
|
|
347
|
+
#### See also
|
|
348
|
+
|
|
349
|
+
- [`no-missing-grants`](#no-missing-grants)
|
|
350
|
+
- [`no-unused-grants`](#no-unused-grants)
|
|
351
|
+
|
|
352
|
+
<div align="center">
|
|
353
|
+
|
|
354
|
+
[Back to index ↑][epg-rules]
|
|
355
|
+
|
|
356
|
+
</div>
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
</details>
|
|
361
|
+
|
|
288
362
|
<h3 id="no-invalid-headers">
|
|
289
363
|
<code>no-invalid-headers</code>
|
|
290
364
|
<a title="Included in recommended config" href="#usage">
|
|
291
365
|
<img height=18 alt="[Recommended]" src="https://img.shields.io/badge/Recommended-f1f20a?style=flat-square" align="middle"></a>
|
|
292
|
-
<a title="Accepts array w/ options"
|
|
366
|
+
<a title="Accepts array w/ options" href="#usage">
|
|
293
367
|
<img height=18 alt="[Configurable]" src="https://img.shields.io/badge/Configurable-black?style=flat-square" align="middle"></a>
|
|
294
368
|
<a title="Copy rule URL" target="_blank"
|
|
295
369
|
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23no-invalid-headers">
|
|
296
370
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
297
371
|
</h3>
|
|
298
372
|
|
|
299
|
-
>
|
|
373
|
+
<details>
|
|
374
|
+
|
|
375
|
+
<summary>Disallows invalid or unsupported metadata headers.</summary>
|
|
300
376
|
|
|
301
377
|
#### Options
|
|
302
378
|
|
|
303
|
-
- `target` (default `'all'`) – manager(s) whose headers to validate against (`'all'`, `'tampermonkey'`, `'violentmonkey'`, `'greasemonkey'`), as a single string or array
|
|
379
|
+
- `target` (default `'all'`) – manager(s) whose headers to validate against (`'all'`, `'tampermonkey'`, `'violentmonkey'`, `'greasemonkey'`, `'scriptcat'`), as a single string or array
|
|
304
380
|
- `allowedHeaders` (default `[]`) – additional headers to allow (strings or regexes), as a single value or array
|
|
305
381
|
|
|
306
382
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
@@ -334,10 +410,14 @@ If you intentionally repeat single-value keys.
|
|
|
334
410
|
|
|
335
411
|
If your script relies heavily on custom headers and you'd rather not maintain `allowedHeaders`.
|
|
336
412
|
|
|
413
|
+
#### Introduced in
|
|
414
|
+
|
|
415
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.0.0">v1.0.0</a> (September 9, 2026)
|
|
416
|
+
|
|
337
417
|
#### See also
|
|
338
418
|
|
|
419
|
+
- [`no-invalid-grants`](#no-invalid-grants)
|
|
339
420
|
- [`valid-field-values`](#valid-field-values)
|
|
340
|
-
- [`valid-grants`](#valid-grants)
|
|
341
421
|
|
|
342
422
|
<div align="center">
|
|
343
423
|
|
|
@@ -347,6 +427,8 @@ If your script relies heavily on custom headers and you'd rather not maintain `a
|
|
|
347
427
|
|
|
348
428
|
---
|
|
349
429
|
|
|
430
|
+
</details>
|
|
431
|
+
|
|
350
432
|
<h3 id="no-missing-grants">
|
|
351
433
|
<code>no-missing-grants</code>
|
|
352
434
|
<a title="Included in recommended config" href="#usage">
|
|
@@ -356,7 +438,9 @@ If your script relies heavily on custom headers and you'd rather not maintain `a
|
|
|
356
438
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
357
439
|
</h3>
|
|
358
440
|
|
|
359
|
-
>
|
|
441
|
+
<details>
|
|
442
|
+
|
|
443
|
+
<summary>Flags API calls (e.g. <code>GM_setValue</code>, <code>GM.setValue</code>, <code>CAT.agent.dom</code>) used w/o a matching <code>@grant</code> declaration.</summary>
|
|
360
444
|
|
|
361
445
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
362
446
|
|
|
@@ -383,10 +467,14 @@ If your script relies heavily on custom headers and you'd rather not maintain `a
|
|
|
383
467
|
|
|
384
468
|
If you use APIs through aliases or wrappers that obscure the original call site.
|
|
385
469
|
|
|
470
|
+
#### Introduced in
|
|
471
|
+
|
|
472
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.3.0">v1.3.0</a> (September 12, 2026)
|
|
473
|
+
|
|
386
474
|
#### See also
|
|
387
475
|
|
|
476
|
+
- [`no-invalid-grants`](#no-invalid-grants)
|
|
388
477
|
- [`no-unused-grants`](#no-unused-grants)
|
|
389
|
-
- [`valid-grants`](#valid-grants)
|
|
390
478
|
|
|
391
479
|
<div align="center">
|
|
392
480
|
|
|
@@ -396,6 +484,8 @@ If you use APIs through aliases or wrappers that obscure the original call site.
|
|
|
396
484
|
|
|
397
485
|
---
|
|
398
486
|
|
|
487
|
+
</details>
|
|
488
|
+
|
|
399
489
|
<h3 id="no-missing-resources">
|
|
400
490
|
<code>no-missing-resources</code>
|
|
401
491
|
<a title="Included in recommended config" href="#usage">
|
|
@@ -405,7 +495,9 @@ If you use APIs through aliases or wrappers that obscure the original call site.
|
|
|
405
495
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
406
496
|
</h3>
|
|
407
497
|
|
|
408
|
-
>
|
|
498
|
+
<details>
|
|
499
|
+
|
|
500
|
+
<summary>Flags <code>@resource</code> references via <code>GM_getResourceText()</code> or <code>GM_getResourceURL()</code> where no matching <code>@resource</code> is declared.</summary>
|
|
409
501
|
|
|
410
502
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
411
503
|
|
|
@@ -432,6 +524,10 @@ If you use APIs through aliases or wrappers that obscure the original call site.
|
|
|
432
524
|
|
|
433
525
|
If you reference resources through an alias or computed pattern that obscures the call site.
|
|
434
526
|
|
|
527
|
+
#### Introduced in
|
|
528
|
+
|
|
529
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.4.0">v1.4.0</a> (September 13, 2026)
|
|
530
|
+
|
|
435
531
|
#### See also
|
|
436
532
|
|
|
437
533
|
- [`no-unused-resources`](#no-unused-resources)
|
|
@@ -444,6 +540,8 @@ If you reference resources through an alias or computed pattern that obscures th
|
|
|
444
540
|
|
|
445
541
|
---
|
|
446
542
|
|
|
543
|
+
</details>
|
|
544
|
+
|
|
447
545
|
<h3 id="no-unused-grants">
|
|
448
546
|
<code>no-unused-grants</code>
|
|
449
547
|
<a title="Included in recommended config" href="#usage">
|
|
@@ -453,7 +551,9 @@ If you reference resources through an alias or computed pattern that obscures th
|
|
|
453
551
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
454
552
|
</h3>
|
|
455
553
|
|
|
456
|
-
>
|
|
554
|
+
<details>
|
|
555
|
+
|
|
556
|
+
<summary>Flags <code>@grant</code> entries whose APIs are never used in the script.</summary>
|
|
457
557
|
|
|
458
558
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
459
559
|
|
|
@@ -477,10 +577,14 @@ If you reference resources through an alias or computed pattern that obscures th
|
|
|
477
577
|
|
|
478
578
|
If you access the granted API through an alias or computed property rather than calling it directly.
|
|
479
579
|
|
|
580
|
+
#### Introduced in
|
|
581
|
+
|
|
582
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.0.0">v1.0.0</a> (September 9, 2026)
|
|
583
|
+
|
|
480
584
|
#### See also
|
|
481
585
|
|
|
586
|
+
- [`no-invalid-grants`](#no-invalid-grants)
|
|
482
587
|
- [`no-missing-grants`](#no-missing-grants)
|
|
483
|
-
- [`valid-grants`](#valid-grants)
|
|
484
588
|
|
|
485
589
|
<div align="center">
|
|
486
590
|
|
|
@@ -490,6 +594,8 @@ If you access the granted API through an alias or computed property rather than
|
|
|
490
594
|
|
|
491
595
|
---
|
|
492
596
|
|
|
597
|
+
</details>
|
|
598
|
+
|
|
493
599
|
<h3 id="no-unused-resources">
|
|
494
600
|
<code>no-unused-resources</code>
|
|
495
601
|
<a title="Included in recommended config" href="#usage">
|
|
@@ -499,7 +605,9 @@ If you access the granted API through an alias or computed property rather than
|
|
|
499
605
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
500
606
|
</h3>
|
|
501
607
|
|
|
502
|
-
>
|
|
608
|
+
<details>
|
|
609
|
+
|
|
610
|
+
<summary>Flags <code>@resource</code> entries that are never referenced via <code>GM_getResourceText()</code>or <code>GM_getResourceURL()</code></summary>
|
|
503
611
|
|
|
504
612
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
505
613
|
|
|
@@ -523,6 +631,10 @@ If you access the granted API through an alias or computed property rather than
|
|
|
523
631
|
|
|
524
632
|
If you pass resource names through variables or aliases rather than use them literally.
|
|
525
633
|
|
|
634
|
+
#### Introduced in
|
|
635
|
+
|
|
636
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.0.0">v1.0.0</a> (September 9, 2026)
|
|
637
|
+
|
|
526
638
|
#### See also
|
|
527
639
|
|
|
528
640
|
- [`no-missing-resources`](#no-missing-resources)
|
|
@@ -535,6 +647,8 @@ If you pass resource names through variables or aliases rather than use them lit
|
|
|
535
647
|
|
|
536
648
|
---
|
|
537
649
|
|
|
650
|
+
</details>
|
|
651
|
+
|
|
538
652
|
<h3 id="prefer-match">
|
|
539
653
|
<code>prefer-match</code>
|
|
540
654
|
<a title="Included in recommended config" href="#usage">
|
|
@@ -544,7 +658,9 @@ If you pass resource names through variables or aliases rather than use them lit
|
|
|
544
658
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
545
659
|
</h3>
|
|
546
660
|
|
|
547
|
-
|
|
661
|
+
<details>
|
|
662
|
+
|
|
663
|
+
<summary>Prefers <code>@match</code> over <code>@include</code> to align w/ <a target="_blank" href="https://developer.chrome.com/docs/extensions/reference/api/userScripts/"><code>chrome.userScripts</code></a> syntax.</summary>
|
|
548
664
|
|
|
549
665
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
550
666
|
|
|
@@ -567,6 +683,10 @@ If you pass resource names through variables or aliases rather than use them lit
|
|
|
567
683
|
|
|
568
684
|
If you rely on `@include` patterns that cannot be expressed using `@match`.
|
|
569
685
|
|
|
686
|
+
#### Introduced in
|
|
687
|
+
|
|
688
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.3.0">v1.3.0</a> (September 12, 2026)
|
|
689
|
+
|
|
570
690
|
#### See also
|
|
571
691
|
|
|
572
692
|
- <a target="_blank" href="https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns">Chrome match patterns</a>
|
|
@@ -579,20 +699,24 @@ If you rely on `@include` patterns that cannot be expressed using `@match`.
|
|
|
579
699
|
|
|
580
700
|
---
|
|
581
701
|
|
|
582
|
-
|
|
702
|
+
</details>
|
|
703
|
+
|
|
704
|
+
<h3 id="require-blank-line-after-meta-block"><a deprecated id="require-meta-newline"></a>
|
|
583
705
|
<code>require-blank-line-after-meta-block</code>
|
|
584
706
|
<a title="Included in recommended config" href="#usage">
|
|
585
707
|
<img height=18 alt="[Recommended]" src="https://img.shields.io/badge/Recommended-f1f20a?style=flat-square" align="middle"></a>
|
|
586
708
|
<a title="Accepts eslint --fix" target="_blank" href="https://eslint.org/docs/latest/use/command-line-interface#--fix">
|
|
587
709
|
<img height=18 alt="[Auto-fixable]" src="https://img.shields.io/badge/Auto--fixable-e8357a?style=flat-square" align="middle"></a>
|
|
588
|
-
<a title="Doesn't
|
|
710
|
+
<a title="Doesn't prevent bugs" href="#require-blank-line-after-meta-block">
|
|
589
711
|
<img height=18 alt="[Stylistic]" src="https://img.shields.io/badge/Stylistic-af68ff?style=flat-square" align="middle"></a>
|
|
590
712
|
<a title="Copy rule URL" target="_blank"
|
|
591
713
|
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23require-blank-line-after-meta-block">
|
|
592
714
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
593
715
|
</h3>
|
|
594
716
|
|
|
595
|
-
>
|
|
717
|
+
<details>
|
|
718
|
+
|
|
719
|
+
<summary>Requires a blank line between the closing <code>// ==/UserScript==</code> and the first line of code.</summary>
|
|
596
720
|
|
|
597
721
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
598
722
|
|
|
@@ -617,8 +741,17 @@ If you rely on `@include` patterns that cannot be expressed using `@match`.
|
|
|
617
741
|
|
|
618
742
|
If you don't care about visual separation between metadata and code.
|
|
619
743
|
|
|
744
|
+
#### Introduced in
|
|
745
|
+
|
|
746
|
+
[v1.3.0](https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.3.0) (September 12, 2026) as `require-meta-newline`
|
|
747
|
+
|
|
748
|
+
#### Renamed in
|
|
749
|
+
|
|
750
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.4.0">v1.4.0</a> (September 13, 2026) to `require-blank-line-after-meta-block`
|
|
751
|
+
|
|
620
752
|
#### See also
|
|
621
753
|
|
|
754
|
+
- [`meta-order`](#meta-order)
|
|
622
755
|
- [`meta-spacing`](#meta-spacing)
|
|
623
756
|
|
|
624
757
|
<div align="center">
|
|
@@ -629,6 +762,8 @@ If you don't care about visual separation between metadata and code.
|
|
|
629
762
|
|
|
630
763
|
---
|
|
631
764
|
|
|
765
|
+
</details>
|
|
766
|
+
|
|
632
767
|
<h3 id="require-homepage-pair">
|
|
633
768
|
<code>require-homepage-pair</code>
|
|
634
769
|
<a title="Only included in strict config" href="#usage">
|
|
@@ -640,7 +775,9 @@ If you don't care about visual separation between metadata and code.
|
|
|
640
775
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
641
776
|
</h3>
|
|
642
777
|
|
|
643
|
-
>
|
|
778
|
+
<details>
|
|
779
|
+
|
|
780
|
+
<summary>Requires <code>@homepage</code> and <code>@homepageURL</code> to be used together.</summary>
|
|
644
781
|
|
|
645
782
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
646
783
|
|
|
@@ -663,6 +800,10 @@ If you don't care about visual separation between metadata and code.
|
|
|
663
800
|
|
|
664
801
|
If your target manager does not fall back to `@namespace` when a homepage key is missing (which usually produces a broken URL).
|
|
665
802
|
|
|
803
|
+
#### Introduced in
|
|
804
|
+
|
|
805
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.3.0">v1.3.0</a> (September 12, 2026)
|
|
806
|
+
|
|
666
807
|
#### See also
|
|
667
808
|
|
|
668
809
|
- [`require-update-download-pair`](#require-update-download-pair)
|
|
@@ -675,18 +816,22 @@ If your target manager does not fall back to `@namespace` when a homepage key is
|
|
|
675
816
|
|
|
676
817
|
---
|
|
677
818
|
|
|
819
|
+
</details>
|
|
820
|
+
|
|
678
821
|
<h3 id="require-matching-localized-fields">
|
|
679
822
|
<code>require-matching-localized-fields</code>
|
|
680
823
|
<a title="Included in recommended config" href="#usage">
|
|
681
824
|
<img height=18 alt="[Recommended]" src="https://img.shields.io/badge/Recommended-f1f20a?style=flat-square" align="middle"></a>
|
|
682
|
-
<a title="Accepts array w/ options"
|
|
825
|
+
<a title="Accepts array w/ options" href="#usage">
|
|
683
826
|
<img height=18 alt="[Configurable]" src="https://img.shields.io/badge/Configurable-black?style=flat-square" align="middle"></a>
|
|
684
827
|
<a title="Copy rule URL" target="_blank"
|
|
685
828
|
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23require-matching-localized-fields">
|
|
686
829
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
687
830
|
</h3>
|
|
688
831
|
|
|
689
|
-
>
|
|
832
|
+
<details>
|
|
833
|
+
|
|
834
|
+
<summary>Requires that every <code>@name:xx</code> has a matching <code>@description:xx</code> (and vice versa).</summary>
|
|
690
835
|
|
|
691
836
|
#### Options
|
|
692
837
|
|
|
@@ -723,6 +868,10 @@ If your target manager does not fall back to `@namespace` when a homepage key is
|
|
|
723
868
|
|
|
724
869
|
If you intentionally provide localized names without descriptions (or vice versa).
|
|
725
870
|
|
|
871
|
+
#### Introduced in
|
|
872
|
+
|
|
873
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.0.0">v1.0.0</a> (September 9, 2026)
|
|
874
|
+
|
|
726
875
|
#### See also
|
|
727
876
|
|
|
728
877
|
- [`no-duplicate-keys`](#no-duplicate-keys)
|
|
@@ -736,27 +885,32 @@ If you intentionally provide localized names without descriptions (or vice versa
|
|
|
736
885
|
|
|
737
886
|
---
|
|
738
887
|
|
|
888
|
+
</details>
|
|
889
|
+
|
|
739
890
|
<h3 id="require-required-fields">
|
|
740
891
|
<code>require-required-fields</code>
|
|
741
892
|
<a title="Included in recommended config" href="#usage">
|
|
742
893
|
<img height=18 alt="[Recommended]" src="https://img.shields.io/badge/Recommended-f1f20a?style=flat-square" align="middle"></a>
|
|
743
|
-
<a title="Accepts array w/ options"
|
|
894
|
+
<a title="Accepts array w/ options" href="#usage">
|
|
744
895
|
<img height=18 alt="[Configurable]" src="https://img.shields.io/badge/Configurable-black?style=flat-square" align="middle"></a>
|
|
745
896
|
<a title="Copy rule URL" target="_blank"
|
|
746
897
|
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23require-required-fields">
|
|
747
898
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
748
899
|
</h3>
|
|
749
900
|
|
|
750
|
-
>
|
|
901
|
+
<details>
|
|
902
|
+
|
|
903
|
+
<summary>Requires essential metadata fields (<code>@name</code>, <code>@version</code> and at least one <code>@match</code> or <code>@include</code>by default).</summary>
|
|
751
904
|
|
|
752
905
|
#### Options
|
|
753
906
|
|
|
754
907
|
- `fields` (default `['name', 'version']`) – override the required field list
|
|
908
|
+
- `requireMatchOrInclude` (default `true`) – require `@match` or `@include`
|
|
755
909
|
|
|
756
910
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
757
911
|
|
|
758
912
|
```diff
|
|
759
|
-
/* eslint greasemonkey/require-required-fields: ['error', { fields: ['name', 'version', '
|
|
913
|
+
/* eslint greasemonkey/require-required-fields: ['error', { fields: ['name', 'version', 'license'] }] */
|
|
760
914
|
|
|
761
915
|
// ==UserScript==
|
|
762
916
|
// @name My Script
|
|
@@ -766,11 +920,12 @@ If you intentionally provide localized names without descriptions (or vice versa
|
|
|
766
920
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> Correct code
|
|
767
921
|
|
|
768
922
|
```diff
|
|
769
|
-
/* eslint greasemonkey/require-required-fields: ['error', { fields: ['name', 'version', '
|
|
923
|
+
/* eslint greasemonkey/require-required-fields: ['error', { fields: ['name', 'version', 'license'] }] */
|
|
770
924
|
|
|
771
925
|
// ==UserScript==
|
|
772
926
|
// @name My Script
|
|
773
927
|
+ // @version 1.0.0
|
|
928
|
+
+ // @license MIT
|
|
774
929
|
+ // @match https://example.com/*
|
|
775
930
|
// ==/UserScript==
|
|
776
931
|
```
|
|
@@ -779,6 +934,10 @@ If you intentionally provide localized names without descriptions (or vice versa
|
|
|
779
934
|
|
|
780
935
|
If you use a subset of metadata fields that doesn't match the convention.
|
|
781
936
|
|
|
937
|
+
#### Introduced in
|
|
938
|
+
|
|
939
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.0.0">v1.0.0</a> (September 9, 2026) as `require-required-fields`
|
|
940
|
+
|
|
782
941
|
#### See also
|
|
783
942
|
|
|
784
943
|
- [`no-duplicate-keys`](#no-duplicate-keys)
|
|
@@ -792,20 +951,24 @@ If you use a subset of metadata fields that doesn't match the convention.
|
|
|
792
951
|
|
|
793
952
|
---
|
|
794
953
|
|
|
954
|
+
</details>
|
|
955
|
+
|
|
795
956
|
<h3 id="require-space-before-meta-key">
|
|
796
957
|
<code>require-space-before-meta-key</code>
|
|
797
958
|
<a title="Included in recommended config" href="#usage">
|
|
798
959
|
<img height=18 alt="[Recommended]" src="https://img.shields.io/badge/Recommended-f1f20a?style=flat-square" align="middle"></a>
|
|
799
960
|
<a title="Accepts eslint --fix" target="_blank" href="https://eslint.org/docs/latest/use/command-line-interface#--fix">
|
|
800
961
|
<img height=18 alt="[Auto-fixable]" src="https://img.shields.io/badge/Auto--fixable-e8357a?style=flat-square" align="middle"></a>
|
|
801
|
-
<a title="Doesn't
|
|
962
|
+
<a title="Doesn't prevent bugs" href="#require-space-before-meta-key">
|
|
802
963
|
<img height=18 alt="[Stylistic]" src="https://img.shields.io/badge/Stylistic-af68ff?style=flat-square" align="middle"></a>
|
|
803
964
|
<a title="Copy rule URL" target="_blank"
|
|
804
965
|
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23require-space-before-meta-key">
|
|
805
966
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
806
967
|
</h3>
|
|
807
968
|
|
|
808
|
-
>
|
|
969
|
+
<details>
|
|
970
|
+
|
|
971
|
+
<summary>Requires exactly one space between <code>//</code> and metadata keys.</summary>
|
|
809
972
|
|
|
810
973
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
811
974
|
|
|
@@ -830,6 +993,10 @@ If you use a subset of metadata fields that doesn't match the convention.
|
|
|
830
993
|
|
|
831
994
|
If you intentionally use a different prefix style.
|
|
832
995
|
|
|
996
|
+
#### Introduced in
|
|
997
|
+
|
|
998
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.3.0">v1.3.0</a> (September 12, 2026)
|
|
999
|
+
|
|
833
1000
|
#### See also
|
|
834
1001
|
|
|
835
1002
|
- [`meta-spacing`](#meta-spacing)
|
|
@@ -843,20 +1010,22 @@ If you intentionally use a different prefix style.
|
|
|
843
1010
|
|
|
844
1011
|
---
|
|
845
1012
|
|
|
1013
|
+
</details>
|
|
1014
|
+
|
|
846
1015
|
<h3 id="require-sri-hashing">
|
|
847
1016
|
<code>require-sri-hashing</code>
|
|
848
1017
|
<a title="Only included in strict config" href="#usage">
|
|
849
1018
|
<img height=18 alt="[Strict only]" src="https://img.shields.io/badge/Strict_only-ff8c42?style=flat-square" align="middle"></a>
|
|
850
|
-
<a title="
|
|
851
|
-
<img height=18 alt="[Stylistic]" src="https://img.shields.io/badge/Stylistic-af68ff?style=flat-square" align="middle"></a>
|
|
852
|
-
<a title="Accepts object w/ options" target="_blank" href="https://eslint.org/docs/latest/extend/custom-rules#option-defaults">
|
|
1019
|
+
<a title="Accepts array w/ options" href="#usage">
|
|
853
1020
|
<img height=18 alt="[Configurable]" src="https://img.shields.io/badge/Configurable-black?style=flat-square" align="middle"></a>
|
|
854
1021
|
<a title="Copy rule URL" target="_blank"
|
|
855
1022
|
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23require-sri-hashing">
|
|
856
1023
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
857
1024
|
</h3>
|
|
858
1025
|
|
|
859
|
-
>
|
|
1026
|
+
<details>
|
|
1027
|
+
|
|
1028
|
+
<summary>Requires SRI hashes on <code>@require</code> and <code>@resource</code> URLs.</summary>
|
|
860
1029
|
|
|
861
1030
|
#### Options
|
|
862
1031
|
|
|
@@ -868,8 +1037,9 @@ If you intentionally use a different prefix style.
|
|
|
868
1037
|
/* eslint greasemonkey/require-sri-hashing: ['error', { algorithm: 'sha384' }] */
|
|
869
1038
|
|
|
870
1039
|
// ==UserScript==
|
|
871
|
-
! // @require https://example.com/library.js
|
|
872
|
-
|
|
1040
|
+
! // @require https://example.com/library.js
|
|
1041
|
+
// @resource css https://example.com/styles.css#sha384-h/TTEs...
|
|
1042
|
+
! // @resource logo https://example.com/logo.png#sha256-xUj+3O...
|
|
873
1043
|
// ==/UserScript==
|
|
874
1044
|
```
|
|
875
1045
|
|
|
@@ -879,16 +1049,21 @@ If you intentionally use a different prefix style.
|
|
|
879
1049
|
/* eslint greasemonkey/require-sri-hashing: ['error', { algorithm: 'sha384' }] */
|
|
880
1050
|
|
|
881
1051
|
// ==UserScript==
|
|
882
|
-
- // @require https://example.com/library.js
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
1052
|
+
- // @require https://example.com/library.js
|
|
1053
|
+
+ // @require https://example.com/library.js#sha384-fTbBOw...
|
|
1054
|
+
// @resource css https://example.com/styles.css#sha384-h/TTEs...
|
|
1055
|
+
- // @resource logo https://example.com/logo.png#sha256-xUj+3O...
|
|
1056
|
+
+ // @resource logo https://example.com/logo.png#sha384-mQ3Slt...
|
|
886
1057
|
// ==/UserScript==
|
|
887
1058
|
```
|
|
888
1059
|
|
|
889
1060
|
#### When not to use it
|
|
890
1061
|
|
|
891
|
-
If you prefer shorter URLs, or don't support users who enforce subresource integrity
|
|
1062
|
+
If you prefer shorter URLs, or don't support users who strictly enforce subresource integrity via manager settings.
|
|
1063
|
+
|
|
1064
|
+
#### Introduced in
|
|
1065
|
+
|
|
1066
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.5.0">v1.5.0</a> (September 15, 2026)
|
|
892
1067
|
|
|
893
1068
|
#### See also
|
|
894
1069
|
|
|
@@ -902,7 +1077,9 @@ If you prefer shorter URLs, or don't support users who enforce subresource integ
|
|
|
902
1077
|
|
|
903
1078
|
</div>
|
|
904
1079
|
|
|
905
|
-
|
|
1080
|
+
---
|
|
1081
|
+
|
|
1082
|
+
</details>
|
|
906
1083
|
|
|
907
1084
|
<h3 id="require-update-download-pair">
|
|
908
1085
|
<code>require-update-download-pair</code>
|
|
@@ -913,7 +1090,9 @@ If you prefer shorter URLs, or don't support users who enforce subresource integ
|
|
|
913
1090
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
914
1091
|
</h3>
|
|
915
1092
|
|
|
916
|
-
>
|
|
1093
|
+
<details>
|
|
1094
|
+
|
|
1095
|
+
<summary>Requires <code>@updateURL</code> and <code>@downloadURL</code> to be used together.</summary>
|
|
917
1096
|
|
|
918
1097
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
919
1098
|
|
|
@@ -936,6 +1115,10 @@ If you prefer shorter URLs, or don't support users who enforce subresource integ
|
|
|
936
1115
|
|
|
937
1116
|
If you don't target Tampermonkey (where `@updateURL` avoids re-downloading the full script on every update check).
|
|
938
1117
|
|
|
1118
|
+
#### Introduced in
|
|
1119
|
+
|
|
1120
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.3.0">v1.3.0</a> (September 12, 2026)
|
|
1121
|
+
|
|
939
1122
|
#### See also
|
|
940
1123
|
|
|
941
1124
|
- <a target="_blank" href="https://www.tampermonkey.net/documentation.php?q=update_url#meta:updateURL"><code>@updateURL</code></a>
|
|
@@ -949,6 +1132,8 @@ If you don't target Tampermonkey (where `@updateURL` avoids re-downloading the f
|
|
|
949
1132
|
|
|
950
1133
|
---
|
|
951
1134
|
|
|
1135
|
+
</details>
|
|
1136
|
+
|
|
952
1137
|
<h3 id="require-user-js-filename">
|
|
953
1138
|
<code>require-user-js-filename</code>
|
|
954
1139
|
<a title="Included in recommended config" href="#usage">
|
|
@@ -958,7 +1143,9 @@ If you don't target Tampermonkey (where `@updateURL` avoids re-downloading the f
|
|
|
958
1143
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
959
1144
|
</h3>
|
|
960
1145
|
|
|
961
|
-
>
|
|
1146
|
+
<details>
|
|
1147
|
+
|
|
1148
|
+
<summary>Requires files containing <code>// ==UserScript==</code> have names ending in <code>.user.js</code></summary>
|
|
962
1149
|
|
|
963
1150
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect filename
|
|
964
1151
|
|
|
@@ -977,6 +1164,10 @@ If you don't target Tampermonkey (where `@updateURL` avoids re-downloading the f
|
|
|
977
1164
|
|
|
978
1165
|
If you intentionally name your userscripts something other than `*.user.js`.
|
|
979
1166
|
|
|
1167
|
+
#### Introduced in
|
|
1168
|
+
|
|
1169
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.2.0">v1.2.0</a> (September 11, 2026)
|
|
1170
|
+
|
|
980
1171
|
<div align="center">
|
|
981
1172
|
|
|
982
1173
|
[Back to index ↑][epg-rules]
|
|
@@ -985,22 +1176,28 @@ If you intentionally name your userscripts something other than `*.user.js`.
|
|
|
985
1176
|
|
|
986
1177
|
---
|
|
987
1178
|
|
|
1179
|
+
</details>
|
|
1180
|
+
|
|
988
1181
|
<h3 id="valid-field-values">
|
|
989
1182
|
<code>valid-field-values</code>
|
|
990
1183
|
<a title="Included in recommended config" href="#usage">
|
|
991
1184
|
<img height=18 alt="[Recommended]" src="https://img.shields.io/badge/Recommended-f1f20a?style=flat-square" align="middle"></a>
|
|
992
|
-
<a title="Accepts array w/ options"
|
|
1185
|
+
<a title="Accepts array w/ options" href="#usage">
|
|
993
1186
|
<img height=18 alt="[Configurable]" src="https://img.shields.io/badge/Configurable-black?style=flat-square" align="middle"></a>
|
|
994
|
-
<a title="Copy rule URL" target="_blank"
|
|
1187
|
+
<a title="Copy rule URL" target="_blank"
|
|
995
1188
|
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23valid-field-values">
|
|
996
1189
|
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
997
1190
|
</h3>
|
|
998
1191
|
|
|
999
|
-
>
|
|
1192
|
+
<details>
|
|
1193
|
+
|
|
1194
|
+
<summary>Validates <code>@version</code> (semver or date format) and URL fields.</summary>
|
|
1000
1195
|
|
|
1001
1196
|
#### Options
|
|
1002
1197
|
|
|
1003
1198
|
- `versionType` (default `'semver'`) – version format to enforce (`'semver'`, `'date'`)
|
|
1199
|
+
- `allowFutureDate` (default `false`) – allow `@version` dates later than the current date
|
|
1200
|
+
- `timezone` (default `''`) – <a target="_blank" href="https://data.iana.org/time-zones/tzdb/zone1970.tab">IANA timezone</a> used to determine the current date (when omitted, only year/month are enforced)
|
|
1004
1201
|
|
|
1005
1202
|
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
1006
1203
|
|
|
@@ -1030,69 +1227,14 @@ If you intentionally name your userscripts something other than `*.user.js`.
|
|
|
1030
1227
|
|
|
1031
1228
|
If you use a custom versioning scheme or URLs that aren't standard.
|
|
1032
1229
|
|
|
1033
|
-
####
|
|
1230
|
+
#### Introduced in
|
|
1034
1231
|
|
|
1035
|
-
|
|
1036
|
-
- [`valid-grants`](#valid-grants)
|
|
1037
|
-
|
|
1038
|
-
<div align="center">
|
|
1039
|
-
|
|
1040
|
-
[Back to index ↑][epg-rules]
|
|
1041
|
-
|
|
1042
|
-
</div>
|
|
1043
|
-
|
|
1044
|
-
---
|
|
1045
|
-
|
|
1046
|
-
<h3 id="valid-grants">
|
|
1047
|
-
<code>valid-grants</code>
|
|
1048
|
-
<a title="Included in recommended config" href="#usage">
|
|
1049
|
-
<img height=18 alt="[Recommended]" src="https://img.shields.io/badge/Recommended-f1f20a?style=flat-square" align="middle"></a>
|
|
1050
|
-
<a title="Accepts array w/ options" target="_blank" href="https://eslint.org/docs/latest/extend/custom-rules#option-defaults">
|
|
1051
|
-
<img height=18 alt="[Configurable]" src="https://img.shields.io/badge/Configurable-black?style=flat-square" align="middle"></a>
|
|
1052
|
-
<a title="Copy rule URL" target="_blank"
|
|
1053
|
-
href="https://copy-to-clipboard.onrender.com/copy/https%3A%2F%2Fcodeberg.org%2Fadamlui%2Feslint-plugin-greasemonkey%2F%23valid-grants">
|
|
1054
|
-
<img height=16 width=21 alt="[Copy rule URL]" src="https://api.iconify.design/mdi/content-copy.svg?color=%23cccccc" align="middle"></a>
|
|
1055
|
-
</h3>
|
|
1056
|
-
|
|
1057
|
-
> Disallows invalid or unsupported `@grant` values.
|
|
1058
|
-
|
|
1059
|
-
#### Options
|
|
1060
|
-
|
|
1061
|
-
- `target` (default `'all'`) – manager(s) whose grants to validate against (`'all'`, `'tampermonkey'`, `'violentmonkey'`, `'greasemonkey'`, `'scriptcat'`), as a single string or array
|
|
1062
|
-
- `allowedGrants` (default `[]`) – additional `@grant` values to allow beyond the built-in list (covering Tampermonkey, Violentmonkey and ScriptCat), as a single string or array
|
|
1063
|
-
|
|
1064
|
-
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/gray.svg" align="bottom"> Incorrect code
|
|
1065
|
-
|
|
1066
|
-
```diff
|
|
1067
|
-
/* eslint greasemonkey/valid-grants: ['error', { target: 'tampermonkey' }] */
|
|
1068
|
-
|
|
1069
|
-
// ==UserScript==
|
|
1070
|
-
! // @grant GM_notificaiton
|
|
1071
|
-
! // @grant CAT.agent.dom
|
|
1072
|
-
// ==/UserScript==
|
|
1073
|
-
```
|
|
1074
|
-
|
|
1075
|
-
#### <img width=13 height=13 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/99f14247b2/assets/images/icons/square/with-symbol/green.svg" align="bottom"> Correct code
|
|
1076
|
-
|
|
1077
|
-
```diff
|
|
1078
|
-
/* eslint greasemonkey/valid-grants: ['error', { target: 'tampermonkey' }] */
|
|
1079
|
-
|
|
1080
|
-
// ==UserScript==
|
|
1081
|
-
- // @grant GM_notificaiton
|
|
1082
|
-
+ // @grant GM_notification
|
|
1083
|
-
- // @grant CAT.agent.dom
|
|
1084
|
-
+ // @grant GM_getTab
|
|
1085
|
-
// ==/UserScript==
|
|
1086
|
-
```
|
|
1087
|
-
|
|
1088
|
-
#### When not to use it
|
|
1089
|
-
|
|
1090
|
-
If you don't want `@grant` validation at all. For individual uncovered grants, prefer whitelisting via `allowedGrants` over disabling the rule.
|
|
1232
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases/tag/v1.0.0">v1.0.0</a> (September 9, 2026)
|
|
1091
1233
|
|
|
1092
1234
|
#### See also
|
|
1093
1235
|
|
|
1094
|
-
- [`no-
|
|
1095
|
-
- [`no-
|
|
1236
|
+
- [`no-invalid-grants`](#no-invalid-grants)
|
|
1237
|
+
- [`no-missing-resources`](#no-missing-resources)
|
|
1096
1238
|
|
|
1097
1239
|
<div align="center">
|
|
1098
1240
|
|
|
@@ -1100,6 +1242,8 @@ If you don't want `@grant` validation at all. For individual uncovered grants, p
|
|
|
1100
1242
|
|
|
1101
1243
|
</div>
|
|
1102
1244
|
|
|
1245
|
+
</details>
|
|
1246
|
+
|
|
1103
1247
|
---
|
|
1104
1248
|
|
|
1105
1249
|
## Shield embed
|
|
@@ -1126,6 +1270,7 @@ If you don't want `@grant` validation at all. For individual uncovered grants, p
|
|
|
1126
1270
|
|
|
1127
1271
|
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-constructors/src/branch/main/docs/LICENSE.md">
|
|
1128
1272
|
<img height=62 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/9e820e5d51/assets/images/logos/mit-license/red-pixelated.png"></a>
|
|
1273
|
+
<br><br>
|
|
1129
1274
|
|
|
1130
1275
|
<details>
|
|
1131
1276
|
|
|
@@ -1164,7 +1309,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
1164
1309
|
<div align="center">
|
|
1165
1310
|
|
|
1166
1311
|
<picture><source media="(prefers-color-scheme: dark)" srcset="https://cdn.staticdelivr.com/gl/adamlui/js-utils/6b0d399/assets/images/icons/tag/white/icon16.svg"><img height=14 src="https://cdn.staticdelivr.com/gl/adamlui/js-utils/6b0d399/assets/images/icons/tag/dark-gray/icon16.svg"></picture>
|
|
1167
|
-
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases"><b>Latest releases</b></a> / <a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/issues/new">Report a bug</a> / <a target="_blank" href="https://
|
|
1312
|
+
<a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/releases"><b>Latest releases</b></a> / <a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/issues/new">Report a bug</a> / <a target="_blank" href="https://www.npmjs.com/~adamlui">More packages by author</a> / [Back to top ↑](#top)
|
|
1168
1313
|
|
|
1169
1314
|
</div>
|
|
1170
1315
|
|