Skip to content

chore(all): fix eslint and lint-staged setup #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

przemyslaw-wlodek
Copy link
Contributor

@przemyslaw-wlodek przemyslaw-wlodek commented Jun 13, 2023

Proposed solution

Minor fixes and updates for eslint and lint-staged configurations.


Allure report

allure-report-publisher generated test report!

smokeTests: ✅ test report for c3ffd99d

passed failed skipped flaky total result
Total 19 0 0 0 19

@przemyslaw-wlodek przemyslaw-wlodek self-assigned this Jun 13, 2023
@przemyslaw-wlodek przemyslaw-wlodek requested review from a team as code owners June 13, 2023 00:05
@przemyslaw-wlodek przemyslaw-wlodek requested review from a team as code owners June 13, 2023 01:34
@github-actions github-actions bot added the browser Changes to the browser application. label Jun 13, 2023
@przemyslaw-wlodek przemyslaw-wlodek changed the title chore(ui): fix eslint and lint-staged setup chore(all): fix eslint and lint-staged setup Jun 13, 2023
@przemyslaw-wlodek przemyslaw-wlodek marked this pull request as draft June 13, 2023 01:52
@przemyslaw-wlodek przemyslaw-wlodek marked this pull request as ready for review June 13, 2023 08:25
@@ -173,7 +174,7 @@ export default new (class WebTester {
await sel.waitForDisplayed();
return await sel
.getText()
.then((t) => Promise.resolve(t))
.then((t) => t)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That then is redundant.

@@ -117,14 +117,15 @@ export class TokensPage extends WebElement {

async getTokenTableItemValueByIndex(index: number, mode: 'extended' | 'popup'): Promise<number> {
const tokenValue = (await webTester.getTextValueFromElement(this.tokensTableItemValue(index, mode))) as string;
return Number.parseFloat(tokenValue.replace(/,/g, ''));
// eslint-disable-next-line unicorn/prefer-string-replace-all
return Number.parseFloat(tokenValue.replace(',', ''));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change might potentially break the code. Previous code replaces all occurrences of , while after your changes only the first one gets replaced. I thing it should be reverted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant catch! Thank you, it reverted just a part of the autofix. I should've noticed that! Will update this soon

}

async getTokenTableItemValueByName(tokenName: string, mode: 'extended' | 'popup'): Promise<number> {
const tokenValue = (await webTester.getTextValueFromElement(
this.tokensTableItemValue(await this.getTokenRowIndex(tokenName), mode)
)) as string;
return Number.parseFloat(tokenValue.replace(/,/g, ''));
return Number.parseFloat(tokenValue.replace(',', ''));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change might potentially break the code. Previous code replaces all occurrences of , while after your changes only the first one gets replaced. I thing it should be reverted.

@@ -19,8 +19,13 @@
"build": "rollup -c rollup.config.js",
"build-storybook": "export NODE_OPTIONS=--openssl-legacy-provider; build-storybook",
"cleanup": "shx rm -rf node_modules",
"format": "yarn prettier --write '**/*.tsx'",
"lint": "eslint .",
"eslint:check": "eslint --cache --cache-location ../../.cache/eslintcache --cache-strategy metadata --ignore-path '../../.eslintignore' .",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache and ignore path parameters assume this package lives in the monorepo. I remember @renanvalentin had a point that this package should stay independent of the lace mono repo so it might be easily moved to separate repo some day.

Comment on lines -61 to -76
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"@vanilla-extract/rollup-plugin": "^1.2.0",
"@vanilla-extract/webpack-plugin": "^2.2.0",
"babel-loader": "^8.3.0",
"concurrently": "^8.0.1",
"eslint": "^8.33.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-boundaries": "^3.1.0",
"eslint-plugin-functional": "^5.0.4",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-max-params-no-constructor": "^0.0.4",
"eslint-plugin-prefer-arrow-functions": "^3.1.4",
"eslint-plugin-react": "7.31.8",
"eslint-plugin-storybook": "^0.6.11",
"eslint-plugin-unicorn": "^45.0.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the same argumentation of this package independency from the lace monorepo I would keep all the required tooling packages here.

@@ -1,4 +1,5 @@
const convertVersionFormat = (version: string) => version.replace(/\./g, '_');
// eslint-disable-next-line unicorn/prefer-string-replace-all
const convertVersionFormat = (version: string) => version.replace('.', '_');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now only the first occurrence of . will be replaced and I thing it is an incorrect behaviour. Consider reverting this change.

@@ -45,7 +45,8 @@ class TokensPageAssert {
await t('browserView.assets.totalWalletBalance')
);
await expect(await tokensPage.getTotalBalanceCurrency()).to.equal('USD');
const actualTotalBalance = Number(((await tokensPage.getTotalBalanceValue()) as string).replace(/,/g, ''));
// eslint-disable-next-line unicorn/prefer-string-replace-all
const actualTotalBalance = Number(((await tokensPage.getTotalBalanceValue()) as string).replace(',', ''));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now only the first occurrence of , will be replaced and I might be an incorrect behaviour. Please ensure this change won't introduce any problem

@@ -165,4 +165,4 @@ export const getWalletName = (): string => {
export const getLastActiveTab: () => Promise<Tabs.Tab> = async () =>
await (
await tabs.query({ currentWindow: true, active: true })
)[0];
)[0]; // eslint-disable-line unicorn/no-await-expression-member
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider disabling this rule.

@przemyslaw-wlodek przemyslaw-wlodek marked this pull request as draft September 5, 2023 06:12
@settings settings bot removed the ui-toolkit label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser Changes to the browser application.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants