Skip to content

Commit

Permalink
Fix missing envvar caused by bad import order
Browse files Browse the repository at this point in the history
Fix in prettier config itself
  • Loading branch information
tonyxiao committed Sep 7, 2022
1 parent d428f82 commit 8ef5181
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
6 changes: 4 additions & 2 deletions apps/cli/_cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import '@ledger-sync/app-config/register.node'
import type {CliOpts} from './cli-utils'
import {cliFromZFunctionMap} from './cli-utils'

import {dotEnvOut} from '@ledger-sync/app-config/register.node'
import {makePostgresKVStore} from '@ledger-sync/core-integration-postgres'
import {makeOneBrickClient} from '@ledger-sync/integration-onebrick'
Expand All @@ -19,6 +18,9 @@ import {makeYodleeClient} from '@ledger-sync/integration-yodlee'
import type {ZFunctionMap} from '@ledger-sync/util'
import {R, safeJSONParse, z, zodInsecureDebug} from '@ledger-sync/util'

import type {CliOpts} from './cli-utils'
import {cliFromZFunctionMap} from './cli-utils'

if (process.env['DEBUG_ZOD']) {
zodInsecureDebug()
}
Expand Down
17 changes: 11 additions & 6 deletions apps/cli/ledgerSync-cli.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/usr/bin/env tsx
// This import line gets frequently moved by vscode organize imports

This comment has been minimized.

Copy link
@yenbekbay

yenbekbay Sep 8, 2022

Contributor

Just don't use "organize imports". Prettier plugin is aware of side-effect imports and will not move stuff around

This comment has been minimized.

Copy link
@tonyxiao

tonyxiao Sep 8, 2022

Author Contributor

Hmm but then how do you automatically remove unused imports for example? the prettier plugin doesn't do that.

This comment has been minimized.

Copy link
@yenbekbay

yenbekbay Sep 8, 2022

Contributor

I see what you mean. Let me think a bit

This comment has been minimized.

Copy link
@yenbekbay

yenbekbay Sep 9, 2022

Contributor

They're going to add an option to only remove unused imports (without ordering) in the next TS version: microsoft/TypeScript#43141. In the meantime, there's this extension https://marketplace.visualstudio.com/items?itemName=kuscamara.remove-unused-imports

This comment has been minimized.

Copy link
@yenbekbay

yenbekbay Sep 9, 2022

Contributor

Let's keep it like this for now but then remove once the new TS version ships

This comment has been minimized.

Copy link
@tonyxiao

tonyxiao Sep 9, 2022

Author Contributor

Ah cool. you mean keep the extra whitespace for now and remove it when new TS Version ships? Or remove the whitespace and start using the VSCode extension rather than organizeImports?

// and thus causing runtime failure... Therefore we moved it to the ledgerSync bin
import '@ledger-sync/app-config/register.node'

import {nodeHTTPRequestHandler} from '@trpc/server/adapters/node-http'
import http from 'http'
import {json} from 'micro'
import ngrok from 'ngrok'

import type {LedgerSyncRouter} from '@ledger-sync/app-config'
import {
ledgerSyncMetaStore as metaStore,
ledgerSyncRouter as router,
} from '@ledger-sync/app-config'
import '@ledger-sync/app-config/register.node'
import {cliFromRouter} from './cli-utils'
import type {inferProcedureInput} from '@ledger-sync/engine'
import {parseWebhookRequest} from '@ledger-sync/engine'
import type {NonEmptyArray} from '@ledger-sync/util'
Expand All @@ -17,10 +24,8 @@ import {
zFunction,
zodInsecureDebug,
} from '@ledger-sync/util'
import {nodeHTTPRequestHandler} from '@trpc/server/adapters/node-http'
import http from 'http'
import {json} from 'micro'
import ngrok from 'ngrok'

import {cliFromRouter} from './cli-utils'

if (!process.env['DEBUG']) {
console.debug = () => {} // Disabling debug logs
Expand Down
3 changes: 3 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ module.exports = {
arrowParens: 'always',
bracketSameLine: true,
bracketSpacing: false,
importOrder: ['<THIRD_PARTY_MODULES>', '^@ledger-sync/(.*)$', '^[./]'],
importOrderCaseInsensitive: true,
importOrderSortSpecifiers: true,
importOrderGroupNamespaceSpecifiers: true,
importOrderSeparation: true, // Very important to make sure register files are imported first...

This comment has been minimized.

Copy link
@yenbekbay

yenbekbay Sep 8, 2022

Contributor

I'm not a fan of extra blank lines personally. Would prefer to not have them unless you feel strongly about this

This comment has been minimized.

Copy link
@tonyxiao

tonyxiao Sep 8, 2022

Author Contributor

I guess we can get rid of importOrder? Then it would only preserve manually added extra lines in imports.

This comment has been minimized.

Copy link
@yenbekbay

yenbekbay Sep 8, 2022

Contributor

I like import order just not the blank lines

jsxSingleQuote: false,
plugins: [
require.resolve('@ianvs/prettier-plugin-sort-imports'),
Expand Down

0 comments on commit 8ef5181

Please sign in to comment.