Skip to content

Commit 2f4f682

Browse files
committed
Sacrifice to the linter gods.
1 parent a7e3454 commit 2f4f682

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export function setCSPTrustedTypesPolicy(policy: CSPTrustedTypesPolicy | Promise
2222
}
2323

2424
// TODO: find another way to make this available for testing.
25+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2526
;(globalThis as any).setCSPTrustedTypesPolicy = setCSPTrustedTypesPolicy
2627

2728
export default class IncludeFragmentElement extends HTMLElement {

test/test.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,13 @@ suite('include-fragment-element', function () {
619619

620620
suite('CSP trusted types', () => {
621621
teardown(() => {
622+
// eslint-disable-next-line no-undef
622623
setCSPTrustedTypesPolicy(null)
623624
})
624625

625626
test('can set a pass-through mock CSP trusted types policy', async function () {
626627
let policyCalled = false
628+
// eslint-disable-next-line no-undef
627629
setCSPTrustedTypesPolicy({
628630
createHTML: htmlText => {
629631
policyCalled = true
@@ -641,8 +643,9 @@ suite('include-fragment-element', function () {
641643

642644
test('can set and clear a mutating mock CSP trusted types policy', async function () {
643645
let policyCalled = false
646+
// eslint-disable-next-line no-undef
644647
setCSPTrustedTypesPolicy({
645-
createHTML: htmlText => {
648+
createHTML: () => {
646649
policyCalled = true
647650
return '<b>replacement</b>'
648651
}
@@ -654,6 +657,7 @@ suite('include-fragment-element', function () {
654657
assert.equal('<b>replacement</b>', data)
655658
assert.ok(policyCalled)
656659

660+
// eslint-disable-next-line no-undef
657661
setCSPTrustedTypesPolicy(null)
658662
const el2 = document.createElement('include-fragment')
659663
el2.src = '/hello'
@@ -663,12 +667,14 @@ suite('include-fragment-element', function () {
663667

664668
test('can set a real CSP trusted types policy in Chromium', async function () {
665669
let policyCalled = false
670+
// eslint-disable-next-line no-undef
666671
const policy = globalThis.trustedTypes.createPolicy('test1', {
667672
createHTML: htmlText => {
668673
policyCalled = true
669674
return htmlText
670675
}
671676
})
677+
// eslint-disable-next-line no-undef
672678
setCSPTrustedTypesPolicy(policy)
673679

674680
const el = document.createElement('include-fragment')
@@ -679,8 +685,9 @@ suite('include-fragment-element', function () {
679685
})
680686

681687
test('can reject data using a mock CSP trusted types policy', async function () {
688+
// eslint-disable-next-line no-undef
682689
setCSPTrustedTypesPolicy({
683-
createHTML: htmlText => {
690+
createHTML: () => {
684691
throw new Error('Rejected data!')
685692
}
686693
})
@@ -696,13 +703,14 @@ suite('include-fragment-element', function () {
696703
})
697704

698705
test('can access headers using a mock CSP trusted types policy', async function () {
706+
// eslint-disable-next-line no-undef
699707
setCSPTrustedTypesPolicy({
700708
createHTML: (htmlText, response) => {
701-
if (response.headers.get("X-Server-Sanitized") !== "sanitized=true") {
709+
if (response.headers.get('X-Server-Sanitized') !== 'sanitized=true') {
702710
// Note: this will reject the contents, but the error may be caught before it shows in the JS console.
703-
throw new Error("Rejecting HTML that was not marked by the server as sanitized.");
711+
throw new Error('Rejecting HTML that was not marked by the server as sanitized.')
704712
}
705-
return htmlText;
713+
return htmlText
706714
}
707715
})
708716

0 commit comments

Comments
 (0)