From 0ce764263f78c915906d888efab8c321c7593488 Mon Sep 17 00:00:00 2001 From: Gallay Lajos Date: Tue, 12 Feb 2019 15:53:13 +0100 Subject: [PATCH 1/5] [KFI]chore(project): removed redundant type definitions, added tslint rule --- examples/sn-dms-demo/src/Actions.ts | 4 +- examples/sn-dms-demo/src/Reducers.ts | 29 +++++------ examples/sn-dms-demo/src/ViewerSettings.ts | 6 +-- .../src/components/ActionMenu/AddNewMenu.tsx | 2 +- .../sn-dms-demo/src/components/BreadCrumb.tsx | 4 +- .../src/components/Dialogs/VersionsDialog.tsx | 4 +- .../sn-dms-demo/src/components/MessageBar.tsx | 2 +- .../src/components/Pickers/PathPicker.tsx | 2 +- .../src/components/Upload/UploadButton.tsx | 6 +-- examples/sn-dms-demo/src/pages/Dashboard.tsx | 3 ++ .../src/store/actionlog/actions.ts | 3 +- .../src/store/documentlibrary/actions.ts | 3 ++ .../sn-dms-demo/src/store/edited/reducers.ts | 5 +- .../sn-dms-demo/src/store/picker/reducers.ts | 22 +++------ examples/sn-dms-demo/src/store/queries.ts | 6 ++- .../src/store/usersandgroups/actions.ts | 2 +- .../src/store/usersandgroups/reducers.ts | 25 +++++----- .../src/store/workspaces/reducers.ts | 8 +-- package.json | 1 + .../sn-authentication-jwt/src/JwtService.ts | 2 +- .../src/Repository/Repository.ts | 2 +- .../sn-client-core/src/Repository/Upload.ts | 4 +- .../sn-control-mapper/src/ControlMapper.ts | 14 ++---- .../src/ExampleAppLayout.tsx | 6 +-- .../src/components/PageList.tsx | 10 ++-- .../src/models/DocumentViewerSettings.ts | 16 +++--- .../src/store/Localization.ts | 5 +- .../src/store/RootReducer.ts | 3 +- .../src/store/index.ts | 12 +---- .../sn-icons-react/src/components/Icon.tsx | 11 ++--- packages/sn-redux/src/Store.ts | 8 ++- .../sn-redux/src/reducers/currentitems.ts | 5 +- packages/sn-redux/src/reducers/selected.ts | 2 +- .../src/Components/Fields/TypeField.tsx | 2 +- tslint.json | 3 +- yarn.lock | 49 ++++++++++++++++++- 36 files changed, 157 insertions(+), 134 deletions(-) diff --git a/examples/sn-dms-demo/src/Actions.ts b/examples/sn-dms-demo/src/Actions.ts index fee800fc9..4af08a0dc 100644 --- a/examples/sn-dms-demo/src/Actions.ts +++ b/examples/sn-dms-demo/src/Actions.ts @@ -146,9 +146,7 @@ export const trackUploadProgress = async ( dispatch: Dispatch, api: Repository, ) => { - let currentUpload: ExtendedUploadProgressInfo | undefined = getState().dms.uploads.uploads.find( - u => u.guid === currentValue.guid, - ) + let currentUpload = getState().dms.uploads.uploads.find(u => u.guid === currentValue.guid) if (currentUpload) { dispatch(updateUploadItem(currentValue)) } else { diff --git a/examples/sn-dms-demo/src/Reducers.ts b/examples/sn-dms-demo/src/Reducers.ts index fd3ded124..ac07c02c6 100644 --- a/examples/sn-dms-demo/src/Reducers.ts +++ b/examples/sn-dms-demo/src/Reducers.ts @@ -29,7 +29,7 @@ export const email: Reducer = (state = '', return state } } -export const registrationError: Reducer = (state: string | null = null, action: AnyAction) => { +export const registrationError: Reducer = (state = null, action: AnyAction) => { switch (action.type) { case 'USER_REGISTRATION_FAILURE': return resources.USER_IS_ALREADY_REGISTERED @@ -37,7 +37,7 @@ export const registrationError: Reducer = (state: string return state } } -export const isRegistering: Reducer = (state: boolean = false, action: AnyAction) => { +export const isRegistering: Reducer = (state = false, action: AnyAction) => { switch (action.type) { case 'USER_REGISTRATION_REQUEST': return true @@ -49,7 +49,7 @@ export const isRegistering: Reducer = (state: boolean = false, action: } } -export const registrationDone: Reducer = (state: boolean = false, action: AnyAction) => { +export const registrationDone: Reducer = (state = false, action: AnyAction) => { switch (action.type) { case 'USER_REGISTRATION_SUCCESS': return true @@ -62,7 +62,7 @@ export const registrationDone: Reducer = (state: boolean = false, actio } } -export const captcha: Reducer = (state: boolean = false, action: AnyAction) => { +export const captcha: Reducer = (state = false, action: AnyAction) => { switch (action.type) { case 'VERIFY_CAPTCHA_SUCCESS': return true @@ -79,7 +79,7 @@ export const register = combineReducers({ captcha, }) -export const open: Reducer = (state: boolean = false, action: AnyAction) => { +export const open: Reducer = (state = false, action: AnyAction) => { switch (action.type) { case 'OPEN_ACTIONMENU': return true @@ -90,7 +90,7 @@ export const open: Reducer = (state: boolean = false, action: AnyAction } } -export const actions: Reducer = (state: ActionModel[] = [], action: AnyAction) => { +export const actions: Reducer = (state = [], action: AnyAction) => { switch (action.type) { case 'LOAD_CONTENT_ACTIONS_SUCCESS': const result: { d: { Actions: ActionModel[] } } = (action.result as Actions.PromiseReturns< @@ -104,7 +104,7 @@ export const actions: Reducer = (state: ActionModel[] = [], actio } } -export const id: Reducer = (state: number | null = null, action: AnyAction) => { +export const id: Reducer = (state = null, action: AnyAction) => { switch (action.type) { case 'OPEN_ACTIONMENU': return action.id || null @@ -248,7 +248,7 @@ export const isSelectionModeOn: Reducer = (state = false, action: AnyAc } } -export const userActions: Reducer = (state: ActionModel[] = [], action: AnyAction) => { +export const userActions: Reducer = (state = [], action: AnyAction) => { switch (action.type) { case 'LOAD_USER_ACTIONS_SUCCESS': const result = action.result as Actions.PromiseReturns @@ -258,7 +258,7 @@ export const userActions: Reducer = (state: ActionModel[] = [], a } } -export const addNewTypes: Reducer = (state: ActionModel[] = [], action: AnyAction) => { +export const addNewTypes: Reducer = (state = [], action: AnyAction) => { switch (action.type) { case 'LOAD_TYPES_TO_ADDNEW_LIST_SUCCESS': const result = action.result as Actions.PromiseReturns @@ -435,7 +435,7 @@ export const viewer: Reducer<{ isOpened: boolean; currentDocumentId: number }, A return state } -export const isOpened: Reducer = (state: boolean = false, action: AnyAction) => { +export const isOpened: Reducer = (state = false, action: AnyAction) => { switch (action.type) { case 'OPEN_DIALOG': return true @@ -445,10 +445,7 @@ export const isOpened: Reducer = (state: boolean = false, action: AnyAc return state } -export const onClose: Reducer<() => void | undefined> = ( - state: () => void | undefined = () => undefined, - action: AnyAction, -) => { +export const onClose: Reducer<() => void | undefined> = (state = () => undefined, action: AnyAction) => { switch (action.type) { case 'OPEN_DIALOG': return action.onClose @@ -471,7 +468,7 @@ export const dialogContent: Reducer = ( return state } -export const dialogTitle: Reducer = (state: string = '', action: AnyAction) => { +export const dialogTitle: Reducer = (state = '', action: AnyAction) => { switch (action.type) { case 'OPEN_DIALOG': return action.title @@ -498,7 +495,7 @@ export const versions = (state: GenericContent[] = [], action: AnyAction) => { } } -export const menuOpen: Reducer = (state: boolean = false, action: AnyAction) => { +export const menuOpen: Reducer = (state = false, action: AnyAction) => { switch (action.type) { case 'HANDLE_DRAWERMENU': return action.open diff --git a/examples/sn-dms-demo/src/ViewerSettings.ts b/examples/sn-dms-demo/src/ViewerSettings.ts index 0cf739b1f..e195b9754 100644 --- a/examples/sn-dms-demo/src/ViewerSettings.ts +++ b/examples/sn-dms-demo/src/ViewerSettings.ts @@ -14,12 +14,12 @@ import { v1 } from 'uuid' /** * Adds a globally unique ID to the shape */ -const addGuidToShape: (shape: T) => T = shape => { +const addGuidToShape = (shape: T) => { shape.guid = v1() return shape } -export const getViewerSettings: (repo: Repository) => DocumentViewerSettings = (repo: Repository) => +export const getViewerSettings = (repo: Repository) => new DocumentViewerSettings({ saveChanges: async (documentData, pages) => { const reqBody = { @@ -67,7 +67,7 @@ export const getViewerSettings: (repo: Repository) => DocumentViewerSettings = ( pageAttributes: (documentData.PageAttributes && JSON.parse(documentData.PageAttributes)) || [], } }, - isPreviewAvailable: async (documentData, version, page: number) => { + isPreviewAvailable: async (documentData, version, page) => { const responseBody = await repo.executeAction<{ page: number }, PreviewImageData & { PreviewAvailable: string }>({ idOrPath: documentData.idOrPath, method: 'POST', diff --git a/examples/sn-dms-demo/src/components/ActionMenu/AddNewMenu.tsx b/examples/sn-dms-demo/src/components/ActionMenu/AddNewMenu.tsx index ac73566f9..98f9102d4 100644 --- a/examples/sn-dms-demo/src/components/ActionMenu/AddNewMenu.tsx +++ b/examples/sn-dms-demo/src/components/ActionMenu/AddNewMenu.tsx @@ -120,7 +120,7 @@ class AddNewMenu extends React.Component< ) } public render() { - return ) => this.handleButtonClick(e)} /> + return this.handleButtonClick(e)} /> } } diff --git a/examples/sn-dms-demo/src/components/BreadCrumb.tsx b/examples/sn-dms-demo/src/components/BreadCrumb.tsx index affccd84c..d0fbfbcb2 100644 --- a/examples/sn-dms-demo/src/components/BreadCrumb.tsx +++ b/examples/sn-dms-demo/src/components/BreadCrumb.tsx @@ -141,7 +141,7 @@ class BreadCrumb extends React.Component< ) : ( ) => this.handleActionMenuClick(e, ancestor)} + onClick={e => this.handleActionMenuClick(e, ancestor)} type={iconType.materialui} iconName={icons.arrowDropDown} /> @@ -150,7 +150,7 @@ class BreadCrumb extends React.Component< {!isLast ? ( ) => this.handleActionMenuClick(e, ancestor)} + onClick={e => this.handleActionMenuClick(e, ancestor)} type={iconType.materialui} iconName={icons.arrowRight} /> diff --git a/examples/sn-dms-demo/src/components/Dialogs/VersionsDialog.tsx b/examples/sn-dms-demo/src/components/Dialogs/VersionsDialog.tsx index 53e898744..55d991c31 100644 --- a/examples/sn-dms-demo/src/components/Dialogs/VersionsDialog.tsx +++ b/examples/sn-dms-demo/src/components/Dialogs/VersionsDialog.tsx @@ -240,7 +240,7 @@ class VersionsDialog extends React.Component< - {versions.map((version, index: number) => ( + {versions.map((version, index) => ( {this.formatVersionNumber(version.Version || '')} @@ -286,7 +286,7 @@ class VersionsDialog extends React.Component< ) : ( {resources.VERSIONS} - {versions.map((version, index: number) => ( + {versions.map((version, index) => ( e.messageEntry), getBulkMessageKey) - const msgSegments: MessageBarState['digestedMessageEntries'] = [...lastState.digestedMessageEntries] + const msgSegments = [...lastState.digestedMessageEntries] for (const type in grouped) { if (grouped[type]) { const groupedEntries = grouped[type] diff --git a/examples/sn-dms-demo/src/components/Pickers/PathPicker.tsx b/examples/sn-dms-demo/src/components/Pickers/PathPicker.tsx index dc86aa0ef..af8f5d6c6 100644 --- a/examples/sn-dms-demo/src/components/Pickers/PathPicker.tsx +++ b/examples/sn-dms-demo/src/components/Pickers/PathPicker.tsx @@ -192,7 +192,7 @@ class PathPicker extends React.Component< type={iconType.materialui} iconName="keyboard_arrow_right" style={this.isHovered ? styles.openIcon : { display: 'none' }} - onClick={(e: React.MouseEvent) => this.handleClick(e, item)} + onClick={e => this.handleClick(e, item)} /> ) : null} diff --git a/examples/sn-dms-demo/src/components/Upload/UploadButton.tsx b/examples/sn-dms-demo/src/components/Upload/UploadButton.tsx index 2993e558b..b9f85052d 100644 --- a/examples/sn-dms-demo/src/components/Upload/UploadButton.tsx +++ b/examples/sn-dms-demo/src/components/Upload/UploadButton.tsx @@ -39,9 +39,9 @@ export interface UploadButtonState { anchorElement: HTMLElement | undefined } -export const UPLOAD_FILE_BUTTON_ID: string = 'sn-dms-upload-button' -export const UPLOAD_FOLDER_BUTTON_ID: string = 'sn-dms-upload-button' -export const UPLOAD_MENU_ID: string = 'sn-dms-upload-button' +export const UPLOAD_FILE_BUTTON_ID = 'sn-dms-upload-button' +export const UPLOAD_FOLDER_BUTTON_ID = 'sn-dms-upload-button' +export const UPLOAD_MENU_ID = 'sn-dms-upload-button' export class UploadButton extends React.Component { private readonly uploadFileButtonId = `${UPLOAD_FILE_BUTTON_ID}-${v1()}` diff --git a/examples/sn-dms-demo/src/pages/Dashboard.tsx b/examples/sn-dms-demo/src/pages/Dashboard.tsx index a6bc98258..afb07f8b8 100644 --- a/examples/sn-dms-demo/src/pages/Dashboard.tsx +++ b/examples/sn-dms-demo/src/pages/Dashboard.tsx @@ -160,6 +160,7 @@ class DashboardComponent extends React.Component< ) => ( @@ -222,6 +223,7 @@ class DashboardComponent extends React.Component< ) => ( @@ -248,6 +250,7 @@ class DashboardComponent extends React.Component< /> ) => ( ({ export const initLog = createAction(() => ({ type: 'SN_DMS_INIT_LOG', + // tslint:disable-next-line: no-unnecessary-type-annotation inject: async (options: IInjectableActionCallbackParams) => { const repository = options.getInjectable(Repository) const eventHub = new EventHub(repository) diff --git a/examples/sn-dms-demo/src/store/documentlibrary/actions.ts b/examples/sn-dms-demo/src/store/documentlibrary/actions.ts index 60ec3f96f..b10c1ca11 100644 --- a/examples/sn-dms-demo/src/store/documentlibrary/actions.ts +++ b/examples/sn-dms-demo/src/store/documentlibrary/actions.ts @@ -30,6 +30,7 @@ export const finishLoadingChildren = createAction(() => ({ export const loadParent = createAction( (idOrPath: number | string, loadParentOptions?: ODataParams) => ({ type: 'DMS_DOCLIB_LOAD_PARENT', + // tslint:disable-next-line: no-unnecessary-type-annotation inject: async (options: IInjectableActionCallbackParams) => { const prevState = options.getState().dms.documentLibrary if (prevState.parentIdOrPath === idOrPath) { @@ -119,6 +120,7 @@ export const loadParent = createAction( export const loadMore = createAction((count: number = loadChunkSize) => ({ type: 'DMS_DOCLIB_LOAD_MORE', + // tslint:disable-next-line: no-unnecessary-type-annotation inject: async (options: IInjectableActionCallbackParams) => { const currentDocLibState = options.getState().dms.documentLibrary @@ -187,6 +189,7 @@ export const setActive = createAction((active?: T) => export const updateChildrenOptions = createAction((odataOptions: ODataParams) => ({ type: 'DMS_DOCLIB_UPDATE_CHILDREN_OPTIONS', odataOptions, + // tslint:disable-next-line: no-unnecessary-type-annotation inject: async (options: IInjectableActionCallbackParams) => { const currentState = options.getState() const parentPath = currentState.dms.documentLibrary.parent ? currentState.dms.documentLibrary.parent.Path : '' diff --git a/examples/sn-dms-demo/src/store/edited/reducers.ts b/examples/sn-dms-demo/src/store/edited/reducers.ts index 4cbabc47b..e91ee8f9b 100644 --- a/examples/sn-dms-demo/src/store/edited/reducers.ts +++ b/examples/sn-dms-demo/src/store/edited/reducers.ts @@ -2,10 +2,7 @@ import { GenericContent } from '@sensenet/default-content-types' import { loadContent, PromiseReturns } from '@sensenet/redux/dist/Actions' import { AnyAction, Reducer } from 'redux' -export const editedContent: Reducer = ( - state: GenericContent | null = null, - action: AnyAction, -) => { +export const editedContent: Reducer = (state = null, action: AnyAction) => { switch (action.type) { case 'LOAD_EDITED_CONTENT_SUCCESS': return (action.result as PromiseReturns).d diff --git a/examples/sn-dms-demo/src/store/picker/reducers.ts b/examples/sn-dms-demo/src/store/picker/reducers.ts index c74c7cb11..4369599fd 100644 --- a/examples/sn-dms-demo/src/store/picker/reducers.ts +++ b/examples/sn-dms-demo/src/store/picker/reducers.ts @@ -3,7 +3,7 @@ import { createContent, PromiseReturns } from '@sensenet/redux/dist/Actions' import { AnyAction, combineReducers, Reducer } from 'redux' import { loadPickerItems, loadPickerParent } from './actions' -export const pickerIsOpened: Reducer = (state: boolean = false, action: AnyAction) => { +export const pickerIsOpened: Reducer = (state = false, action: AnyAction) => { switch (action.type) { case 'OPEN_PICKER': return true @@ -14,7 +14,7 @@ export const pickerIsOpened: Reducer = (state: boolean = false, action: } } -export const pickerOnClose: Reducer = (state: any = null, action: AnyAction) => { +export const pickerOnClose: Reducer = (state = null, action: AnyAction) => { switch (action.type) { case 'OPEN_PICKER': return action.onClose @@ -25,10 +25,7 @@ export const pickerOnClose: Reducer = (state: any = null, action: AnyAction } } -export const pickerContent: Reducer = ( - state: GenericContent | null = null, - action: AnyAction, -) => { +export const pickerContent: Reducer = (state = null, action: AnyAction) => { switch (action.type) { case 'OPEN_PICKER': return action.content @@ -54,7 +51,7 @@ export const pickerParent: Reducer = ( } } -export const pickerItems: Reducer = (state: GenericContent[] = [], action: AnyAction) => { +export const pickerItems: Reducer = (state = [], action: AnyAction) => { switch (action.type) { case 'LOAD_PICKER_ITEMS_SUCCESS': return (action.result as PromiseReturns).d.results @@ -66,7 +63,7 @@ export const pickerItems: Reducer = (state: GenericContent[] = } } -export const pickerSelected: Reducer = (state: GenericContent[] = [], action: AnyAction) => { +export const pickerSelected: Reducer = (state = [], action: AnyAction) => { switch (action.type) { case 'SELECT_PICKER_ITEM': return action.content ? [action.content] : [] @@ -77,7 +74,7 @@ export const pickerSelected: Reducer = (state: GenericContent[ } } -export const pickerMode: Reducer = (state: string = 'move', action: AnyAction) => { +export const pickerMode: Reducer = (state = 'move', action: AnyAction) => { switch (action.type) { case 'OPEN_PICKER': return action.mode @@ -86,10 +83,7 @@ export const pickerMode: Reducer = (state: string = 'move', action: AnyA } } -export const closestWorkspace: Reducer = ( - state: GenericContent | null = null, - action: AnyAction, -) => { +export const closestWorkspace: Reducer = (state = null, action: AnyAction) => { switch (action.type) { case 'SET_PICKER_PARENT': return action.content.Workspace.Path @@ -101,7 +95,7 @@ export const closestWorkspace: Reducer = ( } } -export const backLink: Reducer = (state: boolean = true, action: AnyAction) => { +export const backLink: Reducer = (state = true, action: AnyAction) => { switch (action.type) { case 'SET_BACKLINK': return action.state diff --git a/examples/sn-dms-demo/src/store/queries.ts b/examples/sn-dms-demo/src/store/queries.ts index 288d014ec..c7b1eb404 100644 --- a/examples/sn-dms-demo/src/store/queries.ts +++ b/examples/sn-dms-demo/src/store/queries.ts @@ -1,4 +1,4 @@ -import { ODataBatchResponse, ODataParams, Repository } from '@sensenet/client-core' +import { ODataParams, Repository } from '@sensenet/client-core' import { Query } from '@sensenet/default-content-types' import { createAction, isFromAction } from '@sensenet/redux' import { deleteContent, PromiseReturns, updateContent } from '@sensenet/redux/dist/Actions' @@ -11,6 +11,7 @@ export type QueryType = 'Private' | 'Public' | 'NonDefined' export const saveQuery = createAction( (idOrPath: string | number, query: string, displayName: string, queryType = 'Private') => ({ type: 'SN_DMS_SAVE_QUERY', + // tslint:disable-next-line: no-unnecessary-type-annotation inject: async (options: IInjectableActionCallbackParams) => { const repo = options.getInjectable(Repository) await repo.executeAction({ @@ -30,6 +31,7 @@ export const saveQuery = createAction( export const getQueries = createAction((idOrPath: string | number, queryType = 'Private', force: boolean = false) => ({ type: 'SN_DMS_GET_QUERIES', + // tslint:disable-next-line: no-unnecessary-type-annotation inject: async (options: IInjectableActionCallbackParams) => { const state = options.getState() if (force === false && state.dms.queries.idOrPath === idOrPath && state.dms.queries.queryType === queryType) { @@ -37,7 +39,7 @@ export const getQueries = createAction((idOrPath: string | number, queryType = ' } options.dispatch(queriesRequested(idOrPath, queryType)) const repo = options.getInjectable(Repository) - const q: ODataBatchResponse = await repo.executeAction({ + const q = await repo.executeAction({ idOrPath, name: 'GetQueries', method: 'GET', diff --git a/examples/sn-dms-demo/src/store/usersandgroups/actions.ts b/examples/sn-dms-demo/src/store/usersandgroups/actions.ts index 10dcf6332..403d0bf0f 100644 --- a/examples/sn-dms-demo/src/store/usersandgroups/actions.ts +++ b/examples/sn-dms-demo/src/store/usersandgroups/actions.ts @@ -238,7 +238,7 @@ export const getGroups = (memberships: ODataCollectionResponse) => ({ expand: ['Actions'] as any, }, }) - const comparedList: Group[] = arrayDiff(groups.d.results, memberships.d.results) + const comparedList = arrayDiff(groups.d.results, memberships.d.results) const newGroups = { d: { __count: comparedList.length, diff --git a/examples/sn-dms-demo/src/store/usersandgroups/reducers.ts b/examples/sn-dms-demo/src/store/usersandgroups/reducers.ts index 15e5e1c6f..55bc908eb 100644 --- a/examples/sn-dms-demo/src/store/usersandgroups/reducers.ts +++ b/examples/sn-dms-demo/src/store/usersandgroups/reducers.ts @@ -12,7 +12,7 @@ export const currentUser: Reducer = (state: User | null = null } export const memberships: Reducer> = ( - state: ODataCollectionResponse = { d: { __count: 0, results: [] } }, + state = { d: { __count: 0, results: [] } }, action: AnyAction, ) => { switch (action.type) { @@ -25,7 +25,7 @@ export const memberships: Reducer> = ( } } -export const error: Reducer = (state: any = null, action: AnyAction) => { +export const error: Reducer = (state = null, action: AnyAction) => { switch (action.type) { case 'DMS_USERSANDGROUPS_SET_ERROR': return action.error @@ -33,7 +33,7 @@ export const error: Reducer = (state: any = null, action: AnyAction) => { return state } } -export const isLoading: Reducer = (state: boolean = false, action: AnyAction) => { +export const isLoading: Reducer = (state = false, action: AnyAction) => { switch (action.type) { case 'DMS_USERSANDGROUPS_LOADING': return true @@ -44,7 +44,7 @@ export const isLoading: Reducer = (state: boolean = false, action: AnyA } } -export const isAdmin: Reducer = (state: boolean = false, action: AnyAction) => { +export const isAdmin: Reducer = (state = false, action: AnyAction) => { switch (action.type) { case 'DMS_USER_ISADMIN': return action.admin @@ -53,7 +53,7 @@ export const isAdmin: Reducer = (state: boolean = false, action: AnyAct } } -export const ancestors: Reducer = (state: GenericContent[] = [], action: AnyAction) => { +export const ancestors: Reducer = (state = [], action: AnyAction) => { switch (action.type) { case 'DMS_USERSANDGROUPS_SET_ANCESTORS': return action.ancestors @@ -62,7 +62,7 @@ export const ancestors: Reducer = (state: GenericContent[] = [ } } -export const selected: Reducer = (state: GenericContent[] = [], action: AnyAction) => { +export const selected: Reducer = (state = [], action: AnyAction) => { switch (action.type) { case 'DMS_USERSANDGROUPS_SET_ANCESTORS': return action.ancestors @@ -94,10 +94,7 @@ const defaultOptions = { top: loadChunkSize, } as ODataParams -export const grouplistOptions: Reducer> = ( - state: ODataParams = defaultOptions, - action: AnyAction, -) => { +export const grouplistOptions: Reducer> = (state = defaultOptions, action: AnyAction) => { switch (action.type) { case 'DMS_USERSANDGROUPS_SET_CHILDREN_OPTIONS': return action.odataOptions @@ -106,7 +103,7 @@ export const grouplistOptions: Reducer> = ( } } -export const active: Reducer = (state: GenericContent | null = null, action: AnyAction) => { +export const active: Reducer = (state = null, action: AnyAction) => { switch (action.type) { case 'DMS_USERSANDGROUPS_SET_ACTIVE': return action.active @@ -127,7 +124,7 @@ export const user = combineReducers({ active, }) -export const selectedGroups: Reducer = (state: GenericContent[] = [], action: AnyAction) => { +export const selectedGroups: Reducer = (state = [], action: AnyAction) => { switch (action.type) { case 'DMS_USERSANDGROUPS_SELECT_GROUP': return [...action.groups] @@ -142,7 +139,7 @@ export const selectedGroups: Reducer = (state: GenericContent[ } } -export const all: Reducer = (state: GenericContent[] = [], action: AnyAction) => { +export const all: Reducer = (state = [], action: AnyAction) => { switch (action.type) { case 'DMS_USERSANDGROUPS_SET_GROUPS': return action.groups.d.results @@ -151,7 +148,7 @@ export const all: Reducer = (state: GenericContent[] = [], act } } -export const searchTerm: Reducer = (state: string = '', action: AnyAction) => { +export const searchTerm: Reducer = (state = '', action: AnyAction) => { switch (action.type) { case 'DMS_USERSANDGROUPS_SEARCH_GROUPS': return action.text diff --git a/examples/sn-dms-demo/src/store/workspaces/reducers.ts b/examples/sn-dms-demo/src/store/workspaces/reducers.ts index 1e799d0ea..ca268a0f9 100644 --- a/examples/sn-dms-demo/src/store/workspaces/reducers.ts +++ b/examples/sn-dms-demo/src/store/workspaces/reducers.ts @@ -2,7 +2,7 @@ import { Workspace } from '@sensenet/default-content-types' import { AnyAction, combineReducers, Reducer } from 'redux' import { setFavoriteWorkspaces, setWorkspaces } from './actions' -export const allWorkspaces: Reducer = (state: Workspace[] = [], action: AnyAction) => { +export const allWorkspaces: Reducer = (state = [], action: AnyAction) => { switch (action.type) { case 'SET_WORKSPACES': return (action as ReturnType).workspaces @@ -11,7 +11,7 @@ export const allWorkspaces: Reducer = (state: Workspace[] = [], act } } -export const favorites: Reducer = (state: number[] = [], action: AnyAction) => { +export const favorites: Reducer = (state = [], action: AnyAction) => { switch (action.type) { case 'SET_FAVORITE_WORKSPACES': const items = (action as ReturnType).workspaces @@ -25,7 +25,7 @@ export const favorites: Reducer = (state: number[] = [], action: AnyAc } } -export const searchTerm: Reducer = (state: string = '', action: AnyAction) => { +export const searchTerm: Reducer = (state = '', action: AnyAction) => { switch (action.type) { case 'SEARCH_WORKSPACES': return action.text @@ -34,7 +34,7 @@ export const searchTerm: Reducer = (state: string = '', action: AnyActio } } -export const isLoading: Reducer = (state: boolean = false, action: AnyAction) => { +export const isLoading: Reducer = (state = false, action: AnyAction) => { switch (action.type) { case 'LOAD_WORKSPACES': return true diff --git a/package.json b/package.json index 8efcd29d0..b7d3c4b9a 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "tslint": "^5.12.1", "tslint-config-prettier": "^1.17.0", "tslint-react": "^3.6.0", + "tslint-consistent-codestyle": "1.15.0", "typescript": "3.3.1" }, "scripts": { diff --git a/packages/sn-authentication-jwt/src/JwtService.ts b/packages/sn-authentication-jwt/src/JwtService.ts index b66157815..02040fcc1 100644 --- a/packages/sn-authentication-jwt/src/JwtService.ts +++ b/packages/sn-authentication-jwt/src/JwtService.ts @@ -185,7 +185,7 @@ export class JwtService implements AuthenticationService { try { await this.updateLock.acquire() this.state.setValue(LoginState.Pending) - const authToken: string = Buffer.from(`${username}:${password}`).toString('base64') + const authToken = Buffer.from(`${username}:${password}`).toString('base64') const response = await this.repository.fetch( PathHelper.joinPaths(this.repository.configuration.repositoryUrl, 'sn-token/login'), { diff --git a/packages/sn-client-core/src/Repository/Repository.ts b/packages/sn-client-core/src/Repository/Repository.ts index 940933e79..d8293e0ca 100644 --- a/packages/sn-client-core/src/Repository/Repository.ts +++ b/packages/sn-client-core/src/Repository/Repository.ts @@ -88,7 +88,7 @@ export class Repository implements Disposable { * @param response The Response object to extract the message */ public async getErrorFromResponse(response: Response): Promise { - let msgFromBody: string = '' + let msgFromBody = '' let body: any = {} try { body = await response.json() diff --git a/packages/sn-client-core/src/Repository/Upload.ts b/packages/sn-client-core/src/Repository/Upload.ts index bbe9b13ef..2c8511cea 100644 --- a/packages/sn-client-core/src/Repository/Upload.ts +++ b/packages/sn-client-core/src/Repository/Upload.ts @@ -305,7 +305,7 @@ export class Upload { */ public static async fromDropEvent(options: UploadFromEventOptions) { if ((window as any).webkitRequestFileSystem) { - const entries: Array = options.event.dataTransfer + const entries = options.event.dataTransfer ? ([].map.call(options.event.dataTransfer.items, (i: DataTransferItem) => i.webkitGetAsEntry()) as Array< WebKitFileEntry | WebKitDirectoryEntry >) @@ -314,6 +314,8 @@ export class Upload { } else { // Fallback for non-webkit browsers. options.event.dataTransfer && + options.event.dataTransfer.files && + // tslint:disable-next-line: no-unnecessary-type-annotation [].forEach.call(options.event.dataTransfer.files, async (f: File) => { if (f.type === 'file') { return await Upload.file({ diff --git a/packages/sn-control-mapper/src/ControlMapper.ts b/packages/sn-control-mapper/src/ControlMapper.ts index d187d6303..76ee6f13c 100644 --- a/packages/sn-control-mapper/src/ControlMapper.ts +++ b/packages/sn-control-mapper/src/ControlMapper.ts @@ -66,7 +66,7 @@ export class ControlMapper { private fieldSettingDefaults: Map< string, - ((fieldSetting: FieldSetting) => new (...args: any[]) => TControlBaseType) + (fieldSetting: FieldSetting) => new (...args: any[]) => TControlBaseType > = new Map() /** @@ -101,7 +101,7 @@ export class ControlMapper { private contentTypeBoundfieldSettings: Map< string, - ((fieldSetting: FieldSetting) => new (...args: any[]) => TControlBaseType) + (fieldSetting: FieldSetting) => new (...args: any[]) => TControlBaseType > = new Map() /** @@ -149,7 +149,7 @@ export class ControlMapper { private fieldSettingBoundClientSettingFactories: Map< string, - ((setting: FieldSetting) => TClientControlSettings) + (setting: FieldSetting) => TClientControlSettings > = new Map() /** @@ -188,12 +188,8 @@ export class ControlMapper { ): ControlSchema { const schema = this.getTypeSchema(contentTypeName, actionName) const mappings = schema.FieldSettings.map(f => { - const clientSetting: TClientControlSettings = this.createClientSetting(f) - const control: new (...args: any[]) => TControlBaseType = this.getControlForContentField( - contentTypeName, - f.Name, - actionName, - ) + const clientSetting = this.createClientSetting(f) + const control = this.getControlForContentField(contentTypeName, f.Name, actionName) return { fieldSettings: f, clientSettings: clientSetting, diff --git a/packages/sn-document-viewer-react/src/ExampleAppLayout.tsx b/packages/sn-document-viewer-react/src/ExampleAppLayout.tsx index d20cb6f85..919bc9b66 100644 --- a/packages/sn-document-viewer-react/src/ExampleAppLayout.tsx +++ b/packages/sn-document-viewer-react/src/ExampleAppLayout.tsx @@ -41,7 +41,7 @@ import { Share } from './components/document-widgets/ShareWidget' /** * Adds a globally unique ID to the shape */ -const addGuidToShape: (shape: T) => T = shape => { +const addGuidToShape = (shape: T) => { shape.guid = v1() return shape } @@ -73,7 +73,7 @@ const mapDispatchToProps = {} /** * Settings object for the Document Viewer Example component */ -export const exampleSettings: DocumentViewerSettings = new DocumentViewerSettings({ +export const exampleSettings = new DocumentViewerSettings({ canEditDocument: async documentData => { const response = await fetch( `${encodeURI(documentData.hostName)}/odata.svc/${encodeURI( @@ -148,7 +148,7 @@ export const exampleSettings: DocumentViewerSettings = new DocumentViewerSetting } return allPreviews }, - isPreviewAvailable: async (documentData, version, page: number) => { + isPreviewAvailable: async (documentData, version, page) => { const response = await fetch( `${documentData.hostName}/odata.svc/${documentData.idOrPath}/PreviewAvailable?version=${version}`, { diff --git a/packages/sn-document-viewer-react/src/components/PageList.tsx b/packages/sn-document-viewer-react/src/components/PageList.tsx index cd1beccd2..a97803db8 100644 --- a/packages/sn-document-viewer-react/src/components/PageList.tsx +++ b/packages/sn-document-viewer-react/src/components/PageList.tsx @@ -150,8 +150,8 @@ export class PageListComponent extends React.Component< }) const scrollState = (this.viewPort && this.viewPort.scrollTop) || 0 - let marginTop: number = 0 - let pagesToSkip: number = 0 + let marginTop = 0 + let pagesToSkip = 0 while ( pageNo !== undefined @@ -162,15 +162,15 @@ export class PageListComponent extends React.Component< pagesToSkip++ } - let pagesToTake: number = 1 - let pagesHeight: number = 0 + let pagesToTake = 1 + let pagesHeight = 0 while (pages[pagesToSkip + pagesToTake] && pagesHeight < this.state.viewportHeight + props.tolerance) { pagesHeight += pages[pagesToSkip + pagesToTake].Height + props.padding * 2 pagesToTake++ } - let marginBottom: number = 0 + let marginBottom = 0 for (let i = pagesToSkip + pagesToTake - 1; i < pages.length - 1; i++) { marginBottom += pages[i].Height + props.padding * 2 } diff --git a/packages/sn-document-viewer-react/src/models/DocumentViewerSettings.ts b/packages/sn-document-viewer-react/src/models/DocumentViewerSettings.ts index 15bceae87..6bf0cc65d 100644 --- a/packages/sn-document-viewer-react/src/models/DocumentViewerSettings.ts +++ b/packages/sn-document-viewer-react/src/models/DocumentViewerSettings.ts @@ -28,9 +28,11 @@ export interface DocumentViewerSettingsOptions { * Callback that will return with the retrieved DocumentData (if available) */ - getDocumentData: ( - document: { idOrPath: number | string; hostName: string; version?: string }, - ) => Promise + getDocumentData: (document: { + idOrPath: number | string + hostName: string + version?: string + }) => Promise /** * Callback that will return with the retrieved PreviewImageData array @@ -60,9 +62,11 @@ export class DocumentViewerSettings implements DocumentViewerSettingsOptions { public saveChanges!: (document: DocumentData, pages: PreviewImageData[]) => Promise public canHideWatermark!: (document: DocumentData) => Promise public canHideRedaction!: (document: DocumentData) => Promise - public getDocumentData!: ( - document: { idOrPath: string | number; hostName: string; version?: string }, - ) => Promise + public getDocumentData!: (document: { + idOrPath: string | number + hostName: string + version?: string + }) => Promise public getExistingPreviewImages!: ( document: DocumentData, version: string, diff --git a/packages/sn-document-viewer-react/src/store/Localization.ts b/packages/sn-document-viewer-react/src/store/Localization.ts index da894f8d4..47ebce1f8 100644 --- a/packages/sn-document-viewer-react/src/store/Localization.ts +++ b/packages/sn-document-viewer-react/src/store/Localization.ts @@ -106,10 +106,7 @@ export const setLocalization = (localization: Partial) => * @param state the current state * @param action the action to dispatch */ -export const localizationReducer: Reducer = ( - state: LocalizationStateType = defaultLocalization, - action, -) => { +export const localizationReducer: Reducer = (state = defaultLocalization, action) => { switch (action.type) { case 'SN_DOCVIEWER_SET_LOCALIZATION': { return { diff --git a/packages/sn-document-viewer-react/src/store/RootReducer.ts b/packages/sn-document-viewer-react/src/store/RootReducer.ts index 2416049d7..caf444469 100644 --- a/packages/sn-document-viewer-react/src/store/RootReducer.ts +++ b/packages/sn-document-viewer-react/src/store/RootReducer.ts @@ -1,5 +1,4 @@ import { combineReducers } from 'redux' -import { Reducer } from 'redux' import { documentStateReducer, DocumentStateType } from './Document' import { localizationReducer, LocalizationStateType } from './Localization' @@ -36,7 +35,7 @@ export interface RootReducerType { /** * The root reducer instance with the sensenetDocumentViewer reducer instance */ -export const rootReducer: Reducer = combineReducers({ +export const rootReducer = combineReducers({ sensenetDocumentViewer: combineReducers({ documentState: documentStateReducer, previewImages: previewImagesReducer, diff --git a/packages/sn-document-viewer-react/src/store/index.ts b/packages/sn-document-viewer-react/src/store/index.ts index 9bab6c6e0..5ce7086d4 100644 --- a/packages/sn-document-viewer-react/src/store/index.ts +++ b/packages/sn-document-viewer-react/src/store/index.ts @@ -1,7 +1,5 @@ import { compose, Store } from 'redux' import { Action, applyMiddleware, createStore } from 'redux' -import { Reducer } from 'redux' -import { StoreEnhancer } from 'redux' import { ReduxDiMiddleware } from 'redux-di-middleware' import { DocumentViewerSettings } from '../models' import { rootReducer, RootReducerType } from './RootReducer' @@ -10,11 +8,7 @@ import { rootReducer, RootReducerType } from './RootReducer' * gets a configuration object for the Store instance * @param {DocumentViewerSettings} settings The Settings object for the document viewer instance */ -export const getStoreConfig: ( - settings: DocumentViewerSettings, -) => { rootReducer: Reducer; preloadedState: RootReducerType; enhancer: StoreEnhancer } = ( - settings: DocumentViewerSettings, -) => { +export const getStoreConfig = (settings: DocumentViewerSettings) => { const di = new ReduxDiMiddleware() di.setInjectable(settings) return { @@ -30,9 +24,7 @@ const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || * returns a Store object for a Document Viewer instance * @param {DocumentViewerSettings} settings The Settings object for the document viewer instance */ -export const configureStore: (settings: DocumentViewerSettings) => Store = ( - settings: DocumentViewerSettings, -) => { +export const configureStore: (settings: DocumentViewerSettings) => Store = settings => { const config = getStoreConfig(settings) return createStore(config.rootReducer, config.preloadedState, config.enhancer) } diff --git a/packages/sn-icons-react/src/components/Icon.tsx b/packages/sn-icons-react/src/components/Icon.tsx index f62607846..2c4379fde 100644 --- a/packages/sn-icons-react/src/components/Icon.tsx +++ b/packages/sn-icons-react/src/components/Icon.tsx @@ -87,7 +87,7 @@ export class Icon extends React.Component { classes={classes} iconName={iconName} style={style} - onClick={onClick ? (e: React.MouseEvent) => onClick(e) : undefined} + onClick={onClick ? e => onClick(e) : undefined} className={className}> {this.props.children ? this.props.children : null} @@ -100,7 +100,7 @@ export class Icon extends React.Component { classes={classes} iconName={iconName} style={style} - onClick={onClick ? (e: React.MouseEvent) => onClick(e) : undefined}> + onClick={onClick ? e => onClick(e) : undefined}> {this.props.children ? this.props.children : null} ) @@ -112,14 +112,13 @@ export class Icon extends React.Component { classes={classes} iconName={iconName} style={style} - onClick={onClick ? (e: React.MouseEvent) => onClick(e) : undefined}> + onClick={onClick ? e => onClick(e) : undefined}> {this.props.children ? this.props.children : null} ) case iconType.image: return ( - ) => onClick(e) : undefined}> + onClick(e) : undefined}> {this.props.children ? this.props.children : null} ) @@ -131,7 +130,7 @@ export class Icon extends React.Component { fontSize={fontSize ? fontSize : 'default'} classes={classes ? classes : null} className={className} - onClick={onClick ? (e: React.MouseEvent) => onClick(e) : undefined} + onClick={onClick ? e => onClick(e) : undefined} style={style} /> ) diff --git a/packages/sn-redux/src/Store.ts b/packages/sn-redux/src/Store.ts index 778c079d7..3df9bb4b1 100644 --- a/packages/sn-redux/src/Store.ts +++ b/packages/sn-redux/src/Store.ts @@ -28,7 +28,7 @@ */ import { Repository } from '@sensenet/client-core' import { promiseMiddleware } from '@sensenet/redux-promise-middleware' -import { applyMiddleware, compose, createStore, DeepPartial, Middleware, Reducer, Store, StoreEnhancer } from 'redux' +import { applyMiddleware, compose, createStore, DeepPartial, Middleware, Reducer, StoreEnhancer } from 'redux' import { createLogger } from 'redux-logger' import * as Actions from './Actions' @@ -103,9 +103,7 @@ export interface CreateStoreOptions { * @param options {CreateStoreOptions} An object to hold config options of the Store. * @returns store {Store} Returns a preconfigured Redux store. */ -export const createSensenetStore: (options: CreateStoreOptions) => Store = ( - options: CreateStoreOptions, -) => { +export const createSensenetStore = (options: CreateStoreOptions) => { let middlewareArray: Array> = [] let enhancerArray: Array> = [] if (typeof options.middlewares === 'undefined' || options.middlewares === null) { @@ -137,7 +135,7 @@ export const createSensenetStore: (options: CreateStoreOptions) => Store { diff --git a/packages/sn-redux/src/reducers/currentitems.ts b/packages/sn-redux/src/reducers/currentitems.ts index 81bd74bc8..19b468534 100644 --- a/packages/sn-redux/src/reducers/currentitems.ts +++ b/packages/sn-redux/src/reducers/currentitems.ts @@ -56,10 +56,7 @@ export const ids: Reducer> = (st * @param action Represents an action that is called. * @returns state. Returns the next state based on the action. */ -export const entities: Reducer> = ( - state: GenericContent[] = [], - action, -) => { +export const entities: Reducer> = (state = [], action) => { switch (action.type) { case 'DELETE_CONTENT_SUCCESS': case 'DELETE_BATCH_SUCCESS': diff --git a/packages/sn-redux/src/reducers/selected.ts b/packages/sn-redux/src/reducers/selected.ts index 576d48232..82a10cc1f 100644 --- a/packages/sn-redux/src/reducers/selected.ts +++ b/packages/sn-redux/src/reducers/selected.ts @@ -32,7 +32,7 @@ export const selectedContentItems: Reducer< > = (state = {}, action) => { switch (action.type) { case 'DESELECT_CONTENT': - const res: any = Object.assign({}, state) + const res = Object.assign({}, state) delete res[(action as ReturnType).content.Id] return res case 'SELECT_CONTENT': diff --git a/packages/sn-search-react/src/Components/Fields/TypeField.tsx b/packages/sn-search-react/src/Components/Fields/TypeField.tsx index 02545a5b5..0c7e504a2 100644 --- a/packages/sn-search-react/src/Components/Fields/TypeField.tsx +++ b/packages/sn-search-react/src/Components/Fields/TypeField.tsx @@ -41,7 +41,7 @@ export class TypeField extends Component { name: '', selected: this.props.selectedTypes || [], schemas: [], - getMenuItem: (schema: Schema, isSelected: boolean) => ( + getMenuItem: (schema, isSelected) => ( diff --git a/tslint.json b/tslint.json index cff693c33..5a2d75bf7 100644 --- a/tslint.json +++ b/tslint.json @@ -1,6 +1,6 @@ { "defaultSeverity": "error", - "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"], + "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier", "tslint-consistent-codestyle"], "rules": { "jsx-no-lambda": false, "arrow-parens": [true, "ban-single-arg-parens"], @@ -8,6 +8,7 @@ "object-literal-sort-keys": [false], "no-unused-expression": [true, "allow-fast-null-checks"], "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"], + "no-unnecessary-type-annotation": true, "completed-docs": [ true, { diff --git a/yarn.lock b/yarn.lock index 23cffe988..726446320 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1145,6 +1145,25 @@ resolved "https://registry.yarnpkg.com/@emotion/weak-memoize/-/weak-memoize-0.1.3.tgz#b700d97385fa91affed60c71dfd51c67e9dad762" integrity sha512-QsYGKdhhuDFNq7bjm2r44y0mp5xW3uO3csuTPDWZc0OIiMQv+AIY5Cqwd4mJiC5N8estVl7qlvOx1hbtOuUWbw== +"@fimbul/bifrost@^0.17.0": + version "0.17.0" + resolved "https://registry.yarnpkg.com/@fimbul/bifrost/-/bifrost-0.17.0.tgz#f0383ba7e40992e3193dc87e2ddfde2ad62a9cf4" + integrity sha512-gVTkJAOef5HtN6LPmrtt5fAUmBywwlgmObsU3FBhPoNeXPLaIl2zywXkJEtvvVLQnaFmtff3x+wIj5lHRCDE3Q== + dependencies: + "@fimbul/ymir" "^0.17.0" + get-caller-file "^2.0.0" + tslib "^1.8.1" + tsutils "^3.5.0" + +"@fimbul/ymir@^0.17.0": + version "0.17.0" + resolved "https://registry.yarnpkg.com/@fimbul/ymir/-/ymir-0.17.0.tgz#4f28389b9f804d1cd202e11983af1743488b7815" + integrity sha512-xMXM9KTXRLHLVS6dnX1JhHNEkmWHcAVCQ/4+DA1KKwC/AFnGHzu/7QfQttEPgw3xplT+ILf9e3i64jrFwB3JtA== + dependencies: + inversify "^5.0.0" + reflect-metadata "^0.1.12" + tslib "^1.8.1" + "@furystack/inject@^1.0.9": version "1.0.9" resolved "https://registry.yarnpkg.com/@furystack/inject/-/inject-1.0.9.tgz#dbf286a63d66461a40023b95de77b2e65d7df55a" @@ -6870,6 +6889,11 @@ get-caller-file@^1.0.1: resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== +get-caller-file@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.1.tgz#25835260d3a2b9665fcdbb08cb039a7bbf7011c0" + integrity sha512-SpOZHfz845AH0wJYVuZk2jWDqFmu7Xubsx+ldIpwzy5pDUpu7OJHK7QYNSA2NPlDSKQwM1GFaAkciOWjjW92Sg== + get-own-enumerable-property-symbols@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.0.tgz#b877b49a5c16aefac3655f2ed2ea5b684df8d203" @@ -7838,6 +7862,11 @@ invariant@^2.2.1, invariant@^2.2.2, invariant@^2.2.4: dependencies: loose-envify "^1.0.0" +inversify@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/inversify/-/inversify-5.0.1.tgz#500d709b1434896ce5a0d58915c4a4210e34fb6e" + integrity sha512-Ieh06s48WnEYGcqHepdsJUIJUXpwH5o5vodAX+DK2JA/gjy4EbEcQZxw+uFfzysmKjiLXGYwNG3qDZsKVMcINQ== + invert-kv@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" @@ -13854,7 +13883,7 @@ ts-loader@^5.1.1: micromatch "^3.1.4" semver "^5.0.1" -tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: +tslib@^1.7.1, tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== @@ -13864,6 +13893,15 @@ tslint-config-prettier@^1.17.0: resolved "https://registry.yarnpkg.com/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz#75f140bde947d35d8f0d238e0ebf809d64592c37" integrity sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg== +tslint-consistent-codestyle@1.15.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/tslint-consistent-codestyle/-/tslint-consistent-codestyle-1.15.0.tgz#a3acf8d0a3ca0dc7d1285705102ba1fe4a17c4cb" + integrity sha512-6BNDBbZh2K0ibRXe70Mkl9gfVttxQ3t3hqV1BRDfpIcjrUoOgD946iH4SrXp+IggDgeMs3dJORjD5tqL5j4jXg== + dependencies: + "@fimbul/bifrost" "^0.17.0" + tslib "^1.7.1" + tsutils "^2.29.0" + tslint-loader@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/tslint-loader/-/tslint-loader-3.6.0.tgz#12ed4d5ef57d68be25cd12692fb2108b66469d76" @@ -13900,13 +13938,20 @@ tslint@^5.12.1: tslib "^1.8.0" tsutils "^2.27.2" -tsutils@^2.13.1, tsutils@^2.27.2: +tsutils@^2.13.1, tsutils@^2.27.2, tsutils@^2.29.0: version "2.29.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99" integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA== dependencies: tslib "^1.8.1" +tsutils@^3.5.0: + version "3.8.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.8.0.tgz#7a3dbadc88e465596440622b65c04edc8e187ae5" + integrity sha512-XQdPhgcoTbCD8baXC38PQ0vpTZ8T3YrE+vR66YIj/xvDt1//8iAhafpIT/4DmvzzC1QFapEImERu48Pa01dIUA== + dependencies: + tslib "^1.8.1" + tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" From 06516d3281437973557c6ffe34baf72189b06576 Mon Sep 17 00:00:00 2001 From: Gallay Lajos Date: Tue, 12 Feb 2019 16:06:03 +0100 Subject: [PATCH 2/5] fix(sn-dms-demo):queries reducer type --- examples/sn-dms-demo/src/store/queries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sn-dms-demo/src/store/queries.ts b/examples/sn-dms-demo/src/store/queries.ts index c7b1eb404..31e2eaf3f 100644 --- a/examples/sn-dms-demo/src/store/queries.ts +++ b/examples/sn-dms-demo/src/store/queries.ts @@ -39,7 +39,7 @@ export const getQueries = createAction((idOrPath: string | number, queryType = ' } options.dispatch(queriesRequested(idOrPath, queryType)) const repo = options.getInjectable(Repository) - const q = await repo.executeAction({ + const q = await repo.executeAction({ idOrPath, name: 'GetQueries', method: 'GET', From 52d63772efcc6b1eeacf365739de0e57b504a057 Mon Sep 17 00:00:00 2001 From: Gallay Lajos Date: Tue, 12 Feb 2019 16:14:44 +0100 Subject: [PATCH 3/5] chore(authentication-google): redundant typedef fix --- packages/sn-client-auth-google/src/GoogleOauthProvider.ts | 2 +- packages/sn-document-viewer-react/package.json | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/sn-client-auth-google/src/GoogleOauthProvider.ts b/packages/sn-client-auth-google/src/GoogleOauthProvider.ts index b08ea2db7..cde2e29ec 100644 --- a/packages/sn-client-auth-google/src/GoogleOauthProvider.ts +++ b/packages/sn-client-auth-google/src/GoogleOauthProvider.ts @@ -52,7 +52,7 @@ export class GoogleOauthProvider implements OauthProvider { }, ) if (request.ok) { - const loginResponse: LoginResponse = await request.json() + const loginResponse = await (request.json() as Promise) return this.jwtService.handleAuthenticationResponse(loginResponse) } else { throw Error(request.statusText) diff --git a/packages/sn-document-viewer-react/package.json b/packages/sn-document-viewer-react/package.json index c7363c99e..36813358f 100644 --- a/packages/sn-document-viewer-react/package.json +++ b/packages/sn-document-viewer-react/package.json @@ -63,6 +63,8 @@ "@material-ui/icons": "^3.0.1", "@sensenet/client-utils": "^1.4.2", "@sensenet/control-mapper": "^1.0.4", + "@sensenet/client-core": "^1.4.0", + "@sensenet/default-content-types": "1.1.2", "react": "^16.6.3", "react-dom": "^16.6.3", "react-redux": "^6.0.0", From 94cc64c45138af6cbedbcfd84a4852eee94ff5f1 Mon Sep 17 00:00:00 2001 From: Gallay Lajos Date: Tue, 12 Feb 2019 16:28:16 +0100 Subject: [PATCH 4/5] chore(sn-dms-demo):removed redundant typings --- examples/sn-dms-demo/src/Reducers.ts | 2 +- examples/sn-dms-demo/src/store/picker/reducers.ts | 5 +---- examples/sn-dms-demo/src/store/usersandgroups/actions.ts | 4 ++-- examples/sn-dms-demo/src/store/usersandgroups/reducers.ts | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/examples/sn-dms-demo/src/Reducers.ts b/examples/sn-dms-demo/src/Reducers.ts index ac07c02c6..1969306ee 100644 --- a/examples/sn-dms-demo/src/Reducers.ts +++ b/examples/sn-dms-demo/src/Reducers.ts @@ -268,7 +268,7 @@ export const addNewTypes: Reducer = (state = [], action: AnyActio } } -export const actionmenuContent: Reducer = (state: GenericContent | null = null, action: AnyAction) => { +export const actionmenuContent: Reducer = (state = null, action: AnyAction) => { switch (action.type) { case 'OPEN_ACTIONMENU': return action.content diff --git a/examples/sn-dms-demo/src/store/picker/reducers.ts b/examples/sn-dms-demo/src/store/picker/reducers.ts index 4369599fd..64751e920 100644 --- a/examples/sn-dms-demo/src/store/picker/reducers.ts +++ b/examples/sn-dms-demo/src/store/picker/reducers.ts @@ -36,10 +36,7 @@ export const pickerContent: Reducer = (state = null, acti } } -export const pickerParent: Reducer = ( - state: GenericContent | null = null, - action: AnyAction, -) => { +export const pickerParent: Reducer = (state = null, action: AnyAction) => { switch (action.type) { case 'SET_PICKER_PARENT': return action.content diff --git a/examples/sn-dms-demo/src/store/usersandgroups/actions.ts b/examples/sn-dms-demo/src/store/usersandgroups/actions.ts index 403d0bf0f..53da8fe08 100644 --- a/examples/sn-dms-demo/src/store/usersandgroups/actions.ts +++ b/examples/sn-dms-demo/src/store/usersandgroups/actions.ts @@ -198,7 +198,7 @@ export const removeMemberFromGroups = (contentIds: number[], groups: Group[]) => } catch (error) { options.dispatch(setError(error)) } finally { - const comparedList: Group[] = arrayComparer(groups, currentState.dms.usersAndGroups.user.memberships.d.results) + const comparedList = arrayComparer(groups, currentState.dms.usersAndGroups.user.memberships.d.results) options.dispatch(updateGroupList({ d: { __count: comparedList.length, results: comparedList } })) options.dispatch(loadUser(contentIds[0])) options.dispatch(finishLoading()) @@ -290,7 +290,7 @@ export const addUserToGroups = (user: User, groups: Group[]) => ({ } finally { options.dispatch(finishLoading()) options.dispatch(loadUser(user.Id)) - const comparedList: Group[] = arrayComparer(groups, currentState.dms.usersAndGroups.user.memberships.d.results) + const comparedList = arrayComparer(groups, currentState.dms.usersAndGroups.user.memberships.d.results) options.dispatch(updateGroupList({ d: { __count: comparedList.length, results: comparedList } })) } }, diff --git a/examples/sn-dms-demo/src/store/usersandgroups/reducers.ts b/examples/sn-dms-demo/src/store/usersandgroups/reducers.ts index 55bc908eb..d6dc4d960 100644 --- a/examples/sn-dms-demo/src/store/usersandgroups/reducers.ts +++ b/examples/sn-dms-demo/src/store/usersandgroups/reducers.ts @@ -2,7 +2,7 @@ import { ODataCollectionResponse, ODataParams } from '@sensenet/client-core' import { GenericContent, User } from '@sensenet/default-content-types' import { AnyAction, combineReducers, Reducer } from 'redux' -export const currentUser: Reducer = (state: User | null = null, action: AnyAction) => { +export const currentUser: Reducer = (state = null, action: AnyAction) => { switch (action.type) { case 'DMS_USERSANDGROUPS_SET_USER': return action.content From d6b65b7738682aaa3e3285ee45836294c5ad0a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Tue, 12 Feb 2019 16:30:02 +0100 Subject: [PATCH 5/5] Apply suggestions from code review Co-Authored-By: gallayl --- tslint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tslint.json b/tslint.json index 5a2d75bf7..8ee4ccc67 100644 --- a/tslint.json +++ b/tslint.json @@ -1,6 +1,6 @@ { "defaultSeverity": "error", - "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier", "tslint-consistent-codestyle"], + "extends": ["tslint:recommended", "tslint-react", "tslint-consistent-codestyle", "tslint-config-prettier"], "rules": { "jsx-no-lambda": false, "arrow-parens": [true, "ban-single-arg-parens"],