linting and feedback #13
Replies: 4 comments 1 reply
-
I agree with @alexanderchan; ESLint rules are easier to adopt. |
Beta Was this translation helpful? Give feedback.
-
Hey @alexanderchan, Thanks a lot for your thoughtful feedback! I really appreciate it. I've converted this to a discussion per your suggestion - it's definitely a better place for general feedback like this. ESLint vs Language ExtensionsGreat point about I originally prioritized a TypeScript plugin approach because ESLint was painfully slow in my projects, even with relatively small repos (~400 files, ~25k LOC). Biome is much faster, but not as mature as ESLint yet. The upcoming v2 with GritQL integration looks promising, though from what I understand, it won't have access to type information - only syntax analysis (let me know if I'm wrong on this). Additionally, Currently, I'm refactoring the TypeScript plugin to optimize AST traversal and remove duplicated logic between code fixes and diagnostics. I ended up breaking some things in the process, so I decided to write proper unit and E2E tests first (right now, E2E tests in Additionally, I've found some edge cases with That said, any help or contributions are always welcome! Go-style SyntaxI personally prefer NamingI totally agree that the current package names are a bit long, especially since they're scoped under my username. I've already reserved the
For plugins, Object NotationOne of my main concerns with an object notation approach is that it's easy to forget to handle the error. Go handles this naturally, and I wanted a way to enforce it with tooling in TS. With tuples, we can enforce error handling while still allowing // @ts-expect-error (or @ts-ignore)
const { data } = tryCatch(...) or const { data /* error */ } = tryCatch(...) Neither feels intuitive, and comments aren't stored in the AST, which increases tooling complexity. So, for now, I'll be sticking with tuples - but I'm open to reconsidering if tooling evolves to support objects better. Again, thanks for the feedback! Looking forward to hearing more thoughts. |
Beta Was this translation helpful? Give feedback.
-
I've detected an issue with your approach, the problem of patching. |
Beta Was this translation helpful? Give feedback.
-
nice! I like that you reserved it, that'll be really great. It's a small thing but little devx touches are much appreciated.
That makes a lot of sense on performance. It's unfortunate that it looks like for the next little while we'll be non standardized with all of the different tooling options for these operations. With tsc, eslint and now others like biome and oxc it gets much harder for library devs -- but hopefully best for the community in the long run once one of these proves to be the new linting tool of choice. I will let you know if I take a stab at writing a lint rule but the language extension should work until then.
This sounds great, unkey has an interesting approach to returned errors and I like the idea of having typed errors coming back but they return if I'm understanding it, it'd be to manage errors like function myExample() {
if (Math.random() < 0.5) {
return new Error("Too small"); // instead of throw new Error('Too small')
}
return { message: "ok" };
} I think what makes your library work well is there's less api surface area to learn initially and then with utils or different interfaces we could support the more advanced use cases like returned errors. Looking forward to seeing this.
Coming from react, tuples feel natural enough as long as it's really tuples and it's close to how golang does it.. somehow when it gets beyond two and no longer a tuple but an array I find it harder to track 😄 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Just wanted to say, I went through the implementations on theo's try-catch gist and have to say I like yours a lot. It's clean and simple and works even if it's early on. They should have a kudos page instead of just an issues page in github! Appreciate you releasing it.
Hope you keep it up, these are only suggestions because it's your library but perhaps something helpful while you are building things to get some early feedback. Maybe worth opening discussions tabs for this type of general feedback rather than real a real issue (which these aren't)
Eslint vs Language extensions -- I totally see why you would want an extension but for adoption the lint rule might be easier to adopt. Language extensions are just a bit less common imho. https://typescript-eslint.io/ shows us how some features of ts can be leveraged so maybe that's helpful? It might be just in my head but I see this type of thing as linting because it's syntactically correct but it's preferred to manage the error. Lint rules like this are relatively easy to generate these days so maybe for developer experience choosing the one that fits the toolchain might be an option? Either way I really appreciate that you've included this as a part of the packages. This can be something you consider once the api is stabilized as well or take contributions.
I personally like the go
data, err
syntax and since this form of error handling is really appealing to go devs it seems to make sense to keep it that way as well so I like that you chose that orderMaybe just lean into the
try-catch
name?try-catch-tuple
is just a little more of a mouthful and if it's namespace scoped to you already it's probably ok?object notation - I did like how czy-js had both object and tuples but the types did not work for me so maybe the complexity of the dual typing isn't worth it. It's easier to have a single api to document and support anyways.
Really looking forward to see where you take this!
Beta Was this translation helpful? Give feedback.
All reactions