Skip to content

feat: eliminate unused imports#132

Merged
mnahkies merged 2 commits intomainfrom
mn/feat/no-unused-imports
Mar 2, 2024
Merged

feat: eliminate unused imports#132
mnahkies merged 2 commits intomainfrom
mn/feat/no-unused-imports

Conversation

@mnahkies
Copy link
Owner

@mnahkies mnahkies commented Mar 2, 2024

  • uses hacky method of filtering out imports based on crude tokenization
  • includes cli parameter escape hatch to turn off in-case it's buggy

tried using biome first, with some code like this (private methods used):

 // @ts-ignore
    const linted = biome.withFile(filename, raw, (path) => {
      // @ts-ignore
      const result = biome.workspace.fixFile({
        path,
        fix_file_mode: "SafeAndUnsafeFixes",
        should_format: false
      })
      return result.code
    })

but this was ludicrously slow, even with all rules apart from unused imports disabled

body: ${
bodyParamSchema
? `parseRequestInput(${operation.operationId}BodySchema, ctx.request.body, RequestInputType.RequestBody)`
? `parseRequestInput(${operation.operationId}BodySchema, Reflect.get(ctx.request, "body"), RequestInputType.RequestBody)`
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes the need to import from koa-body to keep typescript happy

Base automatically changed from mn/fix/strict-typescript to main March 2, 2024 14:03
mnahkies added 2 commits March 2, 2024 14:03
- uses hacky method of filtering out imports based on crude tokenization
- includes cli parameter escape hatch to turn off in-case it's buggy
@mnahkies mnahkies force-pushed the mn/feat/no-unused-imports branch from 595e85f to e9cf21c Compare March 2, 2024 14:04
@mnahkies mnahkies marked this pull request as ready for review March 2, 2024 14:04
@mnahkies mnahkies enabled auto-merge (squash) March 2, 2024 14:04
@mnahkies mnahkies merged commit c3d87ce into main Mar 2, 2024
@mnahkies mnahkies deleted the mn/feat/no-unused-imports branch March 2, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant