Skip to content

Commit

Permalink
🦺 chore: Stricter tsconfig.json (#380)
Browse files Browse the repository at this point in the history
## Description

Add more stricter than strict mode tsconfig options

## Testing

Explain the quality checks that have been done on the code changes

## Additional Information

- [ ] I read the [contributing docs](../docs/contributing.md) (if this
is your first contribution)

Your ENS/address:

Co-authored-by: Will Cory <[email protected]>
  • Loading branch information
roninjin10 and Will Cory authored Jul 24, 2023
1 parent 0ff53e7 commit 02a8468
Show file tree
Hide file tree
Showing 31 changed files with 121 additions and 311 deletions.
12 changes: 10 additions & 2 deletions bundlers/bundler/src/bundler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { bundler } from './bundler'
import { resolveArtifacts, resolveArtifactsSync } from './solc'
import { Bundler, ModuleInfo } from './types'
import type { Bundler, ModuleInfo } from './types'
import { writeFileSync } from 'fs'
import * as ts from 'typescript'
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import {
type Mock,
afterEach,
beforeEach,
describe,
expect,
it,
vi,
} from 'vitest'

const erc20Abi = [
{
Expand Down
2 changes: 1 addition & 1 deletion bundlers/bundler/src/runtime/generateEvmtsBody.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generateDtsBody } from './generateEvmtsBodyDts'
import { ResolvedConfig } from '@evmts/config'
import type { ResolvedConfig } from '@evmts/config'

type Artifacts = Record<
string,
Expand Down
2 changes: 1 addition & 1 deletion bundlers/bundler/src/runtime/generateEvmtsBodyDts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getEtherscanLinks } from '../utils'
import { ResolvedConfig } from '@evmts/config'
import type { ResolvedConfig } from '@evmts/config'

type Artifacts = Record<
string,
Expand Down
6 changes: 3 additions & 3 deletions bundlers/bundler/src/runtime/generateRuntime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Artifacts } from '../solc/resolveArtifactsSync'
import { Logger } from '../types'
import type { Artifacts } from '../solc/resolveArtifactsSync'
import type { Logger } from '../types'
import { generateEvmtsBody } from './generateEvmtsBody'
import { ResolvedConfig } from '@evmts/config'
import type { ResolvedConfig } from '@evmts/config'

// TODO make this actually async
export const generateRuntime = async (
Expand Down
11 changes: 9 additions & 2 deletions bundlers/bundler/src/runtime/generateRuntimeSync.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { Artifacts } from '../solc/resolveArtifactsSync'
import type { Artifacts } from '../solc/resolveArtifactsSync'
import { generateEvmtsBody } from './generateEvmtsBody'
import { generateRuntimeSync } from './generateRuntimeSync'
import { defaultConfig } from '@evmts/config'
import { MockedFunction, beforeEach, describe, expect, it, vi } from 'vitest'
import {
type MockedFunction,
beforeEach,
describe,
expect,
it,
vi,
} from 'vitest'

vi.mock('./generateEvmtsBody', () => ({ generateEvmtsBody: vi.fn() }))
const mockGenerateEvmtsBody = generateEvmtsBody as MockedFunction<
Expand Down
6 changes: 3 additions & 3 deletions bundlers/bundler/src/runtime/generateRuntimeSync.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Artifacts } from '../solc/resolveArtifactsSync'
import { Logger } from '../types'
import type { Artifacts } from '../solc/resolveArtifactsSync'
import type { Logger } from '../types'
import { generateEvmtsBody } from './generateEvmtsBody'
import { ResolvedConfig } from '@evmts/config'
import type { ResolvedConfig } from '@evmts/config'

