Skip to content

Commit

Permalink
feat: improve tsconfig, betterer workflow to reduce betterer problems (
Browse files Browse the repository at this point in the history
…#13372)

* feat: pass entropy data to core

* fix: betterer problems, use seperate tsconfig for build process and use strict mode for IDE

* fix: next try with betterer

* fix: use tsconfig.build.json for pipeline test

* fix: betterer

* feat: remove unneccesary code

* fix: broken link, typescript error

* fix: build errors

* feat: do cr tasks
  • Loading branch information
aweiss-dev authored Jul 21, 2022
1 parent d729b7c commit 1c055d6
Show file tree
Hide file tree
Showing 13 changed files with 244 additions and 237 deletions.
68 changes: 10 additions & 58 deletions .betterer.results

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions .betterer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,5 @@
import {typescript} from '@betterer/typescript';

export default {
'stricter compilation': () =>
typescript('./tsconfig.json', {
strict: true,
}).include('./src/**/*.{ts,tsx}'),
'stricter compilation': () => typescript('./tsconfig.json').include('./src/**/*.{ts,tsx}'),
};
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"files": ["*.ts", "*.tsx"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["./tsconfig.json", "./server/tsconfig.json"]
"project": ["./tsconfig.build.json", "./server/tsconfig.json"]
},
"rules": {
"@typescript-eslint/no-floating-promises": "off",
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
. "$(dirname "$0")/_/husky.sh"

npx --no-install lint-staged
yarn betterer precommit --cache
yarn betterer
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"@emotion/react": "11.9.0",
"@wireapp/antiscroll-2": "1.3.1",
"@wireapp/avs": "8.2.2",
"@wireapp/core": "28.6.3",
"@wireapp/react-ui-kit": "8.8.3",
"@wireapp/core": "28.7.0",
"@wireapp/react-ui-kit": "8.9.0",
"@wireapp/store-engine-dexie": "1.6.10",
"@wireapp/store-engine-sqleet": "1.7.14",
"@wireapp/webapp-events": "0.13.2",
Expand All @@ -31,7 +31,7 @@
"platform": "1.3.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-intl": "5.25.1",
"react-intl": "6.0.5",
"react-redux": "8.0.2",
"react-router": "5.3.3",
"react-router-dom": "5.3.3",
Expand Down Expand Up @@ -171,7 +171,7 @@
"text-encoding": "0.7.0",
"ts-node": "10.9.1",
"tsc-watch": "5.0.3",
"typescript": "4.6.4",
"typescript": "4.7.4",
"wait-for-expect": "3.0.2",
"webpack": "5.73.0",
"webpack-cli": "4.10.0",
Expand Down Expand Up @@ -235,12 +235,12 @@
"test": "yarn test:types && yarn test:server && yarn test:app",
"test:app": "jest --forceExit",
"test:server": "cd server && yarn test",
"test:types": "tsc --noEmit && cd server && tsc --noEmit",
"test:types": "tsc --project tsconfig.build.json --noEmit && cd server && tsc --noEmit",
"translate:extract": "i18next-scanner 'src/{page,script}/**/*.{js,html,htm}'",
"translate:merge": "formatjs extract --format './bin/translations_extract_formatter.js' --out-file './src/i18n/en-US.json' './src/script/strings.ts'",
"translate:upload": "yarn translate:merge && ts-node ./bin/translations_upload.ts",
"translate:download": "ts-node ./bin/translations_download.ts",
"betterer": "betterer",
"betterer": "betterer precommit",
"betterer:conflict": "betterer merge"
},
"version": "0.18.0"
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"typescript": "4.7.4"
},
"scripts": {
"build": "yarn clean && tsc -P tsconfig.json && yarn copy-assets && yarn create-commit-sha",
"build": "yarn clean && tsc && yarn copy-assets && yarn create-commit-sha",
"copy-assets": "node ./bin/copy_server_assets.js",
"create-commit-sha": "node ./bin/create_commit_sha_file.js",
"clean": "rimraf ./dist/",
Expand Down
1 change: 1 addition & 0 deletions src/script/auth/module/action/AuthAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ export class AuthAction {
throw new Error(`Could not find value for '${LocalStorageKey.AUTH.PERSIST}'`);
}
const clientType = persist ? ClientType.PERMANENT : ClientType.TEMPORARY;

await core.init(clientType, undefined, false);
await this.persistAuthData(clientType, core, dispatch, localStorageAction);

Expand Down
2 changes: 1 addition & 1 deletion src/script/auth/util/test/mockStoreFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import Cookies, {CookiesStatic} from 'js-cookie';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';

import type {RootState, ThunkDispatch} from '../..//module/reducer';
import {ActionRoot, actionRoot} from '../../module/action/';
import type {RootState, ThunkDispatch} from '../../module/reducer';

export interface MockStoreParameters {
actions?: TypeUtil.RecursivePartial<ActionRoot>;
Expand Down
89 changes: 0 additions & 89 deletions src/script/main/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
import {amplify} from 'amplify';
import jQuery from 'jquery';
import ko from 'knockout';
import type {t} from 'Util/LocalizerUtil';

import type {AssetService} from '../assets/AssetService';
import type {NotificationService} from '../event/NotificationService';

import '../Config';

Expand Down Expand Up @@ -57,91 +53,6 @@ import '../view_model/bindings/VideoCallingBindings';
import '../view_model/MainViewModel';
import '../view_model/PanelViewModel';

declare global {
interface Window {
$: typeof jQuery;
amplify: amplify.Static;
jQuery: typeof jQuery;
ko: typeof ko;
t: typeof t;
wire: {
app: {
service: {
asset: AssetService;
notification: NotificationService;
};
};
env: {
ANALYTICS_API_KEY: string;
APP_BASE: string;
APP_NAME: string;
BACKEND_NAME: string;
BACKEND_REST: string;
BACKEND_WS: string;
BRAND_NAME: string;
CHROME_ORIGIN_TRIAL_TOKEN: string;
COUNTLY_API_KEY: string;
ENVIRONMENT: string;
FEATURE: {
ALLOWED_FILE_UPLOAD_EXTENSIONS: string[];
APPLOCK_SCHEDULED_TIMEOUT: number;
CHECK_CONSENT: boolean;
CONFERENCE_AUTO_MUTE: boolean;
DEFAULT_LOGIN_TEMPORARY_CLIENT: boolean;
ENABLE_ACCOUNT_REGISTRATION: boolean;
ENABLE_ACCOUNT_REGISTRATION_ACCEPT_TERMS_AND_PRIVACY_POLICY: boolean;
ENABLE_DEBUG: boolean;
ENABLE_DOMAIN_DISCOVERY: boolean;
ENABLE_ENFORCE_DESKTOP_APPLICATION_ONLY: boolean;
ENABLE_EXTRA_CLIENT_ENTROPY: boolean;
ENABLE_MEDIA_EMBEDS: boolean;
ENABLE_MLS: boolean;
ENABLE_PHONE_LOGIN: boolean;
ENABLE_SSO: boolean;
ENFORCE_CONSTANT_BITRATE: boolean;
PERSIST_TEMPORARY_CLIENTS: boolean;
SHOW_LOADING_INFORMATION: boolean;
};
MAX_GROUP_PARTICIPANTS: number;
MAX_VIDEO_PARTICIPANTS: number;
NEW_PASSWORD_MINIMUM_LENGTH: number;
URL: {
ACCOUNT_BASE: string;
MOBILE_BASE: string;
PRICING: string;
PRIVACY_POLICY: string;
SUPPORT: {
BUG_REPORT: string;
CALLING: string;
CAMERA_ACCESS_DENIED: string;
CONTACT: string;
DEVICE_ACCESS_DENIED: string;
DEVICE_NOT_FOUND: string;
EMAIL_EXISTS: string;
HISTORY: string;
INDEX: string;
LEGAL_HOLD_BLOCK: string;
MICROPHONE_ACCESS_DENIED: string;
PRIVACY_VERIFY_FINGERPRINT: string;
SCREEN_ACCESS_DENIED: string;
};
TEAMS_BASE: string;
TEAMS_BILLING: string;
TEAMS_CREATE: string;
TERMS_OF_USE_PERSONAL: string;
TERMS_OF_USE_TEAMS: string;
WEBSITE_BASE: string;
WHATS_NEW: string;
};
VERSION: string;
WEBSITE_LABEL: string;
};
};
wSSOCapable: boolean;
z: any;
}
}

window.amplify = amplify;
// we need to publish jQuery on the window so that knockout can use it
window.jQuery = jQuery;
Expand Down
112 changes: 112 additions & 0 deletions src/types/window.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Wire
* Copyright (C) 2022 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

import {amplify} from 'amplify';
import jQuery from 'jquery';
import ko from 'knockout';

import type {AssetService} from '../script/assets/AssetService';
import type {NotificationService} from '../script/event/NotificationService';

import {t} from '../script/util/LocalizerUtil';

declare global {
interface Window {
$: typeof jQuery;
amplify: amplify.Static;
jQuery: typeof jQuery;
ko: typeof ko;
t: typeof t;
wire: {
app: {
service: {
asset: AssetService;
notification: NotificationService;
};
};
env: {
ANALYTICS_API_KEY: string;
APP_BASE: string;
APP_NAME: string;
BACKEND_NAME: string;
BACKEND_REST: string;
BACKEND_WS: string;
BRAND_NAME: string;
CHROME_ORIGIN_TRIAL_TOKEN: string;
COUNTLY_API_KEY: string;
ENVIRONMENT: string;
FEATURE: {
ALLOWED_FILE_UPLOAD_EXTENSIONS: string[];
APPLOCK_SCHEDULED_TIMEOUT: number;
CHECK_CONSENT: boolean;
CONFERENCE_AUTO_MUTE: boolean;
DEFAULT_LOGIN_TEMPORARY_CLIENT: boolean;
ENABLE_ACCOUNT_REGISTRATION: boolean;
ENABLE_ACCOUNT_REGISTRATION_ACCEPT_TERMS_AND_PRIVACY_POLICY: boolean;
ENABLE_DEBUG: boolean;
ENABLE_DOMAIN_DISCOVERY: boolean;
ENABLE_ENFORCE_DESKTOP_APPLICATION_ONLY: boolean;
ENABLE_EXTRA_CLIENT_ENTROPY: boolean;
ENABLE_MEDIA_EMBEDS: boolean;
ENABLE_MLS: boolean;
ENABLE_PHONE_LOGIN: boolean;
ENABLE_SSO: boolean;
ENFORCE_CONSTANT_BITRATE: boolean;
PERSIST_TEMPORARY_CLIENTS: boolean;
SHOW_LOADING_INFORMATION: boolean;
};
MAX_GROUP_PARTICIPANTS: number;
MAX_VIDEO_PARTICIPANTS: number;
NEW_PASSWORD_MINIMUM_LENGTH: number;
URL: {
ACCOUNT_BASE: string;
MOBILE_BASE: string;
PRICING: string;
PRIVACY_POLICY: string;
SUPPORT: {
BUG_REPORT: string;
CALLING: string;
CAMERA_ACCESS_DENIED: string;
CONTACT: string;
DEVICE_ACCESS_DENIED: string;
DEVICE_NOT_FOUND: string;
EMAIL_EXISTS: string;
HISTORY: string;
INDEX: string;
LEGAL_HOLD_BLOCK: string;
MICROPHONE_ACCESS_DENIED: string;
PRIVACY_VERIFY_FINGERPRINT: string;
SCREEN_ACCESS_DENIED: string;
};
TEAMS_BASE: string;
TEAMS_BILLING: string;
TEAMS_CREATE: string;
TERMS_OF_USE_PERSONAL: string;
TERMS_OF_USE_TEAMS: string;
WEBSITE_BASE: string;
WHATS_NEW: string;
};
VERSION: string;
WEBSITE_LABEL: string;
};
};
wSSOCapable: boolean;
z: any;
}
}
6 changes: 6 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"strict": false
}
}
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "src/script/auth",
// Must be in sync with jest.config.js >> moduleNameMapper
"paths": {
"Components/*": ["./src/script/components/*"],
"I18n/*": ["./src/i18n/*"],
Expand All @@ -35,7 +34,9 @@
"resolveJsonModule": true,
"rootDirs": ["src/script"],
"sourceMap": true,
"target": "es2017"
"target": "es2017",
"typeRoots": ["src/types", "node_modules/@types"],
"strict": true
},
"exclude": ["node_modules", "server", "src/sw.js"]
}
Loading

0 comments on commit 1c055d6

Please sign in to comment.