Skip to content

Commit

Permalink
feat!: ts-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanwan05 committed Nov 7, 2022
1 parent 3c3ddf1 commit 8a556b4
Show file tree
Hide file tree
Showing 29 changed files with 1,149 additions and 1,199 deletions.
29 changes: 24 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
/* @flow */

module.exports = {
extends: require.resolve(
"@krakenjs/grumbler-scripts/config/.eslintrc-browser"
),
extends:
"./node_modules/@krakenjs/grumbler-scripts/config/.eslintrc-typescript.js",

globals: {
__TEST__: true,
},

rules: {
"no-mixed-operators": "off",
// off for initial ts conversion
"@typescript-eslint/no-implicit-any-catch": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/prefer-for-of": "off",

"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
},
};
15 changes: 0 additions & 15 deletions .flowconfig

This file was deleted.

4 changes: 4 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
extends: "@krakenjs/grumbler-scripts/config/.babelrc-browser",
presets: ["@krakenjs/grumbler-scripts/config/flow-ts-babel-preset"],
};
3 changes: 0 additions & 3 deletions babel.config.json

This file was deleted.

File renamed without changes.
46 changes: 29 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@
"version": "1.0.124",
"description": "Utilities.",
"main": "index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"sideEffects": [
"./src/styles/*.scss"
],
"scripts": {
"setup": "npm install && npm run flow-typed",
"lint": "eslint src/ *.js",
"flow-typed": "rm -rf ./flow-typed && flow-typed install",
"flow": "flow",
"karma": "cross-env NODE_ENV=test babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/karma start",
"babel": "babel src/ --out-dir dist/module",
"webpack": "babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/webpack --progress",
"build": "npm run babel && npm run webpack && npm run build:types",
"build:flow": "find ./dist -type f -not -path './node_modules/*' -name '*.d.ts' -exec sh -c 'flowgen --add-flow-header $1 -o ${1%.*.*}.js.flow' _ '{}' \\;",
"build:tsc": "tsc src/*.ts --outDir ./dist/esm --declaration --emitDeclarationOnly",
"build:types": "npm run build:tsc && npm run build:flow",
"webpack": "cross-env NODE_ENV=production babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/webpack --progress --output-path dist",
"babel": "cross-env NODE_ENV=production babel src/ --out-dir ./dist/esm/ --extensions .ts,.tsx",
"tsc": "tsc",
"format": "prettier --write --ignore-unknown .",
"format:check": "prettier --check .",
"test": "npm run format:check && npm run lint && npm run flow-typed && npm run flow",
"build": "npm run test && npm run babel && npm run webpack",
"release": "./publish.sh",
"release:patch": "./publish.sh patch",
"release:minor": "./publish.sh minor",
"release:major": "./publish.sh major",
"lint": "eslint --ext ts,tsx,js,jsx src/",
"clean": "rimraf dist coverage",
"reinstall": "rimraf flow-typed && rimraf node_modules && npm install && flow-typed install",
"prerelease": "npm run clean && npm run build && git add dist && git commit -m 'ci: check in dist folder' || echo 'Nothing to distribute'",
"release": "standard-version",
"postrelease": "git push && git push --follow-tags && npm publish",
"debug": "cross-env NODE_ENV=debug",
"prepare": "husky install"
},
Expand All @@ -45,11 +47,21 @@
"license": "Apache-2.0",
"readmeFilename": "README.md",
"devDependencies": {
"@krakenjs/grumbler-scripts": "^7.0.0",
"flow-bin": "0.129.0",
"@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1",
"@krakenjs/grumbler-scripts": "^7.0.3",
"@types/webpack": "^5.28.0",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"c8": "^7.11.0",
"flowgen": "^1.16.0",
"happy-dom": "^2.55.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"prettier": "2.7.1"
"prettier": "2.7.1",
"standard-version": "^9.3.2",
"ts-node": "^10.5.0",
"typescript": "4.8.4"
},
"dependencies": {
"hi-base32": "^0.5.0"
Expand Down
3 changes: 0 additions & 3 deletions src/apm.js → src/apm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/* @flow */

import { FUNDING } from "./funding";

export const APM_LIST = [
FUNDING.IDEAL,
FUNDING.BANCONTACT,
Expand Down
3 changes: 0 additions & 3 deletions src/defaults.js → src/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* @flow */

import { COUNTRY } from "./locale";
import { CURRENCY, INTENT, COMMIT, VAULT } from "./order";
import { COMPONENTS, DEBUG } from "./params";

export const DEFAULT_COUNTRY = COUNTRY.US;
export const DEFAULT_CURRENCY = CURRENCY.USD;
export const DEFAULT_INTENT = INTENT.CAPTURE;
Expand Down
14 changes: 0 additions & 14 deletions src/env.js

This file was deleted.

11 changes: 11 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const ENV = {
LOCAL: "local" as const,
STAGE: "stage" as const,
SANDBOX: "sandbox" as const,
PRODUCTION: "production" as const,
TEST: "test" as const,
};
export const MOBILE_ENV = {
ANDROID: "android" as const,
IOS: "iOS" as const,
};
5 changes: 0 additions & 5 deletions src/error.js

This file was deleted.

3 changes: 3 additions & 0 deletions src/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const ERROR_CODE = {
VALIDATION_ERROR: "validation_error" as const,
};
88 changes: 0 additions & 88 deletions src/fpti.js

This file was deleted.

79 changes: 79 additions & 0 deletions src/fpti.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
export const FPTI_KEY = {
FEED: "feed_name" as const,
STATE: "state_name" as const,
EVENT_NAME: "event_name" as const,
TRANSITION: "transition_name" as const,
PAGE: "page_name" as const,
BUTTON_TYPE: "button_type" as const,
SESSION_UID: "page_session_id" as const,
BUTTON_SESSION_UID: "button_session_id" as const,
TOKEN: "token" as const,
CONTEXT_ID: "context_id" as const,
CONTEXT_TYPE: "context_type" as const,
REFERER: "referer_url" as const,
MERCHANT_DOMAIN: "merchant_domain" as const,
PAY_ID: "pay_id" as const,
SELLER_ID: "seller_id" as const,
CLIENT_ID: "client_id" as const,
DATA_SOURCE: "serverside_data_source" as const,
BUTTON_SOURCE: "button_source" as const,
ERROR_CODE: "ext_error_code" as const,
ERROR_DESC: "ext_error_desc" as const,
PAGE_LOAD_TIME: "page_load_time" as const,
EXPERIMENT_NAME: "pxp_exp_id" as const,
TREATMENT_NAME: "pxp_trtmnt_id" as const,
TRANSITION_TIME: "transition_time" as const,
FUNDING_LIST: "eligible_payment_methods" as const,
FUNDING_COUNT: "eligible_payment_count" as const,
CHOSEN_FUNDING: "selected_payment_method" as const,
BUTTON_LAYOUT: "button_layout" as const,
VERSION: "checkoutjs_version" as const,
LOCALE: "locale" as const,
BUYER_COUNTRY: "buyer_cntry" as const,
INTEGRATION_IDENTIFIER: "integration_identifier" as const,
PARTNER_ATTRIBUTION_ID: "bn_code" as const,
PAGE_TYPE: "pp_placement" as const,
SDK_NAME: "sdk_name" as const,
SDK_VERSION: "sdk_version" as const,
SDK_ENVIRONMENT: "sdk_environment" as const,
MOBILE_APP_VERSION: "mobile_app_version" as const,
MOBILE_BUNDLE_IDENTIFIER: "mapv" as const,
USER_AGENT: "user_agent" as const,
USER_ACTION: "user_action" as const,
CONTEXT_CORRID: "context_correlation_id" as const,
SDK_CACHE: "sdk_cache" as const,
SDK_LOAD_TIME: "sdk_load_time" as const,
IS_VAULT: "is_vault" as const,
DISABLE_FUNDING: "disable_funding" as const,
DISABLE_CARD: "disable_card" as const,
RESPONSE_DURATION: "response_duration" as const,
SDK_INTEGRATION_SOURCE: "sdk_integration_source" as const,
PAYMENT_FLOW: "payment_flow" as const,
BUTTON_VERSION: "button_version" as const,
FI_LIST: "fi_list" as const,
CHOSEN_FI_TYPE: "chosen_fi_type" as const,
SELECTED_FI: "merchant_selected_funding_source" as const,
POTENTIAL_PAYMENT_METHODS: "potential_payment_methods" as const,
PAY_NOW: "pay_now" as const,
STICKINESS_ID: "stickiness_id" as const,
TIMESTAMP: "t" as const,
OPTION_SELECTED: "optsel" as const,
USER_IDENTITY_METHOD: "user_identity_method" as const,
FIELDS_COMPONENT_SESSION_ID: "fields_component_session_id" as const,
CPL_COMP_METRICS: "cpl_comp_metrics" as const,
CPL_CHUNK_METRICS: "cpl_chunk_metrics" as const,
CPL_QUERY_METRICS: "cpl_query_metrics" as const,
};
export const FPTI_USER_ACTION = {
COMMIT: "commit" as const,
CONTINUE: "continue" as const,
};
export const FPTI_DATA_SOURCE = {
PAYMENTS_SDK: "checkout" as const,
};
export const FPTI_FEED = {
PAYMENTS_SDK: "payments_sdk" as const,
};
export const FPTI_SDK_NAME = {
PAYMENTS_SDK: "payments_sdk" as const,
};
Loading

0 comments on commit 8a556b4

Please sign in to comment.