Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 128 additions & 54 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,64 +23,25 @@ export default [
],
},

{
{
name: 'libresign/config',
rules: {
// production only
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
// `eslint-plugin-import` (e quindi `import/order` e `import/no-unresolved`)
// non fa piΓΉ parte di @nextcloud/eslint-config a partire dalla v9.
// L'ordinamento degli import Γ¨ ora gestito da `perfectionist/sort-imports`
// (fornito dalla config condivisa), che verrΓ  valutata come regola
// separata durante la migrazione.
},
},

{
name: 'libresign/config-vue',
files: ['**/*.vue'],
rules: {
// production only
'vue/no-unused-components': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index'], 'unknown'],
pathGroups: [
{
// group all style imports at the end
pattern: '{*.css,*.scss}',
patternOptions: { matchBase: true },
group: 'unknown',
position: 'after',
},
{
// group material design icons
pattern: 'vue-material-design-icons/**',
group: 'external',
position: 'after',
},
{
// group @nextcloud imports
pattern: '@nextcloud/{!(vue),!(vue)/**}',
group: 'external',
position: 'after',
},
{
// group @nextcloud/vue imports
pattern: '{@nextcloud/vue,@nextcloud/vue/**}',
group: 'external',
position: 'after',
},
{
// group project components
pattern: '*.vue',
patternOptions: { matchBase: true },
group: 'parent',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['@nextcloud', 'vue-material-design-icons'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
warnOnUnassignedImports: true,
},
],
'import/no-unresolved': ['error', {
// Ignore Webpack query parameters, not supported by eslint-plugin-import
// https://github.com/import-js/eslint-plugin-import/issues/2562
ignore: ['\\?raw$'],
}],
},
},

Expand All @@ -94,4 +55,117 @@ export default [
'no-use-before-define': 'off',
},
},
]
{
name: 'libresign/disabled-during-migration',
rules: Object.fromEntries([
'perfectionist/sort-imports',
'jsdoc/require-jsdoc',
'@stylistic/indent',
'import-extensions/extensions',
'vue/first-attribute-linebreak',
'vue/attribute-hyphenation',
'perfectionist/sort-named-imports',
'@stylistic/no-tabs',
'@stylistic/member-delimiter-style',
'@stylistic/function-paren-newline',
'@stylistic/arrow-parens',
'vue/html-indent',
'antfu/top-level-function',
'jsdoc/require-param',
'curly',
'@typescript-eslint/no-unused-vars',
'vue/singleline-html-element-content-newline',
'vue/v-on-event-hyphenation',
'import-extensions/ban-inline-type-imports',
'vue/max-attributes-per-line',
'@typescript-eslint/consistent-type-imports',
'vue/custom-event-name-casing',
'vue/define-macros-order',
'@stylistic/comma-dangle',
'@stylistic/no-multiple-empty-lines',
'@stylistic/implicit-arrow-linebreak',
'@typescript-eslint/no-use-before-define',
'@stylistic/exp-list-style',
'vue/attributes-order',
'@stylistic/quote-props',
'vue/padding-line-between-blocks',
'@stylistic/no-extra-semi',
'vue/multi-word-component-names',
'jsdoc/require-param-description',
'@typescript-eslint/no-explicit-any',
'@stylistic/semi',
'vue/html-self-closing',
'vue/no-unused-refs',
'@stylistic/eol-last',
'prefer-object-has-own',
'no-empty',
'vue/no-unused-properties',
'@nextcloud/no-deprecated-library-props',
'jsdoc/no-types',
'camelcase',
'jsdoc/tag-lines',
'no-use-before-define',
'vue/new-line-between-multi-line-property',
'vue/no-v-html',
'vue/no-boolean-default',
'vue/prefer-separate-static-class',
'@nextcloud/l10n-non-breaking-space',
'@nextcloud/l10n-enforce-ellipsis',
'@stylistic/operator-linebreak',
'@stylistic/max-statements-per-line',
'no-empty-pattern',
'vue/html-closing-bracket-newline',
'jsdoc/check-tag-names',
'@stylistic/indent-binary-ops',
'@stylistic/padded-blocks',
'no-useless-escape',
'@stylistic/function-call-argument-newline',
'no-useless-assignment',
'vue/slot-name-casing',
'no-extra-boolean-cast',
'@typescript-eslint/no-empty-object-type',
'no-unused-vars',
'jsdoc/valid-types',
'vue/no-template-shadow',
'prefer-const',
'@stylistic/space-in-parens',
'@stylistic/space-before-function-paren',
'object-shorthand',
'vue/multiline-html-element-content-newline',
'vue/no-useless-mustaches',
'vue/require-default-prop',
'vue/prefer-prop-type-boolean-first',
'package-json/sort-package-json',
'jsdoc/escape-inline-tags',
'vue/key-spacing',
'vue/no-useless-v-bind',
'vue/no-undef-components',
'vue/no-use-v-if-with-v-for',
'@nextcloud/no-deprecated-globals',
'no-undef',
'@stylistic/no-trailing-spaces',
'jsdoc/reject-any-type',
'@typescript-eslint/no-unused-expressions',
'@stylistic/no-multi-spaces',
'@stylistic/lines-between-class-members',
'no-unassigned-vars',
'jsdoc/no-defaults',
'@stylistic/function-call-spacing',
'vue/no-dupe-keys',
].map(rule => [rule, 'off'])),
},
{
name: 'libresign/tests-console-override',
files: [
'src/tests/setup.js',
'src/tests/store/filters.spec.ts',
],
rules: {
// These files intentionally intercept console.error/console.warn
// to fail tests on unexpected console output, or to silence
// expected console output during a specific assertion. This is
// test tooling, not application logging.
'no-console': 'off',
},
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

/* eslint-disable jsdoc/require-jsdoc */

import { expect, test } from '@playwright/test'
import type { APIRequestContext, Locator, Page } from '@playwright/test'
Expand Down
2 changes: 1 addition & 1 deletion src/actions/openInLibreSignAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { t } from '@nextcloud/l10n'
import { spawnDialog } from '@nextcloud/vue/functions/dialog'
import EditNameDialog from '../components/Common/EditNameDialog.vue'

// eslint-disable-next-line import/no-unresolved

import SvgIcon from '../../img/app-dark.svg?raw'

/**
Expand Down
3 changes: 2 additions & 1 deletion src/components/Draw/FileUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'

import 'vue-advanced-cropper/dist/style.css'
import type { LibresignCapabilities } from '../../types/index'
import logger from '../../logger.js'

type CropperResult = {
canvas?: {
Expand Down Expand Up @@ -328,7 +329,7 @@ function fileSelect(event: Event) {
})

fileReader.addEventListener('error', error => {
console.error(error)
logger.error('Failed to read file', { error })
})

fileReader.readAsDataURL(selectedFile)
Expand Down
3 changes: 2 additions & 1 deletion src/components/FileStatusList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'

import { FILE_STATUS } from '../constants.js'
import { getStatusLabel, getStatusIcon } from '../utils/fileStatus.js'
import logger from '../logger.js'

defineOptions({
name: 'FileStatusList',
Expand Down Expand Up @@ -121,7 +122,7 @@ async function loadFiles() {
.filter(file => file.status === FILE_STATUS.SIGNED)
.map(file => file.id)
} catch (error) {
console.error('[libresign][FileStatusList] Error loading files:', error)
logger.error('[libresign][FileStatusList] Error loading files', { error })
} finally {
isLoading.value = false
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/FooterTemplateEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ import '@libresign/pdf-elements/dist/index.css'

import CodeEditor from './CodeEditor.vue'
import { ensurePdfWorker } from '../helpers/pdfWorker'
import logger from '../logger.js'

import {
mdiCheck,
Expand Down Expand Up @@ -303,7 +304,7 @@ function resetTemplateToDefault() {
emit('template-reset')
setPdfPreview(response.data)
}).catch(error => {
console.error('Error resetting footer template:', error)
logger.error('Error resetting footer template', { error })
})
}

Expand Down Expand Up @@ -334,7 +335,7 @@ function saveFooterTemplate() {
).then(response => {
setPdfPreview(response.data)
}).catch(error => {
console.error('Error saving footer template:', error)
logger.error('Error saving footer template', { error })
})
}

Expand All @@ -353,7 +354,7 @@ function setPdfPreview(blob: Blob) {
// Timeout to prevent infinite loading if PDFElements doesn't emit end-init
const loadingTimeout = setTimeout(() => {
if (loadingPreview.value) {
console.warn('PDF loading timeout - forcing preview ready state')
logger.warn('PDF loading timeout - forcing preview ready state')
loadingPreview.value = false
containerHeight.value = null
}
Expand Down
1 change: 0 additions & 1 deletion src/components/Request/RequestPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ const canUploadFronUrl = computed(() => {
return false
}
try {
// eslint-disable-next-line no-new
new URL(pdfUrl.value)
return true
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/RightSidebar/RequestSignatureTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ import { useSignStore } from '../../store/sign.js'
import { useUserConfigStore } from '../../store/userconfig.js'
import { startLongPolling } from '../../services/longPolling'
import { useSigningOrder } from '../../composables/useSigningOrder.js'
import logger from '../../logger.js'
import {
normalizeIdentifyMethodsPolicy,
type IdentifyMethodPolicyEntry,
Expand Down Expand Up @@ -1423,7 +1424,7 @@ function startSigningProgressPolling() {
},
() => !filesStore.getFile() || filesStore.getFile().id !== file.id,
(error: unknown) => {
console.error('Error during signing progress polling:', error)
logger.error('Error during signing progress polling', { error })
showError(t('libresign', 'Error monitoring signing progress'))
},
)
Expand Down
3 changes: 2 additions & 1 deletion src/components/validation/FileStatusList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
import { FILE_STATUS } from '../../constants.js'
import type { ValidationFileRecord } from '../../types'
import { getStatusLabel, getStatusIcon } from '../../utils/fileStatus.js'
import logger from '../../logger.js'

defineOptions({
name: 'FileStatusList',
Expand Down Expand Up @@ -75,7 +76,7 @@ async function loadFiles() {
files.value = responses.map((response) => response.data.ocs.data)
emit('files-updated', files.value)
} catch (error) {
console.error('[libresign][front] Failed to load files', error)
logger.error('[libresign][front] Failed to load files', { error })
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/services/SignFlowHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { REQUIREMENT_TO_MODAL } from '../helpers/ActionMapping.ts'
import logger from '../logger.js'

interface SignMethodsStore {
showModal(modalCode: string): void
Expand Down Expand Up @@ -32,7 +33,7 @@ export class SignFlowHandler {

const handler = actionMap[action]
if (!handler) {
console.warn(`Unknown action: ${action}`)
logger.warn('Unknown action', { action })
return null
}

Expand Down
4 changes: 3 additions & 1 deletion src/services/longPolling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import axios, { type AxiosResponse } from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'

import logger from '../logger.js'

interface FileStatusData {
status: number
[key: string]: unknown
Expand Down Expand Up @@ -76,7 +78,7 @@ export const createLongPolling = (options: LongPollingOptions = {}) => {
}

if (errorCount >= MAX_ERRORS) {
console.error('Long polling stopped after', MAX_ERRORS, 'consecutive errors')
logger.error('Long polling stopped after consecutive errors', { maxErrors: MAX_ERRORS })
break
}

Expand Down
5 changes: 3 additions & 2 deletions src/store/configureCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { computed, ref } from 'vue'

import axios from '@nextcloud/axios'
import { subscribe } from '@nextcloud/event-bus'
import logger from '../logger.js'
import { loadState } from '@nextcloud/initial-state'
import { generateOcsUrl } from '@nextcloud/router'

Expand Down Expand Up @@ -72,7 +73,7 @@ const _configureCheckStore = defineStore('configureCheck', () => {
updateItems(data.ocs?.data || [])
})
.catch((error) => {
console.error('Failed to check setup:', error)
logger.error('Failed to check setup', { error })
state.value = 'error'
downloadInProgress.value = false
})
Expand All @@ -91,7 +92,7 @@ const _configureCheckStore = defineStore('configureCheck', () => {
return checkSetup().then(() => ({ success: true, engine }))
})
.catch((error) => {
console.error('Failed to save certificate engine:', error)
logger.error('Failed to save certificate engine', { error })
return { success: false, error }
})
}
Expand Down
Loading