export const generateRuntimeSync = (
artifacts: Artifacts,
Expand Down
12 changes: 10 additions & 2 deletions bundlers/bundler/src/solc/compileContracts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import type { ModuleInfo } from '../types'
import { compileContractSync } from './compileContracts'
import { moduleFactory } from './moduleFactory'
import { ResolvedConfig } from '@evmts/config'
import type { ResolvedConfig } from '@evmts/config'
import { readFileSync } from 'fs'
import * as resolve from 'resolve'
// TODO wrap this in a typesafe version
// @ts-ignore
import solc from 'solc'
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import {
type Mock,
afterEach,
beforeEach,
describe,
expect,
it,
vi,
} from 'vitest'

// Mock the necessary functions and modules
vi.mock('fs', () => ({ readFileSync: vi.fn() }))
Expand Down
2 changes: 1 addition & 1 deletion bundlers/bundler/src/solc/compileContracts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ModuleInfo } from '../types'
import { moduleFactory } from './moduleFactory'
import { ResolvedConfig } from '@evmts/config'
import type { ResolvedConfig } from '@evmts/config'
import { readFileSync } from 'fs'
import * as resolve from 'resolve'
// TODO wrap this in a typesafe version
Expand Down
10 changes: 9 additions & 1 deletion bundlers/bundler/src/solc/moduleFactory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import type { ModuleInfo } from '../types'
import { moduleFactory } from './moduleFactory'
import { readFileSync } from 'fs'
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import {
type Mock,
afterEach,
beforeEach,
describe,
expect,
it,
vi,
} from 'vitest'

