eslint-plugin-chrome-extensions 1.0.0 → 1.0.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/README.md +16 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -274,8 +274,8 @@ If you trust every external caller and open tab.
|
|
|
274
274
|
|
|
275
275
|
{
|
|
276
276
|
- "permissions": ["browserAction", "tabs"],
|
|
277
|
-
- "optional_permissions": ["history", "pageAction"]
|
|
278
277
|
+ "permissions": ["tabs"],
|
|
278
|
+
- "optional_permissions": ["history", "pageAction"]
|
|
279
279
|
+ "optional_permissions": ["history"]
|
|
280
280
|
}
|
|
281
281
|
```
|
|
@@ -321,7 +321,7 @@ If you don't want permission validation at all. For custom permissions from a Ch
|
|
|
321
321
|
```diff
|
|
322
322
|
// manifest.json
|
|
323
323
|
{
|
|
324
|
-
!
|
|
324
|
+
! "permissions": []
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
// background.js
|
|
@@ -334,8 +334,8 @@ If you don't want permission validation at all. For custom permissions from a Ch
|
|
|
334
334
|
```diff
|
|
335
335
|
// manifest.json
|
|
336
336
|
{
|
|
337
|
-
-
|
|
338
|
-
+
|
|
337
|
+
- "permissions": []
|
|
338
|
+
+ "permissions": ["cookies", "history"]
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
// background.js
|
|
@@ -392,11 +392,6 @@ If you use APIs through aliases or wrappers that obscure the original call site.
|
|
|
392
392
|
! const run = eval('1 + 1')
|
|
393
393
|
! setTimeout('doThing()', 1000)
|
|
394
394
|
! await import('https://cdn.example.com/lib.js')
|
|
395
|
-
! document.head.append(Object.assign(document.createElement('script'),
|
|
396
|
-
! { src: 'https://cdn.example.com/remote.js' }))
|
|
397
|
-
|
|
398
|
-
const secret = 'abc'
|
|
399
|
-
! chrome.scripting.executeScript({ func: () => alert(secret), target: { tabId } })
|
|
400
395
|
```
|
|
401
396
|
|
|
402
397
|
#### <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
|
|
@@ -408,14 +403,6 @@ If you use APIs through aliases or wrappers that obscure the original call site.
|
|
|
408
403
|
+ setTimeout(doThing, 1000)
|
|
409
404
|
- await import('https://cdn.example.com/lib.js')
|
|
410
405
|
+ await import('./lib.js')
|
|
411
|
-
- document.head.append(Object.assign(document.createElement('script'),
|
|
412
|
-
- { src: 'https://cdn.example.com/remote.js' }))
|
|
413
|
-
+ document.head.append(Object.assign(document.createElement('script'),
|
|
414
|
-
+ { src: chrome.runtime.getURL('inject.js') }))
|
|
415
|
-
|
|
416
|
-
const secret = 'abc'
|
|
417
|
-
- chrome.scripting.executeScript({ func: () => alert(secret), target: { tabId } })
|
|
418
|
-
+ chrome.scripting.executeScript({ func: (s) => alert(s), args: [secret], target: { tabId } })
|
|
419
406
|
```
|
|
420
407
|
|
|
421
408
|
#### When not to use it
|
|
@@ -459,7 +446,7 @@ Never (MV3 CSP blocks remote code at runtime).
|
|
|
459
446
|
```diff
|
|
460
447
|
// manifest.json
|
|
461
448
|
{
|
|
462
|
-
!
|
|
449
|
+
! "permissions": ["tabs", "downloads"]
|
|
463
450
|
}
|
|
464
451
|
|
|
465
452
|
// background.js
|
|
@@ -471,8 +458,8 @@ Never (MV3 CSP blocks remote code at runtime).
|
|
|
471
458
|
```diff
|
|
472
459
|
// manifest.json
|
|
473
460
|
{
|
|
474
|
-
-
|
|
475
|
-
+
|
|
461
|
+
- "permissions": ["tabs", "downloads"]
|
|
462
|
+
+ "permissions": ["tabs"]
|
|
476
463
|
}
|
|
477
464
|
|
|
478
465
|
// background.js
|
|
@@ -520,9 +507,9 @@ If you access the granted API through an alias or computed property rather than
|
|
|
520
507
|
```diff
|
|
521
508
|
// manifest.json
|
|
522
509
|
{
|
|
523
|
-
!
|
|
524
|
-
|
|
525
|
-
|
|
510
|
+
! "manifest_version": 2,
|
|
511
|
+
"name": "My Extension",
|
|
512
|
+
"version": "1.0.0"
|
|
526
513
|
}
|
|
527
514
|
```
|
|
528
515
|
|
|
@@ -531,10 +518,10 @@ If you access the granted API through an alias or computed property rather than
|
|
|
531
518
|
```diff
|
|
532
519
|
// manifest.json
|
|
533
520
|
{
|
|
534
|
-
-
|
|
535
|
-
+
|
|
536
|
-
|
|
537
|
-
|
|
521
|
+
- "manifest_version": 2,
|
|
522
|
+
+ "manifest_version": 3,
|
|
523
|
+
"name": "My Extension",
|
|
524
|
+
"version": "1.0.0"
|
|
538
525
|
}
|
|
539
526
|
```
|
|
540
527
|
|
|
@@ -592,10 +579,10 @@ If you intentionally target MV2 for a Chromium fork that still supports it.
|
|
|
592
579
|
"manifest_version": 3,
|
|
593
580
|
- "browser_action": {},
|
|
594
581
|
- "page_action": {},
|
|
595
|
-
- "background": { "scripts": ["bg.js"], "persistent": true },
|
|
596
|
-
- "content_security_policy": "script-src 'self' 'unsafe-eval'"
|
|
597
582
|
+ "action": {},
|
|
583
|
+
- "background": { "scripts": ["bg.js"], "persistent": true },
|
|
598
584
|
+ "background": { "service_worker": "sw.js" },
|
|
585
|
+
- "content_security_policy": "script-src 'self' 'unsafe-eval'"
|
|
599
586
|
+ "content_security_policy": { "extension_pages": "script-src 'self'; object-src 'self'" }
|
|
600
587
|
}
|
|
601
588
|
```
|