Skip to content
Merged
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
141 changes: 133 additions & 8 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,32 @@ export default [
'no-console': 'off',
'n/no-process-exit': 'off',
'n/hashbang': 'off',
// `_` / `__` as a deliberate throwaway binding — `catch (_)`, a
// discarded destructuring slot. Narrow on purpose: the pattern matches
// UNDERSCORES ONLY, so a real name that happens to start with `_` is
// still reported. v9 drives plain `.js` through the CORE rule (the
// `@typescript-eslint` swap is per-file-type), so it is set here.
// Tests import devDependencies by definition; this rule is about what
// ships in the published package, which tests/ never does.
'n/no-unpublished-import': 'off',
},
},

{
// `_` / `__` as a deliberate throwaway binding — `catch (_)`, a discarded
// destructuring slot. Narrow on purpose: the pattern matches UNDERSCORES
// ONLY, so a real name that happens to start with `_` is still reported.
//
// 🔴 `.js` / `.mjs` ONLY, NOT `.ts`. The CORE rule is not TypeScript-aware:
// applied to a `.ts` file it reads the parameter NAMES inside a function
// TYPE as bindings and reports them unused. Measured on humaniq —
//
// t?: (app: string, key: string) => string
//
// produced four `no-unused-vars` errors for `app` and `key`, which are
// documentation, not variables. The same mis-scoping made every unused
// `catch (e)` in a `.ts` spec report TWICE, once per rule.
//
// v9 already turns the core rule off for `.ts` and drives
// `@typescript-eslint/no-unused-vars` instead; naming `.ts` here switched
// it back on. TypeScript files are handled by the block below.
files: ['tests/**/*.js', 'tests/**/*.mjs'],
rules: {
'no-unused-vars': [
'error',
{
Expand All @@ -165,12 +186,116 @@ export default [
ignoreRestSiblings: true,
},
],
// Tests import devDependencies by definition; this rule is about what
// ships in the published package, which tests/ never does.
'n/no-unpublished-import': 'off',
},
},

{
// The TypeScript half of the block above. Same intent, same patterns, on
// the rule that actually understands the language: it knows a name inside
// a function type is not a binding, so type annotations stay quiet while a
// genuinely dead local is still reported.
files: ['tests/**/*.ts', 'tests/**/*.tsx'],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: '^_+$',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_+$',
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},

{
// 🔴 Node-side CLI tooling under `scripts/`, which is COMMONJS. Flat
// config defaults every `.js` to ESM with browser-ish globals, so without
// this block eslint reports the CommonJS wrapper itself as undefined
// identifiers. Measured on this app: 52 of the 233 errors under
// `tests/` + `scripts/` were `no-undef`, ALL of them in `scripts/`, and
// all five names were the environment rather than a typo — `process` 23,
// `require` 20, `__dirname` 6, `__filename` 2, `module` 1.
//
// This is describing the environment, not relaxing a rule, and it is the
// same argument the test-globals block below makes: declaring them keeps
// `no-undef` able to do its real job, which is catching a genuinely
// misspelled identifier. Suppressing the rule instead would bury that.
//
// `no-console` is off because printing its report is what a CLI checker
// is FOR.
//
// 🔴 NO `n/*` ENTRIES HERE, DELIBERATELY. `eslint-plugin-n` is NOT
// registered for these files under eslint 10 + @nextcloud/eslint-config
// 9, so `'n/no-process-exit': 'off'` would be dead config that reads as
// if it were doing something. Measured both ways on this app: 0 `n/`
// findings with the entries and 0 without.
//
// What DID report was the opposite — four `scripts/*.js` carried
// `/* eslint-disable n/no-process-exit */` and `/* eslint-disable
// n/shebang */` left over from the eslintrc era, and an inline disable
// naming an unregistered plugin is itself an error ("Definition for rule
// 'n/shebang' was not found"). Those 8 comments are removed; do not add
// `n/*` rules back to replace them.
//
// ⚠️ `.js` and `.cjs` ONLY. A `scripts/*.mjs` is genuinely ESM and must
// keep the default `sourceType`, or `import` stops parsing there.
files: ['scripts/**/*.js', 'scripts/**/*.cjs'],
languageOptions: {
sourceType: 'commonjs',
globals: {
require: 'readonly',
module: 'writable',
exports: 'writable',
process: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
console: 'readonly',
Buffer: 'readonly',
global: 'readonly',
URL: 'readonly',
TextEncoder: 'readonly',
TextDecoder: 'readonly',
},
},
rules: {
'no-console': 'off',
},
},

{
// The ESM half of the block above. A `scripts/*.mjs` is genuinely a module
// and must keep the default `sourceType`, so it gets Node's globals but
// none of the CommonJS wrapper. Measured: `process` reported undefined 2x
// in hermiq's generate-opengemeenten-icons.mjs and 4x in openregister's
// l10n/runtime-check.mjs, which the `.js`/`.cjs` block deliberately does
// not match.
files: ['scripts/**/*.mjs', 'tests/**/*.mjs'],
languageOptions: {
globals: {
process: 'readonly',
console: 'readonly',
Buffer: 'readonly',
global: 'readonly',
URL: 'readonly',
TextEncoder: 'readonly',
TextDecoder: 'readonly',
},
},
rules: {
'no-console': 'off',
},
},

{
// eslint must not try to PARSE a shell script. `tests/e2e/seed.test.sh`
// matches the `**/*.test.*` glob some presets use, and eslint then reads
// it as JavaScript and reports "Parsing error: Unexpected character" —
// a finding about a file it should never have opened.
ignores: ['**/*.sh', '**/*.bash'],
},

{
// Test globals. Several apps keep their spec files INSIDE `src/`, which the
// lint script scans, and neither `@nextcloud/eslint-config` nor the runner
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"postdev": "[ -d ../openregister/custom_apps/shillinq/js ] && cp -r js/. ../openregister/custom_apps/shillinq/js/ || true",
"prewatch": "node scripts/generate-manifest-shell.js",
"watch": "NODE_ENV=development webpack --config webpack.config.js --progress --watch",
"lint": "eslint src",
"lint": "eslint src tests scripts",
"lint-fix": "npm run lint -- --fix",
"test:l10n": "node tests/l10n/check-l10n.js",
"test:l10n-parity": "L10N_REQUIRED_LOCALES=nl node tests/l10n/check-l10n-parity.js",
Expand Down
3 changes: 3 additions & 0 deletions scripts/build-l10n-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ function renderJs(id, translations, pluralForm) {
].join('\n')
}

/**
*
*/
function main() {
const check = process.argv.includes('--check')
const id = appId()
Expand Down
3 changes: 3 additions & 0 deletions scripts/check-schema-l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ function collect(node, where, sink) {
for (const value of Object.values(node)) collect(value, where, sink)
}

/**
*
*/
function main() {
const update = process.argv.includes('--update')
const list = process.argv.includes('--list')
Expand Down
4 changes: 2 additions & 2 deletions scripts/generate-manifest-shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function slimPages(pages, fragment) {
return pages.map((page) => {
const slim = { _fragment: fragment }
for (const key of SHELL_PAGE_KEYS) {
if (page && Object.prototype.hasOwnProperty.call(page, key)) {
if (page && Object.hasOwn(page, key)) {
slim[key] = page[key]
}
}
Expand Down Expand Up @@ -135,7 +135,7 @@ function generateShellDocument(dir = MANIFEST_D_DIR) {
function main() {
const shell = generateShellDocument()
fs.writeFileSync(SHELL_OUTPUT_PATH, JSON.stringify(shell, null, '\t') + '\n')
// eslint-disable-next-line no-console

console.log(
`[generate-manifest-shell] wrote ${SHELL_OUTPUT_PATH} `
+ `(${shell.fragments.length} fragments, `
Expand Down
4 changes: 0 additions & 4 deletions tests/check-manifest-budget.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ function main() {
manifestSize = fs.statSync(MANIFEST_PATH).size
fragmentsSize = sumJsonFileSizes(MANIFEST_D_DIR)
} catch (err) {
// eslint-disable-next-line no-console
console.error(
`[check-manifest-budget] could not read manifest files: ${err.message}`,
)
Expand All @@ -183,14 +182,12 @@ function main() {

const total = manifestSize + fragmentsSize

// eslint-disable-next-line no-console
console.log(
`[check-manifest-budget] manifest.json=${manifestSize}B manifest.d/=${fragmentsSize}B `
+ `total=${total}B budget=${budget}B`,
)

if (total > budget) {
// eslint-disable-next-line no-console
console.error(
`[check-manifest-budget] FAIL: combined manifest JSON (${total}B) exceeds the `
+ `${budget}B budget shipped in the main webpack chunk (REQ-MBP-001). Either trim `
Expand All @@ -201,7 +198,6 @@ function main() {
return
}

// eslint-disable-next-line no-console
console.log('[check-manifest-budget] PASS')
}

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/AccountantPortalDashboard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @spec openspec/changes/accountant-portal/specs/accountant-portal/spec.md#req-acp-002
*/

import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'
import { becomesVisible } from './becomes-visible.js'

const APP = '/apps/shillinq'
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/DeadlineCalendarSettings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @spec openspec/changes/compliance-deadline-calendar/specs/compliance-deadline-calendar/spec.md#req-cdc-006
*/

import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'
import { becomesVisible } from './becomes-visible.js'

const APP = '/apps/shillinq'
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/NavSixClusters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @spec openspec/changes/nav-six-clusters/specs/nav-clusters/spec.md#req-navc-009
*/

import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'
import { becomesVisible } from './becomes-visible.js'

const APP = '/apps/shillinq'
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/ar-invoice-einvoice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
* @spec openspec/changes/add-invoice-pdf-export-with-ubl-peppol-support/specs/bookkeeping-einvoicing-ubl-peppol/spec.md#req-einv-007
*/

import { test, expect, type Page } from '@playwright/test'
import type { Page } from '@playwright/test'

import { expect, test } from '@playwright/test'

const APP = '/apps/shillinq'
const ROUTE_AR = '/bookkeeping/accounts-receivable'
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/bank-statement-wizard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
* @spec openspec/specs/shillinq-bank-statement-wizard/spec.md
*/

import { test, expect, type Page } from '@playwright/test'
import type { Page } from '@playwright/test'

import { expect, test } from '@playwright/test'
import { becomesVisible } from './becomes-visible.js'

const APP = '/apps/shillinq'
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/base-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export function resolveBaseURL(): string {
}

if (process.env.GITHUB_ACTIONS === 'true' || process.env.CI) {
// eslint-disable-next-line no-console
console.warn(
`[shillinq e2e] none of ${BASE_URL_ENV_NAMES.join(' / ')} is set; `
+ `falling back to the CI-local ${CI_DEFAULT_BASE_URL}.`,
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/bbv-compliance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
* @spec openspec/changes/bookkeeping-bbv-compliance/tasks.md (Tasks 5.13-5.19)
*/

import { test, expect, type Page } from '@playwright/test'
import type { Page } from '@playwright/test'

import { expect, test } from '@playwright/test'

const APP = '/apps/shillinq'
const ROUTE_IV3_AANLEVERING = '/overheid/iv3-aanlevering'
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/bill-import-modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
* @spec openspec/specs/shillinq-bill-import-modal/spec.md
*/

import { test, expect, type Page } from '@playwright/test'
import type { Page } from '@playwright/test'

import { expect, test } from '@playwright/test'

const APP = '/apps/shillinq'
const ROUTE_FINANCIAL = '/financial'
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/bookings-calendar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* scenario against the bookings-resource-calendar spec.
*/

import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'

const APP = '/apps/shillinq'

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/bookings-notification-triggers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @spec openspec/changes/bookings-notification-triggers/tasks.md#task-17
*/

import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'

const APP = '/apps/shillinq'
const NOTIFICATION_TRIGGERS_ROUTE = '/communication/notification-triggers'
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/bookings-resource-calendar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
* @spec openspec/changes/bookings-resource-calendar/tasks.md#task-11
*/

import { test, expect, type Page } from '@playwright/test'
import type { Page } from '@playwright/test'

import { expect, test } from '@playwright/test'

const APP = '/apps/shillinq'

Expand Down
6 changes: 4 additions & 2 deletions tests/e2e/bookings-screenshots.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
* automatically (URL is unchanged from the docs).
*/

import { test, expect, type Page } from '@playwright/test'
import * as path from 'path'
import type { Page } from '@playwright/test'

import { expect, test } from '@playwright/test'
import * as fs from 'fs'
import * as path from 'path'

const SHOT_ROOT = path.resolve(
__dirname,
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/bookings-widget-embed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @spec openspec/changes/bookings-self-service-widget/tasks.md#task-21
*/

import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'

const APP = '/apps/shillinq'
const SERVICES_API = APP + '/api/widget/services'
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/bookkeeping-foundation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* "page mounted on the correct route", not "list has N rows".
*/

import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'

const APP = '/apps/shillinq'

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/bookkeeping-ifrs15-revenue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @spec openspec/changes/bookkeeping-ifrs15-revenue/tasks.md#browser-tests
*/

import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'

const APP = '/apps/shillinq'

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/bookkeeping-period-close.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @spec openspec/changes/bookkeeping-period-close/tasks.md#task-16
*/

import { test, expect } from '@playwright/test'
import { expect, test } from '@playwright/test'

const APP = '/apps/shillinq'
const INDEX_PATH = '/bookkeeping/period-close'
Expand Down
Loading
Loading