pre-commit: add tsc and eslint hooks

This commit is contained in:
Tulir Asokan 2024-10-12 16:30:05 +03:00
parent 2b6c00fa04
commit 88919a2667
5 changed files with 28 additions and 1 deletions

View file

@ -24,3 +24,16 @@ repos:
rev: v0.3.1 rev: v0.3.1
hooks: hooks:
- id: prevent-literal-http-methods - 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]

6
.pre-commit-eslint.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
cd web > /dev/null
if [[ -f "./node_modules/.bin/eslint" ]]; then
ARGS=("$@")
eslint ${ARGS[@]/#web\// }
fi

5
.pre-commit-tsc.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
cd web > /dev/null
if [[ -f "./node_modules/.bin/tsc" ]]; then
tsc --build --noEmit
fi

View file

@ -13,6 +13,9 @@ export default tseslint.config(
languageOptions: { languageOptions: {
ecmaVersion: 2023, ecmaVersion: 2023,
globals: globals.browser, globals: globals.browser,
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
}
}, },
plugins: { plugins: {
"react-hooks": reactHooks, "react-hooks": reactHooks,

View file

@ -189,7 +189,7 @@ export const sanitizeHtmlParams: sanitizeHtml.IOptions = {
// custom ones first: // custom ones first:
font: ["color", "data-mx-bg-color", "data-mx-color", "style"], // custom to matrix font: ["color", "data-mx-bg-color", "data-mx-color", "style"], // custom to matrix
span: [ 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 ], // custom to matrix
div: ["data-mx-maths"], div: ["data-mx-maths"],
// eslint-disable-next-line id-length // eslint-disable-next-line id-length