Skip to content

Commit

Permalink
Merge pull request #39029 from nextcloud/feat/eslint-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Jun 27, 2023
2 parents fa37574 + cd54f7c commit c3982b7
Show file tree
Hide file tree
Showing 120 changed files with 11,903 additions and 5,416 deletions.
13 changes: 5 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@ module.exports = {
__webpack_nonce__: true,
_: true,
$: true,
moment: true,
escapeHTML: true,
oc_userconfig: true,
dayNames: true,
escapeHTML: true,
firstDay: true,
'cypress/globals': true,
},
parserOptions: {
parser: '@typescript-eslint/parser',
moment: true,
oc_userconfig: true,
sinon: true,
},
plugins: [
'cypress',
],
extends: [
'@nextcloud',
'@nextcloud/eslint-config/typescript',
'plugin:cypress/recommended',
],
rules: {
Expand Down
30 changes: 30 additions & 0 deletions __mocks__/@nextcloud/dialogs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @copyright Copyright (c) 2023 John Molakvoæ <[email protected]>
*
* @author John Molakvoæ <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

import { jest } from '@jest/globals'

export const showMessage = jest.fn()
export const showSuccess = jest.fn()
export const showWarning = jest.fn()
export const showInfo = jest.fn()
export const showError = jest.fn()
export const showUndo = jest.fn()
6 changes: 6 additions & 0 deletions __tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"verbatimModuleSyntax": false
}
}
6 changes: 3 additions & 3 deletions apps/files/src/actions/editLocallyAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
*/
import { action } from './editLocallyAction'
import { expect } from '@jest/globals'
import { File, Folder, Permission } from '@nextcloud/files'
import { File, Permission } from '@nextcloud/files'
import { FileAction } from '../services/FileAction'
import * as ncDialogs from '@nextcloud/dialogs'
import axios from '@nextcloud/axios'
import type { Navigation } from '../services/Navigation'
import ncDialogs from '@nextcloud/dialogs'

