Skip to content
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

Added automatic linting to the repository #23

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ coverage
downloads
# dont lint examples
examples
# don't lint the contract folder since we dont want to mess with it
/tools/contract/
22 changes: 22 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,26 @@ module.exports = {
'testing-library/prefer-screen-queries': 0,
'turbo/no-undeclared-env-vars': 0,
},

overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'prettier',
'plugin:prettier/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:cypress/recommended',
'plugin:ui-testing/cypress',
'plugin:testing-library/react',
'turbo',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
},
],
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't have TS files. They're TS files in the tools folder but we've skipped lining in that folder. Why are we adding this configuration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

index.d.ts which defines types of all our commands.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need to configure ESLint for specifically one TS file. Plus we don't have any plans to transition to TS. I feel it is not required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the files exists in the repository and we will be adding code to it in the future. i think its best that we add support for typescript eslint now. rather than lets seperately

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, we will be updating that file. But adding this whole config just for one TS file isn't a overhead?

};
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm lint-staged
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/tools/contract/
13 changes: 8 additions & 5 deletions commands/keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,17 +270,20 @@ const keplr = {
async getWalletAddress(chainName) {
playwright.switchToKeplrWindow();
await module.exports.goToHome();
const newTokensSelctorExists = await playwright.waitForAndCheckElementExistence(
homePageElements.newTokensFoundSelector,
);
const newTokensSelctorExists =
await playwright.waitForAndCheckElementExistence(
homePageElements.newTokensFoundSelector,
);

if (newTokensSelctorExists) {
await module.exports.addNewTokensFound(false);
}

await playwright.waitAndClickByText(notificationPageElements.copyAddress);
await playwright.waitAndClick(notificationPageElements.walletSelectors(chainName))

await playwright.waitAndClick(
notificationPageElements.walletSelectors(chainName),
);

walletAddress = clipboardy.readSync();
await playwright.switchToCypressWindow();
return walletAddress;
Expand Down
4 changes: 2 additions & 2 deletions commands/playwright-keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ module.exports = {
throw new Error(`Failed to click element after ${maxRetries} attempts`);
},
async waitAndClickWithDelay(selector, options, delay) {
const page = module.exports.keplrWindow()
await page.waitForTimeout(delay)
const page = module.exports.keplrWindow();
await page.waitForTimeout(delay);
await module.exports.waitAndClick(selector, page, options);
},
async switchToKeplrNotification() {
Expand Down
5 changes: 2 additions & 3 deletions helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,8 @@ module.exports = {
release.tagName,
'manifest.json',
);
const extensionManifestFileExists = await module.exports.checkDirOrFileExist(
extensionManifestFilePath,
);
const extensionManifestFileExists =
await module.exports.checkDirOrFileExist(extensionManifestFilePath);
if (!extensionDirectoryExists && !extensionManifestFileExists) {
await module.exports.download(release.downloadUrl, extensionDirectory);
} else {
Expand Down
27 changes: 20 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@
"bin": {
"synpress": "synpress.js"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --quiet --fix"
],
"*.{json,js,ts,jsx,tsx,html}": [
"prettier --write --ignore-unknown"
]
},
"scripts": {
"fix": "turbo fix:eslint fix:prettier --concurrency 1",
"fix:eslint": "eslint --fix **/*.js",
"fix:prettier": "prettier --write **/*.js",
"fix:eslint": "eslint . --ext .js,.ts,.jsx,.tsx --fix",
"fix:prettier": "prettier --write **/*.{js,json,ts,tsx,html}",
"lint": "turbo lint:eslint lint:prettier",
"lint:eslint": "eslint . --ext js",
"lint:prettier": "prettier --check **/*.js",
"lint:eslint": "eslint . --ext .js,.ts,.jsx,.tsx",
"lint:prettier": "prettier --check **/*.{js,json,ts,tsx,html}",
"lint:sarif": "node lint.js . --ext js",
"release": "release-it --disable-metrics",
"release:major": "release-it major --disable-metrics",
Expand All @@ -53,7 +61,8 @@
"test:e2e:ci:anvil": "start-server-and-test 'turbo start:server' http-get://localhost:3000 'CYPRESS_USE_ANVIL=true pnpm synpress:run --record --group'",
"test:e2e:ci:cypress-action": "CYPRESS_USE_ANVIL=true pnpm synpress:run",
"synpress:run:keplr": "CYPRESS_SPEC_PATTERN=tests/e2e/specs/keplr/** EXTENSION=keplr SKIP_EXTENSION_SETUP=true SYNPRESS_LOCAL_TEST=true node synpress.js run --configFile=synpress.config.js",
"test:e2e:keplr": "start-server-and-test 'pnpm start:ui' http-get://localhost:3000 'pnpm start:json-server' http-get://localhost:3004 'pnpm synpress:run:keplr'"
"test:e2e:keplr": "start-server-and-test 'pnpm start:ui' http-get://localhost:3000 'pnpm start:json-server' http-get://localhost:3004 'pnpm synpress:run:keplr'",
"prepare": "husky"
},
"dependencies": {
"@cypress/code-coverage": "^3.11.0",
Expand Down Expand Up @@ -93,8 +102,10 @@
"devDependencies": {
"@metamask/test-dapp": "^7.0.1",
"@microsoft/eslint-formatter-sarif": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-config-turbo": "^1.10.12",
"eslint-plugin-chai-friendly": "^0.7.2",
Expand All @@ -107,9 +118,11 @@
"eslint-plugin-testing-library": "^6.0.0",
"eslint-plugin-ui-testing": "^2.0.1",
"eslint-plugin-unicorn": "^48.0.1",
"husky": "^9.0.11",
"json-server": "1.0.0-alpha.23",
"lint-staged": "^15.2.2",
"npm-check-updates": "^16.12.2",
"prettier": "^3.0.2",
"prettier": "^3.2.5",
"release-it": "^16.1.5",
"serve": "^14.2.0",
"start-server-and-test": "^2.0.0",
Expand Down
8 changes: 4 additions & 4 deletions pages/keplr/first-time-flow-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const phraseAccountCreated = 'Account Created!';
const finishButton = 'button[type="button"]';
const textAreaSelector = 'textbox';
const submitPhraseButton = 'button[type="submit"]';
const chainName = 'Agoric local'
const chainNameSelector = 'text=Agoric local'
const importButtonSelector = 'button:has-text("Import")'
const chainName = 'Agoric local';
const chainNameSelector = 'text=Agoric local';
const importButtonSelector = 'button:has-text("Import")';

module.exports.onboardingElements = {
existingWalletButton,
Expand All @@ -37,5 +37,5 @@ module.exports.onboardingElements = {
finishButton,
textAreaSelector,
submitPhraseButton,
chainName
chainName,
};
4 changes: 2 additions & 2 deletions pages/keplr/home-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ const tokenParentSelector = '../../../..';
const selectAllTokensCheck = 'input[type="checkbox"]:enabled';
const newTokensFound = 'new token(s) found';
const addChainsButton = 'Add Chains';
const newTokensFoundSelector = 'text=new token(s) found'
const newTokensFoundSelector = 'text=new token(s) found';

module.exports.homePageElements = {
tokenNameLabel,
tokenParentSelector,
selectAllTokensCheck,
newTokensFound,
addChainsButton,
newTokensFoundSelector
newTokensFoundSelector,
};
2 changes: 1 addition & 1 deletion pages/keplr/notification-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ const walletSelectors = chainName => `img[alt="${chainName}"]`;
module.exports.notificationPageElements = {
approveButton,
copyAddress,
walletSelectors
walletSelectors,
};
3 changes: 2 additions & 1 deletion plugins/metamask-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ module.exports = (on, config) => {
if (!process.env.SKIP_METAMASK_INSTALL) {
// NOTE: extensions cannot be loaded in headless Chrome
const metamaskPath = await helpers.prepareExtension(
process.env.METAMASK_VERSION || '10.25.0', process.env.EXTENSION
process.env.METAMASK_VERSION || '10.25.0',
process.env.EXTENSION,
);
arguments_.extensions.push(metamaskPath);
}
Expand Down
Loading
Loading