mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
update(dompurify): minor cleanups (#47092)
- removes custom TSLint exclude rules with exception of `sanitize` overloads rule exclusion - correct all other TSLint issues - correct author GitHub handle Thanks!
This commit is contained in:
parent
9976729950
commit
b1bb0a4868
3
types/dompurify/index.d.ts
vendored
3
types/dompurify/index.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
// Type definitions for DOM Purify 2.0
|
||||
// Project: https://github.com/cure53/DOMPurify
|
||||
// Definitions by: Dave Taylor <http://davetayls.me>
|
||||
// Definitions by: Dave Taylor https://github.com/davetayls
|
||||
// Samira Bazuzi <https://github.com/bazuzi>
|
||||
// FlowCrypt <https://github.com/FlowCrypt>
|
||||
// Exigerr <https://github.com/Exigerr>
|
||||
@ -16,7 +16,6 @@ declare const DOMPurify: createDOMPurifyI;
|
||||
|
||||
interface createDOMPurifyI extends DOMPurify.DOMPurifyI {
|
||||
(window?: Window): DOMPurify.DOMPurifyI;
|
||||
|
||||
}
|
||||
|
||||
declare namespace DOMPurify {
|
||||
|
||||
@ -6,4 +6,4 @@
|
||||
// https://github.com/microsoft/TypeScript/issues/19139
|
||||
|
||||
let dirty = '<script>alert("hi")</script><p>Totally safe<p><p onerror="blowUp()">Totally not safe</p>';
|
||||
DOMPurify.sanitize(dirty)
|
||||
DOMPurify.sanitize(dirty);
|
||||
|
||||
@ -3,8 +3,8 @@ import dompurify = require('dompurify');
|
||||
dompurify.sanitize('<script>alert("hi")</script>');
|
||||
dompurify.addHook('beforeSanitizeElements', (el, data, config) => undefined);
|
||||
|
||||
//examples from the DOMPurify README
|
||||
let dirty = '<script>alert("hi")</script><p>Totally safe<p><p onerror="blowUp()">Totally not safe</p>';
|
||||
// examples from the DOMPurify README
|
||||
const dirty = '<script>alert("hi")</script><p>Totally safe<p><p onerror="blowUp()">Totally not safe</p>';
|
||||
let str: string;
|
||||
let elem: HTMLElement;
|
||||
let frag: DocumentFragment;
|
||||
@ -72,30 +72,30 @@ const createDOMPurify = dompurify;
|
||||
const customDOMPurify = createDOMPurify();
|
||||
customDOMPurify.sanitize(dirty);
|
||||
|
||||
const customWindow = {} as Window;
|
||||
const customWindow: Window = window;
|
||||
const customDOMPurifyWithCustomWindow = createDOMPurify(customWindow);
|
||||
customDOMPurifyWithCustomWindow.sanitize(dirty);
|
||||
|
||||
//test the 'DOMPurifyI' type is publicly accessible.
|
||||
// test the 'DOMPurifyI' type is publicly accessible.
|
||||
function registerDomPurifyInstance(domPurify: DOMPurify.DOMPurifyI) {}
|
||||
|
||||
//test the 'config' type is publicly accessible.
|
||||
// test the 'config' type is publicly accessible.
|
||||
const config: DOMPurify.Config = {};
|
||||
|
||||
//test the 'HookName' type is publicly accessible.
|
||||
// test the 'HookName' type is publicly accessible.
|
||||
const hookName: DOMPurify.HookName = "beforeSanitizeElements";
|
||||
|
||||
//test the 'HookEvent' type is publicly accessible.
|
||||
// test the 'HookEvent' type is publicly accessible.
|
||||
dompurify.addHook(hookName, (currentNode: Element, event: DOMPurify.HookEvent) => {});
|
||||
|
||||
//test the 'SanitizeElementHookEvent' type is publicly accessible.
|
||||
// test the 'SanitizeElementHookEvent' type is publicly accessible.
|
||||
dompurify.addHook('uponSanitizeElement', (currentNode: Element, event: DOMPurify.SanitizeElementHookEvent) => {
|
||||
if (currentNode.nodeName && currentNode.nodeName.match(/^\w+-\w+$/) && !event.allowedTags[event.tagName]) {
|
||||
event.allowedTags[event.tagName] = true;
|
||||
}
|
||||
});
|
||||
|
||||
//test the 'SanitizeAttributeHookEvent' type is publicly accessible.
|
||||
// test the 'SanitizeAttributeHookEvent' type is publicly accessible.
|
||||
dompurify.addHook('uponSanitizeAttribute', (currentNode: Element, event: DOMPurify.SanitizeAttributeHookEvent) => {
|
||||
if (event.attrName && event.attrName.match(/^\w+-\w+$/) && !event.allowedAttributes[event.attrName]) {
|
||||
event.allowedAttributes[event.attrName] = true;
|
||||
|
||||
@ -1,15 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"prefer-const": false,
|
||||
"prefer-method-signature": false,
|
||||
"semicolon": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user