const view = {
id: 'files',
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('Edit locally action execute tests', () => {

test('Edit locally fails and show error', async () => {
jest.spyOn(axios, 'post').mockImplementation(async () => ({}))
jest.spyOn(ncDialogs, 'showError')
jest.spyOn(ncDialogs, 'showError').mockImplementation(async () => ({}))

const file = new File({
id: 1,
Expand Down
5 changes: 2 additions & 3 deletions apps/files/src/actions/openFolderAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
import { action } from './openFolderAction'
import { expect } from '@jest/globals'
import { File, Folder, Permission } from '@nextcloud/files'
import { File, Folder, Node, Permission } from '@nextcloud/files'
import { FileAction } from '../services/FileAction'
import type { Navigation } from '../services/Navigation'

Expand Down Expand Up @@ -139,8 +139,7 @@ describe('Open folder action execute tests', () => {
const goToRouteMock = jest.fn()
window.OCP = { Files: { Router: { goToRoute: goToRouteMock } } }

// @ts-ignore null as Node
const exec = await action.exec(null, view, '/')
const exec = await action.exec(null as unknown as Node, view, '/')
expect(exec).toBe(false)
expect(goToRouteMock).toBeCalledTimes(0)
})
Expand Down
1 change: 0 additions & 1 deletion apps/files/src/actions/sidebarAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ export const action = new FileAction({
})

registerFileAction(action)

1 change: 0 additions & 1 deletion apps/files/src/components/SidebarTab.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<!--
- @copyright Copyright (c) 2019 John Molakvoæ <[email protected]>
-
Expand Down
14 changes: 7 additions & 7 deletions apps/files/src/services/RouterService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,26 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import type { Route } from 'vue-router';
import type VueRouter from 'vue-router';
import type { Dictionary } from 'vue-router/types/router';
import type { Location } from 'vue-router/types/router';
import type { Route } from 'vue-router'
import type VueRouter from 'vue-router'
import type { Dictionary, Location } from 'vue-router/types/router'

export default class RouterService {

private _router: VueRouter;
private _router: VueRouter

constructor(router: VueRouter) {
this._router = router
}

/**
* Trigger a route change on the files app
*
*
* @param path the url path, eg: '/trashbin?dir=/Deleted'
* @param replace replace the current history
* @see https://router.vuejs.org/guide/essentials/navigation.html#navigate-to-a-different-location
*/
goTo(path: string, replace: boolean = false): Promise<Route> {
goTo(path: string, replace = false): Promise<Route> {
return this._router.push({
path,
replace,
Expand Down Expand Up @@ -68,4 +67,5 @@ export default class RouterService {
replace,
} as Location)
}

}
2 changes: 1 addition & 1 deletion apps/files/src/views/Navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('Quota rendering', () => {
// TODO: remove when @nextcloud/l10n 2.0 is released
// https://github.com/nextcloud/nextcloud-l10n/pull/542
cy.stub(L10n, 'translate', (app, text, vars = {}, number) => {
cy.log({app, text, vars, number})
cy.log({ app, text, vars, number })
return text.replace(/%n/g, '' + number).replace(/{([^{}]*)}/g, (match, key) => {
return vars[key]
})
Expand Down
1 change: 0 additions & 1 deletion apps/files_sharing/src/components/SharingEntryInternal.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<template>
<ul>
<SharingEntrySimple ref="shareEntrySimple"
Expand Down
10 changes: 4 additions & 6 deletions apps/settings/src/components/AppList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,13 @@ export default {
return (this.category === 'app-bundles')
},
allBundlesEnabled() {
const self = this
return function(id) {
return self.bundleApps(id).filter(app => !app.active).length === 0
return (id) => {
return this.bundleApps(id).filter(app => !app.active).length === 0
}
},
bundleToggleText() {
const self = this
return function(id) {
if (self.allBundlesEnabled(id)) {
return (id) => {
if (this.allBundlesEnabled(id)) {
return t('settings', 'Disable all')
}
return t('settings', 'Enable all')
Expand Down
7 changes: 3 additions & 4 deletions apps/settings/src/components/GroupListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,15 @@ export default {
}
},
removeGroup(groupid) {
const self = this
// TODO migrate to a vue js confirm dialog component
OC.dialogs.confirm(
t('settings', 'You are about to remove the group {group}. The users will NOT be deleted.', { group: groupid }),
t('settings', 'Please confirm the group removal '),
function(success) {
(success) => {
if (success) {
self.$store.dispatch('removeGroup', groupid)
this.$store.dispatch('removeGroup', groupid)
}
}
},
)
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ export default {
</script>

<style lang="scss" scoped>
.federation-actions__btn {
&::v-deep p {
width: 150px !important;
padding: 8px 0 !important;
color: var(--color-main-text) !important;
font-size: 12.8px !important;
line-height: 1.5em !important;
}
.federation-actions__btn {
&::v-deep p {
width: 150px !important;
padding: 8px 0 !important;
color: var(--color-main-text) !important;
font-size: 12.8px !important;
line-height: 1.5em !important;
}
}
.federation-actions__btn--active {
background-color: var(--color-primary-element-light) !important;
box-shadow: inset 2px 0 var(--color-primary-element) !important;
}
.federation-actions__btn--active {
background-color: var(--color-primary-element-light) !important;
box-shadow: inset 2px 0 var(--color-primary-element) !important;
}
</style>
4 changes: 2 additions & 2 deletions apps/theming/src/components/BackgroundSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ export default {
const result = await axios.post(generateUrl('/apps/theming/background/color'), { color })
this.update(result.data)
},
debouncePickColor: debounce(function() {
this.pickColor(...arguments)
debouncePickColor: debounce(function(...args) {
this.pickColor(...args)
}, 200),
async pickFile() {
Expand Down
1 change: 0 additions & 1 deletion core/src/profile/ProfileSections.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* @copyright Copyright (c) 2019 Julius Härtl <[email protected]>
*
Expand Down
2 changes: 0 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable node/no-unpublished-import */

import {
applyChangesToNextcloud,
configureNextcloud,
Expand Down
3 changes: 3 additions & 0 deletions dist/2142-2142.js

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions dist/6117-6117.js.LICENSE.txt → dist/2142-2142.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

/*! For license information please see NcActionTextEditable.js.LICENSE.txt */

/**
*
*
* @author Jerry Bendy <[email protected]>
* @licence MIT
*
*/

/**
* @copyright 2022 Louis Chmn <[email protected]>
*
Expand Down Expand Up @@ -444,3 +436,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**!
* url-search-params-polyfill
*
* @author Jerry Bendy (https://github.com/jerrybendy)
* @licence MIT
*/
1 change: 1 addition & 0 deletions dist/2142-2142.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/2323-2323.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/2323-2323.js.map

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions dist/6117-6117.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/6117-6117.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions dist/614-614.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/614-614.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/7816-7816.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/7816-7816.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

28 changes: 3 additions & 25 deletions dist/core-common.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object-assign
*/

/*!
* focus-trap 7.4.0
* focus-trap 7.4.3
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
*/

Expand All @@ -94,11 +94,11 @@ object-assign
*/

/*!
* tabbable 6.1.1
* tabbable 6.2.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/

/*! @license DOMPurify 2.4.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.5/LICENSE */
/*! @license DOMPurify 3.0.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.3/LICENSE */

/*! For license information please see NcActionButton.js.LICENSE.txt */

Expand Down Expand Up @@ -182,28 +182,6 @@ object-assign
*
*/

/**
* @copyright Copyright (c) 2021 Christoph Wurst
*
* @author Christoph Wurst <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.16.1
Expand Down
2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-install.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-install.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit c3982b7

Please sign in to comment.