From ff071c8f52db9a4384bbe00a7005531566674887 Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 2 Dec 2024 16:19:10 +0100 Subject: [PATCH 1/3] fix(esling): eslint config should extend `@nextcloud` Required to import all Nextcloud eslint rules, not only the typescript ones. Signed-off-by: Jonas --- .eslintrc.cjs | 2 +- tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index bc019d9820d..0bab9029919 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -6,7 +6,7 @@ module.exports = { root: true, extends: [ - '@nextcloud/eslint-config/typescript', + '@nextcloud', ], rules: { '@typescript-eslint/no-unused-vars': ['off'], diff --git a/tsconfig.json b/tsconfig.json index 9d64b435b9d..43a99b75aea 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "extends": "@vue/tsconfig", "compilerOptions": { "allowSyntheticDefaultImports": true, - "allowJs": true, + "allowJs": true, "declaration": true, "esModuleInterop": true, "lib": ["DOM", "ESNext"], From 7d953a409e2182d23f714dd5a8b036b5b941510c Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 2 Dec 2024 16:26:53 +0100 Subject: [PATCH 2/3] fix(eslint): Also lint typescript files Signed-off-by: Jonas --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6a217fd8ede..171ccf56e38 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,8 @@ "build": "NODE_ENV=production NODE_OPTIONS='--max-old-space-size=4096' vite --mode production build", "dev": "NODE_ENV=development NODE_OPTIONS='--max-old-space-size=4096' vite --mode development build", "watch": "NODE_ENV=development NODE_OPTIONS='--max-old-space-size=8192' vite --mode development build --watch", - "lint": "tsc && eslint --ext .js,.vue src cypress", - "lint:fix": "tsc && eslint --ext .js,.vue src cypress --fix", + "lint": "tsc && eslint --ext .js,.ts,.vue src cypress", + "lint:fix": "tsc && eslint --ext .js,.ts,.vue src cypress --fix", "stylelint": "stylelint src/**/*.vue src/**/*.scss src/**/*.css css/*.scss", "stylelint:fix": "stylelint src/**/*.vue src/**/*.scss src/**/*.css css/*.scss --fix", "test": "NODE_ENV=test vitest", From b26e0d90d2410f1d32245dc8b40570360e9532fd Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 2 Dec 2024 16:31:38 +0100 Subject: [PATCH 3/3] fix: linting code style fixes to typescript files Signed-off-by: Jonas --- src/global.d.ts | 1 + src/markdownit/details.ts | 10 +- src/markdownit/taskLists.ts | 246 ++++++++++++++++++++++-------------- src/services/Outbox.ts | 3 +- src/vue-shim.d.ts | 2 +- 5 files changed, 161 insertions(+), 101 deletions(-) diff --git a/src/global.d.ts b/src/global.d.ts index 4ca5582d482..a0de9b3eb2f 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -10,6 +10,7 @@ declare global { // Nextcloud Globals t: typeof import('@nextcloud/l10n').t n: typeof import('@nextcloud/l10n').n + // eslint-disable-next-line @typescript-eslint/no-explicit-any OCA: Record OCP: Nextcloud.v29.OCP } diff --git a/src/markdownit/details.ts b/src/markdownit/details.ts index 15f316c1004..ac0493b1c53 100644 --- a/src/markdownit/details.ts +++ b/src/markdownit/details.ts @@ -13,10 +13,10 @@ const SUMMARY_REGEX = /(?<=^).*(?=<\/summary>\s*$)/ /** * - * @param state - * @param startLine - * @param endLine - * @param silent + * @param state - MarkdownIt state + * @param startLine - start line number + * @param endLine - end line number + * @param silent - validation mode */ function parseDetails(state: StateBlock, startLine: number, endLine: number, silent: boolean) { // let autoClosedBlock = false @@ -120,7 +120,7 @@ function parseDetails(state: StateBlock, startLine: number, endLine: number, sil } /** - * @param {object} md Markdown object + * @param {object} md - Markdown object */ export default function details(md: MarkdownIt) { md.block.ruler.before('fence', 'details', parseDetails, { diff --git a/src/markdownit/taskLists.ts b/src/markdownit/taskLists.ts index 6cb9e8d58ff..ee173efea52 100644 --- a/src/markdownit/taskLists.ts +++ b/src/markdownit/taskLists.ts @@ -21,139 +21,197 @@ interface TaskListsOptions { const checkboxRegex = /^ *\[([\sx])] /i +/** + * + * @param md - + * @param options - taskLists plugin options + */ export default function taskLists( - md: MarkdownIt, - options: TaskListsOptions = { enabled: false, label: false, lineNumber: false } + md: MarkdownIt, + options: TaskListsOptions = { enabled: false, label: false, lineNumber: false }, ): void { - md.core.ruler.after('inline', 'task-lists', (state) => processToken(state, options)) - md.renderer.rules.taskListItemCheckbox = (tokens) => { - const token = tokens[0] - const checkedAttribute = token.attrGet('checked') ? 'checked="" ' : '' - const disabledAttribute = token.attrGet('disabled') ? 'disabled="" ' : '' - const line = token.attrGet('line') - const idAttribute = `id="${token.attrGet('id')}" ` - const dataLineAttribute = line && options.lineNumber ? `data-line="${line}" ` : '' - - return `` - } - - md.renderer.rules.taskListItemLabel_close = () => { - return '' - } - - md.renderer.rules.taskListItemLabel_open = (tokens: Token[]) => { - const token = tokens[0] - const id = token.attrGet('id') - return `' + } + + md.renderer.rules.taskListItemLabel_open = (tokens: Token[]) => { + const token = tokens[0] + const id = token.attrGet('id') + return `