Tag: TypeScript
-
Stop ESLint from searching up the directory tree
For most projects, I use a monorepo, and nest my scripts in a directory. I’ll npm init each script, and maintain an isolated set of dependencies outside of the main dependency tree. This includes maintaining a separate .eslintrc file as well. Typically, this isn’t a problem, but recently with a new project that was created…
-
Airbnb style guide with Next.js
Starting a fresh Next.js project the other day, I was happy to see that configuring eslint was part of the bootstrapping process. Where things fell short for me, was the lack of a prompt asking me which style guide I’d like to use. I’m sure the out of the box option is sufficient enough, and…
-
Best way to pin TypeScript as a dependency
While I’m a pretty big fan of TypeScript, there’s some stuff that drives me up a wall. One of those things recently came to light during the release of TypeScript 4.4 on a Friday afternoon. So it was nearing both end of day and end of week, and we were…
-
Recursive functions in TypeScript
In working with the Slate framework for building rich text editors recently, I found myself faced with a scenario where I needed to loop through the editor’s value. The value that comes out the editor is an array of objects that is nestable, I assume infinitely, by way of the…
-
Recursive types and interfaces in TypeScript
When writing out a type or interface in TypeScript for something that will be fed into a recursive function you could cop out and use any or you could properly define the structure. Fortunately, both type and interface allow you to be self referential in terms of defining properties. Let’s…
-
Error: Cannot resolve a DOM point from Slate point
By way of recommendation (thanks Brewer), I’ve been messing around with Slate.js a ton. Such is life, I did have my fair share of issues, particularly in terms of getting it to function like a chat message input where hitting Enter will submit the form and reset it to it’s…
-
Resetting a Slate.js editor to an empty state
I’ve been messing with Slate.js and happen to be using it in the context of having a persistent editor on the page that can be used post from. It’s sort of like a chat’s message input, it’s always there, and when you submit it, it resets back to it’s original…
-
Resetting the undo/redo history of a Slate.js editor
Slate.js has some wonderful undo/redo history under the hood, by way of the React hook useMemo. Out of the box is works great, but if you want to reset your editor back to an empty state (in scenarios where the component is persistent on the page), the undo/redo history will…
-
Submit on enter except when shift is pressed in JavaScript
Been working on something recently where I wanted to implement a submit handler when a user hits the enter key in an input. That’s not that big of a deal, sniff out the key being pressed, and if it’s the Enter key, go ahead and execute the submit handler. Since…
-
Complete CI/CD pipeline with GitLab Runners
Automation is one of the best ways to improve productivity. Even as a development team of one, spending a bit of time on DevOps and improving your developer quality of life can pay off immensely. Automated tasks strip away cognitive load. No more forgetting to deploy code because the process…