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:
Piotr Błażejewicz (Peter Blazejewicz) 2020-08-28 05:23:54 +02:00 committed by GitHub
parent 9976729950
commit b1bb0a4868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 21 deletions

View File

@ -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 {

View File

@ -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);

View File

@ -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;

View File

@ -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
}
}