From 457ee9a111eaffd986bba34957c4672d10668286 Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Mon, 16 Nov 2020 12:54:41 +0100 Subject: [PATCH] Remove unused NPM libraries from package.json (#771) * Remove unused FontAwesome free icons Signed-off-by: Mick Vleeshouwer * Remove unused imports, comment unused code Signed-off-by: Mick Vleeshouwer * Remove jquery Signed-off-by: Mick Vleeshouwer * Remove unused serialize-javascript Signed-off-by: Mick Vleeshouwer * Move yarn to dev dependencies Signed-off-by: Mick Vleeshouwer * Move rimraf to devDependencies Signed-off-by: Mick Vleeshouwer Co-authored-by: stew-ro <60453211+stew-ro@users.noreply.github.com> --- package.json | 11 +++----- src/index.tsx | 1 - .../components/pages/editorPage/tableView.tsx | 2 +- .../prebuiltPredict/layoutPredictPage.tsx | 1 - .../components/pages/train/trainPage.tsx | 2 +- src/redux/actions/projectActions.ts | 20 +++++++-------- src/redux/reducers/currentProjectReducer.ts | 3 +-- src/services/assetService.ts | 2 +- yarn.lock | 25 +++---------------- 9 files changed, 21 insertions(+), 46 deletions(-) diff --git a/package.json b/package.json index e43347724..35223e32c 100644 --- a/package.json +++ b/package.json @@ -42,12 +42,9 @@ "reactstrap": "^8.2.0", "redux": "^4.0.4", "redux-thunk": "^2.3.0", - "rimraf": "^3.0.2", - "serialize-javascript": "^5.0.1", "shortid": "^2.2.15", "utif": "^3.1.0", - "vott-react": "^0.2.12", - "yarn": "^1.22.4" + "vott-react": "^0.2.12" }, "scripts": { "start": "env-cmd -f .env.electron nf start -p 3000", @@ -84,7 +81,6 @@ ] }, "devDependencies": { - "@fortawesome/fontawesome-free": "^5.12.0", "@types/axios": "^0.14.0", "@types/enzyme": "^3.10.4", "@types/history": "^4.7.3", @@ -106,7 +102,6 @@ "enzyme-adapter-react-16": "^1.15.1", "eslint-utils": "^1.4.3", "foreman": "^3.0.1", - "jquery": "^3.5.0", "kind-of": "^6.0.3", "mime": "^2.4.6", "minimist": "^1.2.2", @@ -117,11 +112,13 @@ "redux-immutable-state-invariant": "^2.1.0", "redux-logger": "^3.0.6", "redux-mock-store": "^1.5.4", + "rimraf": "^3.0.2", "ts-loader": "^7.0.1", "tslint": "^6.1.1", "typescript": "^3.9.5", "webpack-cli": "^3.3.11", - "webpack-merge": "^4.2.2" + "webpack-merge": "^4.2.2", + "yarn": "^1.22.10" }, "engines": { "node": ">=12.13.1", diff --git a/src/index.tsx b/src/index.tsx index 030ae7717..62e240d27 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -5,7 +5,6 @@ import React from "react"; import ReactDOM from "react-dom"; import { Provider } from "react-redux"; import "../node_modules/bootstrap/dist/css/bootstrap.min.css"; -import "../node_modules/@fortawesome/fontawesome-free/css/all.css"; import "./assets/css/bootstrap-theme-slate.css"; import "./index.scss"; import App from "./App"; diff --git a/src/react/components/pages/editorPage/tableView.tsx b/src/react/components/pages/editorPage/tableView.tsx index 9f5a3068e..172d3d522 100644 --- a/src/react/components/pages/editorPage/tableView.tsx +++ b/src/react/components/pages/editorPage/tableView.tsx @@ -28,7 +28,7 @@ export const TableView: React.FunctionComponent = (props) => { if (table !== null) { tableBody = []; const rows = table["rows"]; - const columns = table["columns"]; + // const columns = table["columns"]; for (let i = 0; i < rows; i++) { const tableRow = []; tableBody.push({tableRow}); diff --git a/src/react/components/pages/prebuiltPredict/layoutPredictPage.tsx b/src/react/components/pages/prebuiltPredict/layoutPredictPage.tsx index d96d723e4..b55b32dee 100644 --- a/src/react/components/pages/prebuiltPredict/layoutPredictPage.tsx +++ b/src/react/components/pages/prebuiltPredict/layoutPredictPage.tsx @@ -11,7 +11,6 @@ import { TooltipHost } from "@fluentui/react"; import Fill from "ol/style/Fill"; -import Icon from "ol/style/Icon"; import Stroke from "ol/style/Stroke"; import Style from "ol/style/Style"; import React from "react"; diff --git a/src/react/components/pages/train/trainPage.tsx b/src/react/components/pages/train/trainPage.tsx index 07bf66799..14bfd6e84 100644 --- a/src/react/components/pages/train/trainPage.tsx +++ b/src/react/components/pages/train/trainPage.tsx @@ -12,7 +12,7 @@ import {constants} from "../../../../common/constants"; import {isElectron} from "../../../../common/hostProcess"; import {interpolate, strings} from "../../../../common/strings"; import {getGreenWithWhiteBackgroundTheme, getPrimaryGreenTheme} from "../../../../common/themes"; -import {AssetLabelingState, AssetState, FieldType, IApplicationState, IAppSettings, IAssetMetadata, IConnection, IProject, IRecentModel} from "../../../../models/applicationState"; +import {AssetLabelingState, FieldType, IApplicationState, IAppSettings, IAssetMetadata, IConnection, IProject, IRecentModel} from "../../../../models/applicationState"; import IApplicationActions, * as applicationActions from "../../../../redux/actions/applicationActions"; import IAppTitleActions, * as appTitleActions from "../../../../redux/actions/appTitleActions"; import IProjectActions, * as projectActions from "../../../../redux/actions/projectActions"; diff --git a/src/redux/actions/projectActions.ts b/src/redux/actions/projectActions.ts index 10a9948a4..87e98b810 100644 --- a/src/redux/actions/projectActions.ts +++ b/src/redux/actions/projectActions.ts @@ -14,8 +14,6 @@ import { IProject, ITag, ISecurityToken, - AssetState, - AssetLabelingState, } from "../../models/applicationState"; import { createAction, createPayloadAction, IPayloadAction } from "./actionCreators"; import { appInfo } from "../../common/appInfo"; @@ -35,7 +33,7 @@ export default interface IProjectActions { addAssetToProject(project: IProject, fileName: string, buffer: Buffer, analyzeResult: any): Promise; deleteAsset(project: IProject, assetMetadata: IAssetMetadata): Promise; loadAssets(project: IProject): Promise; - refreshAsset(project: IProject, assetName: string):Promise; + refreshAsset(project: IProject, assetName: string): Promise; loadAssetMetadata(project: IProject, asset: IAsset): Promise; saveAssetMetadata(project: IProject, assetMetadata: IAssetMetadata): Promise; saveAssetMetadataAndCleanEmptyLabel(project: IProject, assetMetadata: IAssetMetadata): Promise; @@ -158,7 +156,7 @@ export function deleteProject(project: IProject) if (!projectToken) { dispatch(deleteProjectAction(project)); - throw new AppError(ErrorCode.SecurityTokenNotFound, interpolate(strings.errors.projectDeleteErrorSecurityTokenNotFound.message, {project})); + throw new AppError(ErrorCode.SecurityTokenNotFound, interpolate(strings.errors.projectDeleteErrorSecurityTokenNotFound.message, { project })); } const decryptedProject = await projectService.load(project, projectToken); @@ -235,11 +233,11 @@ function areAssetsEqual(assets: IAsset[], projectAssets: { [index: string]: IAss return JSON.stringify(assetsMap) === JSON.stringify(projectAssets); } -export function refreshAsset(project: IProject, assetName:string):(dispatch:Dispatch) => Promise { - return async (dispatch:Dispatch) =>{ +export function refreshAsset(project: IProject, assetName: string): (dispatch: Dispatch) => Promise { + return async (dispatch: Dispatch) => { const assetService = new AssetService(project); - const asset = await assetService.getAsset( assetName); - dispatch(refreshAssetAction( asset)); + const asset = await assetService.getAsset(assetName); + dispatch(refreshAssetAction(asset)); } } @@ -280,11 +278,11 @@ export function saveAssetMetadata( export function saveAssetMetadataAndCleanEmptyLabel( project: IProject, assetMetadata: IAssetMetadata): (dispatch: Dispatch) => Promise { - const newAssetMetadata: IAssetMetadata = { ...(_.cloneDeep(assetMetadata)), version: appInfo.version}; + const newAssetMetadata: IAssetMetadata = { ...(_.cloneDeep(assetMetadata)), version: appInfo.version }; return async (dispatch: Dispatch) => { const assetService = new AssetService(project); - const savedMetadata = await assetService.save(newAssetMetadata,true); + const savedMetadata = await assetService.save(newAssetMetadata, true); dispatch(saveAssetMetadataAction(savedMetadata)); return { ...savedMetadata }; @@ -475,7 +473,7 @@ export const deleteProjectAssetAction = createPayloadAction(ActionTypes.DELETE_PROJECT_ASSET_SUCCESS); export const refreshAssetAction = -createPayloadAction(ActionTypes.REFRESH_ASSET_SUCCESS); + createPayloadAction(ActionTypes.REFRESH_ASSET_SUCCESS); /** * Instance of Load Asset Metadata action */ diff --git a/src/redux/reducers/currentProjectReducer.ts b/src/redux/reducers/currentProjectReducer.ts index 8e78dd943..2d690fc85 100644 --- a/src/redux/reducers/currentProjectReducer.ts +++ b/src/redux/reducers/currentProjectReducer.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import {ActionTypes} from "../actions/actionTypes"; -import {AssetLabelingState, AssetState, IProject, ITag} from "../../models/applicationState"; +import {IProject, ITag} from "../../models/applicationState"; import {AnyAction} from "../actions/actionCreators"; import _ from "lodash"; // tslint:disable-next-line:no-var-requires @@ -43,7 +43,6 @@ export const reducer = (state: IProject = null, action: AnyAction): IProject => ...state, assets:{...state.assets, [action.payload.id]: action.payload}, }; - break; case ActionTypes.DELETE_PROJECT_ASSET_SUCCESS: case ActionTypes.LOAD_PROJECT_ASSETS_SUCCESS: let assets = {}; diff --git a/src/services/assetService.ts b/src/services/assetService.ts index 2ef5255d3..bdac4dfc3 100644 --- a/src/services/assetService.ts +++ b/src/services/assetService.ts @@ -58,7 +58,7 @@ const imageMimes: IMime[] = [ }, ]; // We can expand this list @see https://mimesniff.spec.whatwg.org/#matching-an-image-type-pattern -const mimeBytesNeeded: number = (Math.max(...imageMimes.map((m) => m.pattern.length)) - 1); +// const mimeBytesNeeded: number = (Math.max(...imageMimes.map((m) => m.pattern.length)) - 1); /** * @name - Asset Service diff --git a/yarn.lock b/yarn.lock index 483fc18c8..24b9cd1f1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1310,11 +1310,6 @@ office-ui-fabric-react "^7.121.0" tslib "^1.10.0" -"@fortawesome/fontawesome-free@^5.12.0": - version "5.13.0" - resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.13.0.tgz#fcb113d1aca4b471b709e8c9c168674fbd6e06d9" - integrity sha512-xKOeQEl5O47GPZYIMToj6uuA2syyFlq9EMSl2ui0uytjY9xbe8XS0pexNWmxrdcCyNGyDmLyYw5FtKsalBUeOg== - "@hapi/address@2.x.x": version "2.1.4" resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5" @@ -7695,11 +7690,6 @@ jest@24.9.0: import-local "^2.0.0" jest-cli "^24.9.0" -jquery@^3.5.0: - version "3.5.1" - resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5" - integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg== - js-base64@^2.1.8: version "2.5.2" resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.5.2.tgz#313b6274dda718f714d00b3330bbae6e38e90209" @@ -11777,13 +11767,6 @@ serialize-javascript@^3.1.0: dependencies: randombytes "^2.1.0" -serialize-javascript@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-5.0.1.tgz#7886ec848049a462467a97d3d918ebb2aaf934f4" - integrity sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA== - dependencies: - randombytes "^2.1.0" - serve-index@^1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.1.tgz#d3768d69b1e7d82e5ce050fff5b453bea12a9239" @@ -13873,10 +13856,10 @@ yargs@^16.0.3: y18n "^5.0.5" yargs-parser "^20.2.2" -yarn@^1.22.4: - version "1.22.4" - resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.4.tgz#01c1197ca5b27f21edc8bc472cd4c8ce0e5a470e" - integrity sha512-oYM7hi/lIWm9bCoDMEWgffW8aiNZXCWeZ1/tGy0DWrN6vmzjCXIKu2Y21o8DYVBUtiktwKcNoxyGl/2iKLUNGA== +yarn@^1.22.10: + version "1.22.10" + resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.10.tgz#c99daa06257c80f8fa2c3f1490724e394c26b18c" + integrity sha512-IanQGI9RRPAN87VGTF7zs2uxkSyQSrSPsju0COgbsKQOOXr5LtcVPeyXWgwVa0ywG3d8dg6kSYKGBuYK021qeA== yauzl@^2.10.0: version "2.10.0"