__filename and __dirname in ESM
ESM does not populate the __filename
and __dirname
variables frequently used in CommonJS. This post shows what to do instead.
ESM does not populate the __filename
and __dirname
variables frequently used in CommonJS. This post shows what to do instead.
element-vir
is a package for defining and rendering custom HTML web components. It wraps Lit and aims to dramatically reduce the number of mistakes devs can easily make. This post will talk about how rendering within element-vir
works.
Web Components are reusable, native chunks of shared HTML, CSS, and JavaScript. They are the way of reusing HTML and defining tightly-scoped and decoupled blocks of HTML with dedicated styles (CSS) and logic (JavaScript). How do you use them? This post is a high level introductory answer to that question.
PickDeep
is a utility type that expands TypeScript's built-in Pick
utility type to pick keys in nested objects.PickSelection
is a utility type that accomplishes the same thing but with a different interface: using selection sets (similar to GraphQL selection or Prisma's selection interface).While both are still supported, PickSelection
is now the recommended utility type. This blog post will explain why.
There are tons of options for test packages and frameworks within the JavaScript ecosystem, both on the backend and frontend. This is my knowledge dump of them.
Disclaimer: This is only what I know about each package from browsing its docs, my experiences with them, and my, often strong (beware), opinions. I can't possibly hear or know about all available testing packages.
Here's a super simple, low cost pattern for keeping track of multiple solo projects: just add a todo.md
file at the root of each repo.
A collection of commands for use in PostgreSQL. Many will be applicable to any SQL database (not just PostgreSQL). I'll add more to this over time.
If you're an experienced database dev, these will probably be stupidly obvious to you.
This is intended to be a very basic high level overview of GraphQL, explained to a developer that already understands the basics of REST API design. This is not a deep dive into all GraphQL's features or a GraphQL pros/cons list. Also, while GraphQL is backend language agnostic, this guide will be mentioning JavaScript implementations (since that's what I work with).
If you're using TypeScript and ESLint in VS Code, wip files or legacy files can quickly explode into a sea of red squiggles, making it hard to know where to start or track what's going on.
I like to hone in on type errors first, since they're typically more critical (as in, type errors will often completely crash your code). I keep those as scary red squiggles and tone ESLint down a bit by changing all its squiggles to just (orange) warnings.
This is easy to do with a quick edit to your user settings JSON file (accessed via the >Preferences: Open User Settings (JSON)
command in VS Code):
"eslint.rules.customizations": [
{ "rule": "*", "severity": "warn" },
]
Use {@link VarName}
in JSDoc comments when referencing variables or types to get:
I assume that all the features in VS Code are driven by the TypeScript Language Server and thus are applicable to any editor that utilizes that same language server.