From a1fc6d9c541360cdb4ba902e1583f4f247f4d34b Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 27 Sep 2023 16:11:08 +0200 Subject: [PATCH] Refactor `package.json` some more --- lib/index.js | 20 +++++++------------- package.json | 24 ++---------------------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/lib/index.js b/lib/index.js index b8edf44f..3bbe47bd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -260,13 +260,11 @@ export function Markdown(options) { } if (node.type === 'element') { - let remove = false - - if (allowedElements) { - remove = !allowedElements.includes(node.tagName) - } else if (disallowedElements) { - remove = disallowedElements.includes(node.tagName) - } + let remove = allowedElements + ? !allowedElements.includes(node.tagName) + : disallowedElements + ? disallowedElements.includes(node.tagName) + : false if (!remove && allowElement && typeof index === 'number') { remove = !allowElement(node, index, parent) @@ -307,11 +305,7 @@ export function defaultUrlTransform(value) { return url } - let index = -1 - - while (++index < safeProtocols.length) { - const protocol = safeProtocols[index] - + for (const protocol of safeProtocols) { if ( colon === protocol.length && url.slice(0, protocol.length).toLowerCase() === protocol @@ -320,7 +314,7 @@ export function defaultUrlTransform(value) { } } - index = url.indexOf('?') + let index = url.indexOf('?') if (index !== -1 && colon > index) { return url } diff --git a/package.json b/package.json index 804d2e94..0953edcf 100644 --- a/package.json +++ b/package.json @@ -98,10 +98,7 @@ "@types/react-dom": "^18.0.0", "c8": "^8.0.0", "esbuild": "^0.19.0", - "eslint-plugin-es": "^4.0.0", "eslint-plugin-react": "^7.0.0", - "eslint-plugin-react-hooks": "^4.0.0", - "eslint-plugin-security": "^1.0.0", "prettier": "^3.0.0", "react": "^18.0.0", "react-dom": "^18.0.0", @@ -153,10 +150,6 @@ "atLeast": 100, "detail": true, "ignoreCatch": true, - "#": "below is ignored because some proptypes will `any`; to do: remove prop-types?", - "ignoreFiles": [ - "lib/index.d.ts" - ], "strict": true }, "xo": { @@ -165,19 +158,6 @@ ], "extends": "plugin:react/jsx-runtime", "overrides": [ - { - "files": [ - "lib/**/*.js" - ], - "extends": [ - "plugin:es/restrict-to-es2019", - "plugin:security/recommended" - ], - "rules": { - "complexity": "off", - "security/detect-object-injection": "off" - } - }, { "files": [ "**/*.jsx" @@ -189,8 +169,8 @@ ], "prettier": true, "rules": { - "n/file-extension-in-import": "off", - "unicorn/prefer-string-replace-all": "off" + "complexity": "off", + "n/file-extension-in-import": "off" } } }