Skip to content

Commit

Permalink
eslint @typescript-eslint/consistent-type-exports & settings
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed May 3, 2023
1 parent b16752c commit 5367af6
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ dist
.serverless
coverage
migrations
test/*.json
test/**/*.json
_
4 changes: 4 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module.exports = {
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['tsconfig.json'],
extraFileExtensions: ['.json'],
warnOnUnsupportedTypeScriptVersion: true,
},
reportUnusedDisableDirectives: true,
Expand All @@ -29,6 +31,8 @@ module.exports = {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
'@typescript-eslint/consistent-type-exports': ['error'],
'@typescript-eslint/no-import-type-side-effects': ['error'],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
13 changes: 9 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{
"eslint.enable": true,
"eslint.format.enable": true,
"window.title": "🦙 ${rootName} ${separator} ${activeEditorMedium} 🦙",
"git.autofetch": true,
"git.enableCommitSigning": true,
"git.inputValidationSubjectLength": 72,
"editor.linkedEditing": true,
"editor.formatOnSave": false,
"npm.packageManager": "pnpm",
"eslint.packageManager": "pnpm",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.enable": true,
"eslint.format.enable": true,
"eslint.packageManager": "pnpm",
"npm.packageManager": "pnpm",
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.preferences.importModuleSpecifier": "non-relative"
Expand Down
2 changes: 1 addition & 1 deletion bench/multi-balanceOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function help() {
}

async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: multi-balanceOf.ts
// argv[2]: chain
// argv[3]: address
Expand Down
2 changes: 1 addition & 1 deletion bench/multicall-balanceOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function help() {
}

async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: multicall-balanceOf.ts
// argv[2]: chain
// argv[3]: address
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
"lint": "eslint --fix . --ext js,cjs,mjs,ts,d.ts,json --cache",
"format": "prettier --write --ignore-path='./.eslintignore' '**/*.{md,json,js,cjs,mjs,ts}' --ignore-unknown --cache",
"typecheck": "tsc --noEmit --skipLibCheck",
"predev-test": "pnpm clean",
"dev-test": "sls offline --httpPort 3034",
"test": "vitest",
"test:ci": "/bin/bash ./scripts/test.sh",
"test:ui": "vitest --ui",
"test:coverage": "vitest --coverage",
"ts-node": "tsx",
"clean": "rm -rf dist .esbuild .serverless",
"preinstall": "npx only-allow pnpm"
},
"keywords": [],
Expand Down
11 changes: 7 additions & 4 deletions scripts/build-adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { chains } from '../src/lib/chains'

const exportsTemplate = (adapters: string[]) => `
${adapters.map((adapter) => `import ${slugify(adapter)} from '@adapters/${adapter}'`).join(';')}
import { Adapter } from '@lib/adapter';
import type { Adapter } from '@lib/adapter';
export const adapters: Adapter[] = [
Expand Down Expand Up @@ -116,7 +116,7 @@ function getAdapters() {
}

async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: build-adapters.ts

const adapters = getAdapters()
Expand All @@ -131,9 +131,12 @@ async function main() {
vsCodeLaunchTemplate(adapters, chains.map((chain) => chain.id).sort()),
)

// lint
execSync('./node_modules/.bin/eslint --fix "./src/adapters/index.ts"')
execSync('./node_modules/.bin/eslint --fix "./.vscode/launch.json"')
// format
execSync(`npx prettier --ignore-path .gitignore --ignore-path .prettierignore 'src/adapters/index.ts' --write`)
execSync(`npx prettier --ignore-path .gitignore --ignore-path .prettierignore '.vscode/launch.json' --write`)
execSync('./node_modules/.bin/prettier --ignore-path="./.eslintignore" "./src/adapters/index.ts" --write')
execSync('./node_modules/.bin/prettier --ignore-path="./.eslintignore" "./.vscode/launch.json" --write')
}

main()
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function help() {
}

async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: create-adapter.ts
// argv[2]: adapter
if (process.argv.length < 3) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/delete-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function help() {
}

async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: delete-adapter.ts
// argv[2]: adapter
if (process.argv.length < 3) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/find-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function help() {
}

async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: find-user.ts
// argv[2]: adapter
// argv[3]: address
Expand Down
2 changes: 1 addition & 1 deletion scripts/provider-bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { call } from '../src/lib/call'
import { abi as erc20Abi } from '../src/lib/erc20'

async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: provider-bench.ts
// argv[2]: ?chain

Expand Down
2 changes: 1 addition & 1 deletion scripts/revalidate-all-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getAdapters() {
* Revalidate contracts of all adapters
*/
async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: revalidate-all-contracts.ts

const adapters = getAdapters()
Expand Down
2 changes: 1 addition & 1 deletion scripts/revalidate-contracts-rec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function help() {
* Recursively revalidate contracts of a chain for a given adapter
*/
async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: revalidate-contracts-rec.ts
// argv[2]: adapter
// argv[3]: chain
Expand Down
2 changes: 1 addition & 1 deletion scripts/revalidate-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function help() {
* Revalidate contracts of all (or given) chain(s) for given adapter
*/
async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: revalidate-contracts.ts
// argv[2]: adapter
// argv[3]: ?chain
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-adapter-balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function help() {
}

async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: run-balances.ts
// argv[2]: adapter
// argv[3]: chain
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function help() {
}

async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: run-adapter.ts
// argv[2]: adapter
// argv[3]: chain
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function help() {
}

async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: update-balances.ts
// argv[2]: address
if (process.argv.length < 3) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function help() {
}

async function main() {
// argv[0]: ts-node
// argv[0]: node_modules/.bin/tsx
// argv[1]: update-tokens.ts
if (process.argv.length < 2) {
console.error('Missing arguments')
Expand Down
4 changes: 2 additions & 2 deletions test/config/get-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function getRoutes({ stage }: { stage: AwsStage | 'local' }): Array<Route

/**
* this function runs aws command to get the routes,
* save to test/network/config/apigateway-routes.json,
* save to test/network/config/routes.json,
* parse the json file and return a list of objects,
* object: method, path, pathParams, queryParams
*/
Expand All @@ -37,7 +37,7 @@ export function getGatewayRoutes(): Array<Route> {
queryParams,
}
}) as Array<Route>
fs.writeFileSync('test/fixtures/apigateway-routes.json', JSON.stringify(routes, undefined, 2))
fs.writeFileSync('test/fixtures/routes.json', JSON.stringify(routes, undefined, 2))
return routes
}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/test-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Chain } from '@lib/chains'
import type { Chain } from '@lib/chains'

export const testAddresses = ['0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045']

Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"alwaysStrict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
"noEmit": false,
"jsx": "preserve",
"allowJs": false,
"noImplicitThis": false,
"noErrorTruncation": true,
Expand All @@ -24,6 +24,6 @@
"@environment": ["./environment.ts"]
}
},
"include": ["src", "scripts", "test", "environment.ts", "bench"],
"exclude": [".esbuild", "node_modules"]
"include": ["src", "scripts", "test", "bench", "*.ts", "*.js", "*.cjs", ".*.cjs", "*.json"],
"exclude": [".esbuild", "node_modules", "coverage", "dist"]
}

0 comments on commit 5367af6

Please sign in to comment.