@feinarbyte/pluginbase
TypeScript icon, indicating that this package has built-in type declarations

5.1.2 • Public • Published

don't repeat your self

coding is fun, but many projects and frameworks end up in a lot of repetetive tedious work. Ofen the task is not very complex but automating it would take to much time. Goal of this project is to minimize the time required to define a simple pattern and apply it to your codebase.

It is done in form of a visual studio code extension, that allows to define small patterns.

export const AutoThunk: Pattern<MethodDeclaration> = {
    // filter projects in which to look for the pattern
    sourceProjects: (lp) => lp.config.type === "backend",
    // filter projects that might be relevant to the pattern
    targetProjects: (lp) => lp.config.type === "frontend",
    // a ts-query selector to match all method declarations that have a certain decorator
    query: `MethodDeclaration:has(Decorator Identifier[name="Query"],[name="Mutation"],[name="Subscription"])`,
    // this will render the text of each vs-code lens
    title: (node, context, target) => `+thunk in ${target.config.name ?? target.config.type}`,
    // include/exclude pathes
    include: [/Resolver.ts/, /\.resolver\.ts/],
    // the handler that will be executed 
    handler: function* (node, context, target) {
        // some custom code
        yield* createThunk(node, target, context);
    },
};

This subproject is for some usefull code

types and definitions

  • Pattern: allows to quickly define a pattern
  • Plugin: probably obsoleted by pattern
  • LoadedProject: representation of the various projects in a workspace
  • FileEditOperations: operations that can be generated by patterns and plugins

helper code

  • refToNode: get a referrenced node from typeReference or Identifier
  • shared: helpers to use ts-query on ts-morph
  • writeType: cleanup type from import

Readme

Keywords

none

Package Sidebar

Install

npm i @feinarbyte/pluginbase

Weekly Downloads

5

Version

5.1.2

License

UNLICENSED

Unpacked Size

367 kB

Total Files

169

Last publish

Collaborators

  • nightvisi0n
  • derkorb