Skip to content

Commit

Permalink
format & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Dec 12, 2023
1 parent c695de2 commit 129528f
Show file tree
Hide file tree
Showing 26 changed files with 847 additions and 379 deletions.
31 changes: 1 addition & 30 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:react-hooks/recommended",
"react-app",
"prettier"
],
"parser": "@typescript-eslint/parser",
Expand All @@ -20,40 +18,13 @@
"tsconfigRootDir": "./",
"project": "./tsconfig.json"
},
"plugins": ["react", "ternary", "prettier"],
"plugins": ["prettier", "cypress"],
"rules": {
"react/jsx-max-props-per-line": [
"error",
{
"maximum": {
"single": 1,
"multi": 1
}
}
],
"trailingComma": "off",
"ternary/nesting": "off",
"ternary/no-dupe": "error",
"ternary/no-unreachable": "off",
"object-curly-spacing": ["error", "always"],
"react/jsx-tag-spacing": "error",
"prettier/prettier": "error"
},
"overrides": [
{
"files": ["*.ts", "*tsx", "*.js", "*.jsx"],
"processor": "@graphql-eslint/graphql"
},
{
"files": ["*.graphql"],
"extends": "plugin:@graphql-eslint/schema-recommended",
"rules": {
"@graphql-eslint/known-type-names": "error"
},
"parserOptions": {
"schema": "http://localhost:4350/graphql"
}
}
],
"ignorePatterns": ["src/interfaces/**/*", "types-and-hooks.tsx", "src/gql/**/*"]
}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@
#!.yarn/cache
.pnp.*
node_modules
dist
packages/**/dist
packages/**/dist
packages/**/dist
packages/**/dist
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.yarn
lib/**/*
build/**/*
build/**/*
packages/**/dist/**/*
14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,13 @@
"scripts": {
"dev": "cypress open",
"build": "tsc",
"lint": "yarn eslint './{src,cypress}/**/*.ts'",
"format": "yarn prettier --write './{src,cypress}/**/*.ts'",
"format-check": "yarn prettier --check './{src,cypress}/**/*.ts'"
"lint": "yarn workspaces foreach --all run lint",
"formatAll": "yarn workspaces foreach --all run format",
"formatAll-check": "yarn workspaces foreach --all run format-check"
},
"workspaces": [
"packages/*"
],
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"eslint": "^8.55.0",
"eslint-plugin-cypress": "^2.15.1",
"prettier": "^3.1.0",
"typescript": "^5.3.3"
},
"peerDependencies": {
"cypress": ">=10"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/example/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineConfig } from "cypress";
import { defineConfig } from 'cypress'

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
}
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
describe('test cypress-polkadot-wallet plugin', function () {
beforeEach(function () {
cy.visit('http://localhost:3333');
});
it('should check if plugin is installed', function () {
expect(cy).property('initExtension').to.be.a('function');
});
it('should init the extension and connect accounts', function () {
cy.initExtension([
{
address: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
publicKey: '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d',
name: 'Alice',
type: 'sr25519',
mnemonic: 'bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice'
}
]);
cy.get('#connect-accounts').click();
cy.wait(1000);
cy.getAuthRequests().then(function (authRequests) {
var requests = Object.values(authRequests);
// we should have 1 connection request to the extension
cy.wrap(requests.length).should('eq', 1);
// this request should be from the application Multix
cy.wrap(requests[0].origin).should('eq', 'example-dapp');
cy.enableAuth(requests[0].id, ['5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY']);
});
});
});
25 changes: 25 additions & 0 deletions packages/example/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
2 changes: 1 addition & 1 deletion packages/example/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
21 changes: 21 additions & 0 deletions packages/example/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use strict";
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
Object.defineProperty(exports, "__esModule", { value: true });
// Import commands.js using ES2015 syntax:
require("./commands");
// Alternatively you can use CommonJS syntax:
// require('./commands')
require("@chainsafe/cypress-polkadot-wallet");
21 changes: 15 additions & 6 deletions packages/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="icon"
type="image/svg+xml"
href="/vite.svg"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<title>Vite + TS</title>
</head>
<body>
<div id="app">
<button id="connect-accounts">Connect</button>
<div id="injected">
</div>
<di id="all-accounts"></di>
<div id="injected"></div>
<di id="all-accounts"></di>
</div>
<script type="module" src="/src/main.ts"></script>
<script
type="module"
src="/src/main.ts"
></script>
</body>
</html>
13 changes: 12 additions & 1 deletion packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@
"build": "tsc && vite build",
"preview": "vite preview",
"start": "yarn vite serve --port 3333",
"test": "cypress open"
"test": "cypress open",
"lint": "yarn eslint './{src, cypress}/**/*.{ts, tsx, js, jsx, json, yml, yaml}'",
"format": "yarn prettier --write .",
"format-check": "yarn prettier --check ."
},
"dependencies": {
"@chainsafe/cypress-polkadot-wallet": "0.0.1",
"@polkadot/extension-dapp": "^0.46.6"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"cypress": "^13.6.1",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-prettier": "^5.0.1",
"prettier": "^3.1.1",
"typescript": "^5.3.3",
"vite": "^5.0.0"
}
}
13 changes: 13 additions & 0 deletions packages/example/src/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupCounter = void 0;
function setupCounter(element) {
var counter = 0;
var setCounter = function (count) {
counter = count;
element.innerHTML = "count is ".concat(counter);
};
element.addEventListener('click', function () { return setCounter(counter + 1); });
setCounter(0);
}
exports.setupCounter = setupCounter;
79 changes: 79 additions & 0 deletions packages/example/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var extension_dapp_1 = require("@polkadot/extension-dapp");
require("./style.css");
// document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
// <div>
// <a href="https://vitejs.dev" target="_blank">
// <img src="${viteLogo}" class="logo" alt="Vite logo" />
// </a>
// <a href="https://www.typescriptlang.org/" target="_blank">
// <img src="${typescriptLogo}" class="logo vanilla" alt="TypeScript logo" />
// </a>
// <h1>Vite + TypeScript</h1>
// <div class="card">
// <button id="counter" type="button"></button>
// </div>
// <p class="read-the-docs">
// Click on the Vite and TypeScript logos to learn more
// </p>
// </div>
// `
console.log('boom');
document
.querySelector('#connect-accounts')
.addEventListener('click', function () { return __awaiter(void 0, void 0, void 0, function () {
var allInjected, allAccounts;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
console.log('click');
return [4 /*yield*/, (0, extension_dapp_1.web3Enable)('example-dapp')];
case 1:
allInjected = _a.sent();
document.querySelector('#injected').innerHTML = JSON.stringify(allInjected);
return [4 /*yield*/, (0, extension_dapp_1.web3Accounts)()];
case 2:
allAccounts = _a.sent();
document.querySelector('#all-accounts').innerHTML = JSON.stringify(allAccounts);
return [2 /*return*/];
}
});
}); });
// setupCounter(document.querySelector<HTMLButtonElement>('#counter')!)
24 changes: 24 additions & 0 deletions packages/plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Loading

0 comments on commit 129528f

Please sign in to comment.