Skip to content

Commit

Permalink
move eslint and prettier into packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Yolley committed Feb 21, 2024
1 parent 282427b commit 06e2d39
Show file tree
Hide file tree
Showing 57 changed files with 1,242 additions and 670 deletions.
86 changes: 86 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"extends": [
"airbnb-typescript",
"plugin:jest/recommended",
"plugin:import/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"plugins": [
"@typescript-eslint",
"jest",
"import",
"prettier"
],
"env": {
"browser": true,
"es6": true,
"jest": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "../../tsconfig.json"
},
"ignorePatterns": [
"**/dist/**/*"
],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"react/jsx-filename-extension": "off",
"@typescript-eslint/no-throw-literal": "off",
"no-debugger": "warn",
"no-console": "warn",
"import/prefer-default-export": "off",
"no-plusplus": "off",
"import/named": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/ban-ts-comment": "off",
"no-param-reassign": "off",
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/no-shadow": "warn",
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/explicit-module-boundary-types": "warn",
"import/no-extraneous-dependencies": "warn",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"import/newline-after-import": "error",
"import/order": [
"error",
{
"groups": [
[
"builtin",
"external"
],
"internal"
],
"newlines-between": "always"
}
],
"no-multiple-empty-lines": [
"error",
{
"max": 1,
"maxEOF": 1
}
],
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "export",
"next": [
"expression",
"const"
]
}
]
}
}
84 changes: 2 additions & 82 deletions packages/common/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,85 +1,5 @@
{
"extends": [
"airbnb-typescript",
"plugin:jest/recommended",
"plugin:import/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"plugins": [
"@typescript-eslint",
"jest",
"import"
],
"env": {
"browser": true,
"es6": true,
"jest": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "../../tsconfig.json"
},
"ignorePatterns": [
"**/dist/**/*"
],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"react/jsx-filename-extension": "off",
"@typescript-eslint/no-throw-literal": "off",
"no-debugger": "warn",
"no-console": "warn",
"import/prefer-default-export": "off",
"no-plusplus": "off",
"import/named": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/ban-ts-comment": "off",
"no-param-reassign": "off",
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/no-shadow": "warn",
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/explicit-module-boundary-types": "warn",
"import/no-extraneous-dependencies": "warn",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"import/newline-after-import": "error",
"import/order": [
"error",
{
"groups": [
[
"builtin",
"external"
],
"internal"
],
"newlines-between": "always"
}
],
"no-multiple-empty-lines": [
"error",
{
"max": 1,
"maxEOF": 1
}
],
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "export",
"next": [
"expression",
"const"
]
}
]
}
"@streamflow/eslint-config"
]
}
6 changes: 1 addition & 5 deletions packages/common/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"semi": true,
"printWidth": 100,
"tabWidth": 2,
"arrowParens": "always",
"bracketSpacing": true
"prettier": "@streamflow/prettier-config"
}
10 changes: 3 additions & 7 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,17 @@
"scripts": {
"build": "rm -rf dist; tsc -p tsconfig.json",
"pack": "npm pack",
"lint": "eslint .",
"lint": "eslint --fix .",
"prepublishOnly": "npm run lint && npm test && npm run build"
},
"gitHead": "a37306eba0e762af096db642fa22f07194014cfd",
"devDependencies": {
"@streamflow/eslint-config": "workspace:*",
"@streamflow/prettier-config": "workspace:*",
"@types/bn.js": "5.1.1",
"@types/jest": "29.2.4",
"date-fns": "2.28.0",
"eslint": "8.29.0",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-jest": "27.1.6",
"eslint-plugin-prettier": "4.2.1",
"jest": "29.3.1",
"prettier": "2.8.1",
"ts-jest": "29.0.3",
"typescript": "^4.9.5"
},
Expand Down
13 changes: 11 additions & 2 deletions packages/common/solana/instructions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Connection, PublicKey, SystemProgram, TransactionInstruction } from "@solana/web3.js";
import {
Connection,
PublicKey,
SystemProgram,
TransactionInstruction,
} from "@solana/web3.js";
import BN from "bn.js";
import {
createAssociatedTokenAccountInstruction,
Expand All @@ -12,7 +17,11 @@ export const prepareWrappedAccount = async (
senderAddress: PublicKey,
amount: BN
): Promise<TransactionInstruction[]> => {
const tokenAccount = await getAssociatedTokenAddress(NATIVE_MINT, senderAddress, true);
const tokenAccount = await getAssociatedTokenAddress(
NATIVE_MINT,
senderAddress,
true
);

const accInfo = await connection.getParsedAccountInfo(tokenAccount);

Expand Down
44 changes: 34 additions & 10 deletions packages/common/solana/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,17 @@ export async function signAndExecuteTransaction(
if (!hash.lastValidBlockHeight || !signedTx.signature || !hash.blockhash)
throw Error("Error with transaction parameters.");

const confirmationStrategy: BlockheightBasedTransactionConfirmationStrategy = {
lastValidBlockHeight: hash.lastValidBlockHeight,
signature: bs58.encode(signedTx.signature),
blockhash: hash.blockhash,
};
const signature = await sendAndConfirmRawTransaction(connection, rawTx, confirmationStrategy);
const confirmationStrategy: BlockheightBasedTransactionConfirmationStrategy =
{
lastValidBlockHeight: hash.lastValidBlockHeight,
signature: bs58.encode(signedTx.signature),
blockhash: hash.blockhash,
};
const signature = await sendAndConfirmRawTransaction(
connection,
rawTx,
confirmationStrategy
);
return signature;
}

Expand Down Expand Up @@ -159,7 +164,12 @@ export async function generateCreateAtaBatchTx(
}> {
const ixs: TransactionInstruction[] = await Promise.all(
paramsBatch.map(async ({ mint, owner }) => {
return createAssociatedTokenAccountInstruction(payer, await ata(mint, owner), owner, mint);
return createAssociatedTokenAccountInstruction(
payer,
await ata(mint, owner),
owner,
mint
);
})
);
const hash = await connection.getLatestBlockhash();
Expand All @@ -183,8 +193,17 @@ export async function createAtaBatch(
invoker: Keypair | SignerWalletAdapter,
paramsBatch: AtaParams[]
): Promise<string> {
const { tx, hash } = await generateCreateAtaBatchTx(connection, invoker.publicKey!, paramsBatch);
const signature = await signAndExecuteTransaction(connection, invoker, tx, hash);
const { tx, hash } = await generateCreateAtaBatchTx(
connection,
invoker.publicKey!,
paramsBatch
);
const signature = await signAndExecuteTransaction(
connection,
invoker,
tx,
hash
);
return signature;
}

Expand Down Expand Up @@ -212,7 +231,12 @@ export async function checkOrCreateAtaBatch(
for (let i = 0; i < response.length; i++) {
if (!response[i]) {
ixs.push(
createAssociatedTokenAccountInstruction(invoker.publicKey!, atas[i], owners[i], mint)
createAssociatedTokenAccountInstruction(
invoker.publicKey!,
atas[i],
owners[i],
mint
)
);
}
}
Expand Down
84 changes: 2 additions & 82 deletions packages/distributor/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,85 +1,5 @@
{
"extends": [
"airbnb-typescript",
"plugin:jest/recommended",
"plugin:import/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"plugins": [
"@typescript-eslint",
"jest",
"import"
],
"env": {
"browser": true,
"es6": true,
"jest": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "../../tsconfig.json"
},
"ignorePatterns": [
"**/dist/**/*"
],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"react/jsx-filename-extension": "off",
"@typescript-eslint/no-throw-literal": "off",
"no-debugger": "warn",
"no-console": "warn",
"import/prefer-default-export": "off",
"no-plusplus": "off",
"import/named": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/ban-ts-comment": "off",
"no-param-reassign": "off",
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/no-shadow": "warn",
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/explicit-module-boundary-types": "warn",
"import/no-extraneous-dependencies": "warn",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"import/newline-after-import": "error",
"import/order": [
"error",
{
"groups": [
[
"builtin",
"external"
],
"internal"
],
"newlines-between": "always"
}
],
"no-multiple-empty-lines": [
"error",
{
"max": 1,
"maxEOF": 1
}
],
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "export",
"next": [
"expression",
"const"
]
}
]
}
"@streamflow/eslint-config"
]
}
Loading

0 comments on commit 06e2d39

Please sign in to comment.