vi.mock('fs', () => ({
readFileSync: vi.fn(),
Expand Down
13 changes: 10 additions & 3 deletions bundlers/bundler/src/solc/resolveArtifacts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { Logger, ModuleInfo } from '../types'
import type { Logger, ModuleInfo } from '../types'
import { compileContractSync } from './compileContracts'
import { resolveArtifacts } from './resolveArtifacts'
import { ResolvedConfig, defaultConfig } from '@evmts/config'
import { MockedFunction, afterEach, describe, expect, it, vi } from 'vitest'
import { type ResolvedConfig, defaultConfig } from '@evmts/config'
import {
type MockedFunction,
afterEach,
describe,
expect,
it,
vi,
} from 'vitest'

vi.mock('./compileContracts', () => ({
compileContractSync: vi.fn(),
Expand Down
4 changes: 2 additions & 2 deletions bundlers/bundler/src/solc/resolveArtifacts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Logger, ModuleInfo } from '../types'
import type { Logger, ModuleInfo } from '../types'
import { resolveArtifactsSync } from './resolveArtifactsSync'
import { ResolvedConfig } from '@evmts/config'
import type { ResolvedConfig } from '@evmts/config'

/**
* Currently unimplemented just uses resolveArtifactsSync
Expand Down
13 changes: 10 additions & 3 deletions bundlers/bundler/src/solc/resolveArtifactsSync.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { Logger, ModuleInfo } from '../types'
import type { Logger, ModuleInfo } from '../types'
import { compileContractSync } from './compileContracts'
import { resolveArtifactsSync } from './resolveArtifactsSync'
import { ResolvedConfig, defaultConfig } from '@evmts/config'
import { MockedFunction, afterEach, describe, expect, it, vi } from 'vitest'
import { type ResolvedConfig, defaultConfig } from '@evmts/config'
import {
type MockedFunction,
afterEach,
describe,
expect,
it,
vi,
} from 'vitest'

vi.mock('./compileContracts', () => ({
compileContractSync: vi.fn(),
Expand Down
4 changes: 2 additions & 2 deletions bundlers/bundler/src/solc/resolveArtifactsSync.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Logger, ModuleInfo } from '../types'
import type { Logger, ModuleInfo } from '../types'
import { compileContractSync } from './compileContracts'
import { ResolvedConfig } from '@evmts/config'
import type { ResolvedConfig } from '@evmts/config'

export type Artifacts = Record<
string,
Expand Down
4 changes: 2 additions & 2 deletions bundlers/bundler/src/unplugin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { bundler } from './bundler'
import { unpluginFn } from './unplugin'
import { loadConfig } from '@evmts/config'
import { UnpluginBuildContext, UnpluginContext } from 'unplugin'
import { Mock, beforeEach, describe, expect, it, vi } from 'vitest'
import type { UnpluginBuildContext, UnpluginContext } from 'unplugin'
import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'

vi.mock('@evmts/config', async () => ({
...((await vi.importActual('@evmts/config')) as {}),
Expand Down
4 changes: 2 additions & 2 deletions bundlers/bundler/src/unplugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { bundler } from './bundler'
import { ResolvedConfig, loadConfig } from '@evmts/config'
import { UnpluginFactory, createUnplugin } from 'unplugin'
import { type ResolvedConfig, loadConfig } from '@evmts/config'
import { type UnpluginFactory, createUnplugin } from 'unplugin'
import { z } from 'zod'

const compilerOptionValidator = z
Expand Down
4 changes: 2 additions & 2 deletions bundlers/bundler/src/utils/checkSolcVersion.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Logger } from '../types'
import { ResolvedConfig } from '@evmts/config'
import type { Logger } from '../types'
import type { ResolvedConfig } from '@evmts/config'
// TODO wrap this in a typesafe version
// @ts-ignore
import solc from 'solc'
Expand Down
4 changes: 2 additions & 2 deletions bundlers/config/src/defineConfig.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from '.'
import { EvmtsConfig, defaultConfig } from './Config'
import { type EvmtsConfig, defaultConfig } from './Config'
import { execSync } from 'child_process'
import { MockedFunction, describe, expect, it, vi } from 'vitest'
import { type MockedFunction, describe, expect, it, vi } from 'vitest'

vi.mock('child_process', () => ({
execSync: vi.fn(),
Expand Down
2 changes: 1 addition & 1 deletion bundlers/config/src/defineConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EvmtsConfig, ResolvedConfig, defaultConfig } from './Config'
import { type EvmtsConfig, type ResolvedConfig, defaultConfig } from './Config'
import { handleDeprecations } from './handleDeprecations'
import { execSync } from 'child_process'
import * as path from 'path'
Expand Down
4 changes: 2 additions & 2 deletions bundlers/config/src/handleDeprecations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EvmtsConfig } from './Config'
import { DeprecatedConfig, handleDeprecations } from './handleDeprecations'
import type { EvmtsConfig } from './Config'
import { type DeprecatedConfig, handleDeprecations } from './handleDeprecations'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'

describe(handleDeprecations.name, () => {
Expand Down
6 changes: 5 additions & 1 deletion bundlers/config/src/handleDeprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
// deployments?: Record<string, DeploymentConfig>
// forge?: ForgeConfig

import { CompilerConfig, EvmtsConfig, LocalContractsConfig } from './Config'
import type {
CompilerConfig,
EvmtsConfig,
LocalContractsConfig,
} from './Config'

export interface DeprecatedConfig extends EvmtsConfig {
deployments?: LocalContractsConfig['contracts']
Expand Down
2 changes: 1 addition & 1 deletion bundlers/config/src/loadConfig.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EvmtsConfig, defaultConfig, loadConfig } from '.'
import { type EvmtsConfig, defaultConfig, loadConfig } from '.'
import * as cp from 'child_process'
import * as fs from 'fs'
import { beforeEach, describe, expect, it, vi } from 'vitest'
Expand Down
2 changes: 1 addition & 1 deletion bundlers/config/src/loadConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EvmtsConfig, ResolvedConfig, defaultConfig } from './Config'
import { type EvmtsConfig, type ResolvedConfig, defaultConfig } from './Config'
import { defineConfig } from './defineConfig'
import { readFileSync } from 'fs'
import * as path from 'path'
Expand Down
2 changes: 1 addition & 1 deletion examples/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@types/react-dom": "^18.2.6",
"eslint": "^8.44.0",
"eslint-config-next": "^13.4.9",
"solc": "0.8.19",
"solc": "0.8.20",
"typescript": "^5.1.6"
}
}
2 changes: 1 addition & 1 deletion examples/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"react-helmet": "^6.1.0",
"rome": "^12.1.3",
"serve": "^14.2.0",
"solc": "0.8.19",
"solc": "0.8.20",
"typescript": "^5.1.6",
"vite": "^4.3.9",
"vitest": "^0.33.0"
Expand Down
2 changes: 1 addition & 1 deletion lsp/vscode/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DiagnosticModel, InitializationOptions } from '@volar/language-server'
import { DiagnosticModel, type InitializationOptions } from '@volar/language-server'
import { activateAutoInsertion } from '@volar/vscode'
import * as vscode from 'vscode'
import * as lsp from 'vscode-languageclient/node'
Expand Down
Loading

0 comments on commit 02a8468

Please sign in to comment.