Skip to content

Commit c6f04cd

Browse files
authored
Merge pull request #7418 from nextcloud-libraries/chore/eslint-9
[stable8] chore: migrate to ESLint 9 and @nextcloud/eslint-config 9
2 parents b21e660 + 46e17cb commit c6f04cd

File tree

199 files changed

+3402
-3500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+3402
-3500
lines changed

.eslintrc.js

Lines changed: 0 additions & 46 deletions
This file was deleted.

build/extract-l10n.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import { GettextExtractor, JsExtractors, HtmlExtractors } from 'gettext-extractor'
6+
import { GettextExtractor, HtmlExtractors, JsExtractors } from 'gettext-extractor'
77

88
const extractor = new GettextExtractor()
99

@@ -30,6 +30,7 @@ extractor.createHtmlParser([
3030

3131
/**
3232
* remove references to avoid conflicts but save them for code splitting
33+
*
3334
* @type {Record<string,string[]>}
3435
*/
3536
export const context = extractor.getMessages().map((msg) => {
@@ -41,10 +42,10 @@ export const context = extractor.getMessages().map((msg) => {
4142
if (usage in localContext) {
4243
localContext[usage].push(id)
4344
return localContext
44-
} else {
45+
} else {
4546
localContext[usage] = [id]
46-
}
47-
return localContext
47+
}
48+
return localContext
4849
})
4950

5051
extractor.savePotFile('./l10n/messages.pot')

build/format-changelog.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
import { readFile, writeFile } from 'node:fs/promises'
66
import { join } from 'node:path'
77

8+
/* eslint-disable no-console */
9+
810
console.info('🔎 checking format of CHANGELOG.md')
911

1012
const file = join(import.meta.dirname, '..', 'CHANGELOG.md')
1113
const content = await readFile(file, { encoding: 'utf-8' })
1214

1315
const formatted = content.replaceAll(
1416
/by @([^ ]+) in ((https:\/\/github.com\/)nextcloud-libraries\/nextcloud-vue\/pull\/(\d+))/g,
15-
'[\#$4]($2) \([$1]($3$1)\)'
17+
'[\\#$4]($2) \\([$1]($3$1)\\)',
1618
)
1719

1820
if (formatted !== content) {

build/l10n-plugin.mts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import { Plugin } from 'vite'
7-
import { loadTranslations } from './translations.mts'
6+
import type { Plugin } from 'vite'
7+
88
import { readFileSync } from 'fs'
99
import { dirname, join, resolve } from 'path'
10+
import { loadTranslations } from './translations.mts'
1011

1112
/**
1213
* This is a plugin to split all translations into chunks of users meaning components that use that translation
@@ -63,6 +64,7 @@ export default (dir: string) => {
6364

6465
/**
6566
* Hook into module resolver and fake all '../[...]/l10n.js' imports to inject our splitted translations
67+
*
6668
* @param source The file which is imported
6769
* @param importer The file that imported the file
6870
*/
@@ -84,6 +86,7 @@ export default (dir: string) => {
8486

8587
/**
8688
* This function injects the translation chunks by returning a module that exports one translation object per component
89+
*
8790
* @param id The name of the module that should be loaded
8891
*/
8992
load(id) {

build/l10n-registration-implementation.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export const n = (...args) => gettext.ngettext(...args)
1515
export const t = (...args) => gettext.gettext(...args)
1616

1717
/**
18-
* @param {{ l: string, t: Record<string, { v: string[], p?: string }> }[]} chunks
18+
* This is called by the l10n plugin for the chunk(s) of translations used by a used component.
19+
* So that only those chunks used by the imported components are loaded.
20+
*
21+
* @param {{ l: string, t: Record<string, { v: string[], p?: string }> }[]} chunks - The translation chunk to be registered
1922
*/
2023
export function register(...chunks) {
2124
for (const chunk of chunks) {
@@ -29,17 +32,15 @@ export function register(...chunks) {
2932
continue
3033
}
3134

32-
const decompressed = Object.fromEntries(
33-
Object.entries(translations)
35+
const decompressed = Object.fromEntries(Object.entries(translations)
3436
.map(([id, value]) => [
3537
id,
3638
{
3739
msgid: id,
3840
msgid_plural: value.p,
3941
msgstr: value.v,
40-
}
41-
])
42-
)
42+
},
43+
]))
4344

4445
gettext.addTranslations({
4546
translations: {

build/translations.mts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import { join, basename } from 'path'
76
import { readdir, readFile } from 'fs/promises'
87
import { po as poParser } from 'gettext-parser'
8+
import { basename, join } from 'path'
99

10+
/**
11+
* @param baseDir - Base directory to look for translations
12+
*/
1013
export async function loadTranslations(baseDir: string) {
1114
const files = await readdir(baseDir)
1215

1316
const promises = files
14-
.filter(name => name !== 'messages.pot' && name.endsWith('.pot'))
15-
.map(file => join(baseDir, file))
17+
.filter((name) => name !== 'messages.pot' && name.endsWith('.pot'))
18+
.map((file) => join(baseDir, file))
1619
.map(parseFile)
1720

1821
const parsedTranslations = await Promise.all(promises)

cypress.config.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
import { createAppConfig } from '@nextcloud/vite-config'
77
import { defineConfig } from 'cypress'
8+
import { configureVisualRegression } from 'cypress-visual-regression'
89
import { resolve } from 'path'
910
import { fileURLToPath } from 'url'
10-
import { configureVisualRegression } from 'cypress-visual-regression'
1111

1212
const __dirname = fileURLToPath(new URL('.', import.meta.url))
1313
const SCOPE_VERSION = Date.now().toString()
@@ -49,7 +49,6 @@ export default defineConfig({
4949
return launchOptions
5050
}
5151
})
52-
5352
},
5453

5554
devServer: {

cypress/commands.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type { mount } from '@cypress/vue2'
88
// Augment the Cypress namespace to include type definitions for
99
// your custom commands
1010
declare global {
11-
// eslint-disable-next-line @typescript-eslint/no-namespace
1211
namespace Cypress {
1312
interface Chainable {
1413
mount: typeof mount

cypress/component/NcAppNavigation.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('NcAppNavigation hotkeys', () => {
4545
cy.document().then((doc) => {
4646
const activeElement = doc.activeElement
4747
const navigation = doc.querySelector('nav')
48-
// eslint-disable-next-line no-unused-expressions
48+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
4949
expect(navigation?.contains(activeElement)).to.be.true
5050
})
5151
})

cypress/component/NcAppSettingsDialog.cy.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*/
55

66
import { mount } from 'cypress/vue2'
7+
import { defineComponent } from 'vue'
78
import NcAppSettingsDialog from '../../src/components/NcAppSettingsDialog/NcAppSettingsDialog.vue'
89
import NcAppSettingsSection from '../../src/components/NcAppSettingsSection/NcAppSettingsSection.vue'
9-
import { defineComponent } from 'vue'
1010

1111
describe('NcAppSettingsDialog', () => {
1212
it('Dialog is correctly labelled', () => {
@@ -17,8 +17,8 @@ describe('NcAppSettingsDialog', () => {
1717
},
1818
slots: {
1919
default: defineComponent({
20-
render: (h) => h(NcAppSettingsSection, { props: { name: 'First section', id: 'first' } })
21-
})
20+
render: (h) => h(NcAppSettingsSection, { props: { name: 'First section', id: 'first' } }),
21+
}),
2222
},
2323
})
2424

@@ -34,8 +34,8 @@ describe('NcAppSettingsDialog', () => {
3434
},
3535
slots: {
3636
default: defineComponent({
37-
render: (h) => h(NcAppSettingsSection, { props: { name: 'First section', id: 'first' } }, ['The section content'])
38-
})
37+
render: (h) => h(NcAppSettingsSection, { props: { name: 'First section', id: 'first' } }, ['The section content']),
38+
}),
3939
},
4040
})
4141

0 commit comments

Comments
 (0)