diff --git a/.eslintrc.js b/.eslintrc.js index 2a050c77..688f3aaf 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,15 +1,19 @@ module.exports = { extends: ["@stellar/eslint-config"], rules: { - "no-console": 0, + "no-console": "off", "import/no-unresolved": "off", - "react/jsx-filename-extension": [1, { extensions: [".tsx", ".jsx"] }], - "react/prop-types": 0, - // note you must disable the base rule as it can report incorrect errors - "no-shadow": "off", - "@typescript-eslint/no-shadow": ["error"], - // note you must disable the base rule as it can report incorrect errors - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": ["error"], + "react/jsx-filename-extension": ["error", { extensions: [".tsx", ".jsx"] }], + "no-plusplus": "off", + "jsdoc/check-indentation": "off", + "@typescript-eslint/naming-convention": [ + "error", + { + selector: "typeProperty", + format: ["PascalCase", "UPPER_CASE", "camelCase", "snake_case"], + leadingUnderscore: "allow", + trailingUnderscore: "allow", + }, + ], }, }; diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 00000000..31354ec1 --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/post-merge b/.husky/post-merge new file mode 100644 index 00000000..27443865 --- /dev/null +++ b/.husky/post-merge @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +yarn install-if-package-changed diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..025779ed --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +yarn pre-commit diff --git a/package.json b/package.json index 7eecea8e..dfeb309c 100644 --- a/package.json +++ b/package.json @@ -7,54 +7,42 @@ "engines": { "node": "14.x" }, - "husky": { - "hooks": { - "pre-commit": "concurrently 'pretty-quick --staged' 'lint-staged' 'tsc --noEmit'", - "post-merge": "yarn install-if-package-changed" - } - }, "lint-staged": { "src/**/*.ts?(x)": [ "eslint --fix --max-warnings 0" ] }, "dependencies": { - "@reduxjs/toolkit": "^1.5.0", - "@sentry/browser": "^6.3.1", - "@sentry/tracing": "^6.3.1", + "@reduxjs/toolkit": "^1.6.0", + "@sentry/browser": "^6.8.0", + "@sentry/tracing": "^6.8.0", "@stellar/design-system": "^0.1.0-alpha.3", "@stellar/prettier-config": "^1.0.1", - "@stellar/wallet-sdk": "^0.3.0-rc.4", - "@testing-library/jest-dom": "^5.11.9", - "@testing-library/react": "^11.2.3", - "@testing-library/user-event": "^12.6.0", - "@types/jest": "^26.0.20", - "@types/node": "^14.14.20", - "@types/react": "^17.0.0", - "@types/react-copy-to-clipboard": "^5.0.0", - "@types/react-dom": "^17.0.0", - "@types/react-redux": "^7.1.15", - "@types/react-router-dom": "^5.1.7", + "@stellar/wallet-sdk": "^0.4.0-rc.0", + "@testing-library/jest-dom": "^5.14.1", + "@testing-library/react": "^12.0.0", + "@testing-library/user-event": "^13.1.9", "bignumber.js": "^9.0.1", "crypto": "^1.0.1", - "dompurify": "^2.2.7", - "html-react-parser": "^1.2.4", - "lodash": "^4.17.19", - "marked": "^2.0.1", - "node-sass": "^4.14.1", - "react": "^17.0.1", + "dompurify": "^2.3.0", + "html-react-parser": "^1.2.7", + "lodash": "^4.17.21", + "marked": "^2.1.3", + "node-sass": "^6.0.1", + "react": "^17.0.2", "react-copy-to-clipboard": "^5.0.3", - "react-dom": "^17.0.1", - "react-json-view": "^1.21.1", - "react-redux": "^7.2.2", + "react-dom": "^17.0.2", + "react-json-view": "^1.21.3", + "react-redux": "^7.2.4", "react-router-dom": "^5.2.0", - "react-scripts": "4.0.1", - "redux": "^4.0.5", - "stellar-sdk": "^8.2.1", - "styled-components": "^5.2.1", + "react-scripts": "4.0.3", + "redux": "^4.1.0", + "stellar-sdk": "^8.2.3", + "styled-components": "^5.3.0", "toml": "^3.0.0", - "typescript": "~4.1.3", - "web-vitals": "^0.2.4" + "tslib": "^2.3.0", + "typescript": "~4.3.5", + "web-vitals": "^2.1.0" }, "scripts": { "install-if-package-changed": "git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep --quiet yarn.lock && yarn install || exit 0", @@ -64,7 +52,9 @@ "eject": "react-scripts eject", "prod:build": "docker image build --build-arg REACT_APP_AMPLITUDE_KEY=$AMPLITUDE_KEY --build-arg REACT_APP_SENTRY_KEY=$SENTRY_KEY -t stellar-demo-wallet:localbuild .", "prod:serve": "docker run -p 8000:80 stellar-demo-wallet:localbuild", - "production": "yarn prod:build && yarn prod:serve" + "production": "yarn prod:build && yarn prod:serve", + "prepare": "husky install", + "pre-commit": "concurrently 'pretty-quick --staged' 'lint-staged' 'tsc --noEmit'" }, "eslintConfig": { "extends": [ @@ -85,19 +75,36 @@ ] }, "devDependencies": { - "@stellar/eslint-config": "^1.0.5", + "@stellar/eslint-config": "^2.1.1", "@stellar/tsconfig": "^1.0.2", - "@types/lodash": "^4.14.167", - "@types/marked": "^2.0.0", + "@types/jest": "^26.0.24", + "@types/lodash": "^4.14.171", + "@types/marked": "^2.0.4", + "@types/node": "^16.0.1", + "@types/react": "^17.0.14", + "@types/react-copy-to-clipboard": "^5.0.1", + "@types/react-dom": "^17.0.9", + "@types/react-redux": "^7.1.17", + "@types/react-router-dom": "^5.1.8", "@types/redux": "^3.6.0", - "@types/styled-components": "^5.1.7", - "concurrently": "^5.3.0", - "eslint": "^7.17.0", - "eslint-config-prettier": "^7.1.0", + "@types/styled-components": "^5.1.11", + "@typescript-eslint/eslint-plugin": "^4.28.2", + "@typescript-eslint/parser": "^4.28.2", + "concurrently": "^6.2.0", + "eslint": "^7.30.0", + "eslint-config-prettier": "^8.3.0", "eslint-config-react": "^1.1.7", - "husky": "^4.3.7", - "lint-staged": "^10.5.3", - "prettier": "^2.2.1", - "pretty-quick": "^3.1.0" + "eslint-config-react-app": "^6.0.0", + "eslint-plugin-flowtype": "^5.8.0", + "eslint-plugin-import": "^2.23.4", + "eslint-plugin-jsdoc": "^35.4.1", + "eslint-plugin-jsx-a11y": "^6.4.1", + "eslint-plugin-prefer-arrow": "^1.2.3", + "eslint-plugin-react": "^7.24.0", + "eslint-plugin-react-hooks": "^4.2.0", + "husky": "^7.0.1", + "lint-staged": "^11.0.0", + "prettier": "^2.3.2", + "pretty-quick": "^3.1.1" } } diff --git a/src/components/AddAsset.tsx b/src/components/AddAsset.tsx index 56cbec06..16b77a9e 100644 --- a/src/components/AddAsset.tsx +++ b/src/components/AddAsset.tsx @@ -83,7 +83,7 @@ export const AddAsset = ({ onClose }: { onClose: () => void }) => { if (asset.homeDomain) { search = searchParam.updateKeyPair({ - searchParam: SearchParams.ASSET_OVERRIDES, + param: SearchParams.ASSET_OVERRIDES, itemId: `${asset.assetCode}:${asset.assetIssuer}`, keyPairs: { homeDomain }, urlSearchParams: new URLSearchParams(search), diff --git a/src/components/Assets.tsx b/src/components/Assets.tsx index 026a803c..08fdfba1 100644 --- a/src/components/Assets.tsx +++ b/src/components/Assets.tsx @@ -86,7 +86,7 @@ export const Assets = ({ const dispatch = useDispatch(); const history = useHistory(); - enum modalType { + enum ModalType { ADD_ASSET = "ADD_ASSET", CONFIRM_ACTION = "CONFIRM_ACTION", } @@ -133,7 +133,7 @@ export const Assets = ({ description, options, }: AssetActionItem) => { - setActiveModal(modalType.CONFIRM_ACTION); + setActiveModal(ModalType.CONFIRM_ACTION); dispatch( setActiveAssetAction({ assetString, @@ -396,7 +396,7 @@ export const Assets = ({