diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4439db1..368aa83 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,3 +24,16 @@ repos: rev: v0.3.1 hooks: - id: prevent-literal-http-methods + + - repo: local + hooks: + - id: eslint + name: eslint + entry: .pre-commit-eslint.sh + language: system + types_or: [ts, tsx] + - id: typescript + name: typescript + entry: .pre-commit-tsc.sh + language: system + types_or: [ts, tsx] diff --git a/.pre-commit-eslint.sh b/.pre-commit-eslint.sh new file mode 100755 index 0000000..9ebb3e8 --- /dev/null +++ b/.pre-commit-eslint.sh @@ -0,0 +1,6 @@ +#!/bin/bash +cd web > /dev/null +if [[ -f "./node_modules/.bin/eslint" ]]; then + ARGS=("$@") + eslint ${ARGS[@]/#web\// } +fi diff --git a/.pre-commit-tsc.sh b/.pre-commit-tsc.sh new file mode 100755 index 0000000..b39434a --- /dev/null +++ b/.pre-commit-tsc.sh @@ -0,0 +1,5 @@ +#!/bin/bash +cd web > /dev/null +if [[ -f "./node_modules/.bin/tsc" ]]; then + tsc --build --noEmit +fi diff --git a/web/eslint.config.js b/web/eslint.config.js index 7f79be9..8b8e9e9 100644 --- a/web/eslint.config.js +++ b/web/eslint.config.js @@ -13,6 +13,9 @@ export default tseslint.config( languageOptions: { ecmaVersion: 2023, globals: globals.browser, + parserOptions: { + warnOnUnsupportedTypeScriptVersion: false, + } }, plugins: { "react-hooks": reactHooks, diff --git a/web/src/util/html.ts b/web/src/util/html.ts index 660d794..7f24b4e 100644 --- a/web/src/util/html.ts +++ b/web/src/util/html.ts @@ -189,7 +189,7 @@ export const sanitizeHtmlParams: sanitizeHtml.IOptions = { // custom ones first: font: ["color", "data-mx-bg-color", "data-mx-color", "style"], // custom to matrix span: [ - "data-mx-maths", "data-mx-bg-color", "data-mx-color", "data-mx-spoiler", "style", "title" + "data-mx-maths", "data-mx-bg-color", "data-mx-color", "data-mx-spoiler", "style", "title", ], // custom to matrix div: ["data-mx-maths"], // eslint-disable-next-line id-length