Uncategorized

  • An enum with an interface, and the match I stopped writing

    The same match on an enum, in four places, each returning a different aspect of the same thing. Moving the match onto the enum means adding a case…

  • A Jest test that mocked the module under test

    A test file that mocked the module it imported, so it asserted the behaviour of the mock and passed after the implementation was deleted. It had been added…

  • An autoloaded option that was 400 KB

    Every page load unserialising four hundred kilobytes of a plugin’s cached API response, because it had been stored as an autoloaded option. Autoloaded options are read as one…

  • import.meta.glob for a route table

    A route table maintained by hand next to a directory of route files, forgotten on average once a month. The build-time resolution is what makes this safe: the…

  • manualChunks, and a vendor bundle that was one library

    A 410 KB vendor chunk that invalidated on every dependency update, of which 280 KB was a date library used in two places. Splitting a rarely-used heavy dependency…

  • A discriminated union instead of four optional fields

    A response type with four optional properties permits sixteen shapes, of which three are valid. The compiler now narrows on status, so the branch that reads data is…

  • A saga in a table, because the alternative was a framework

    A three-step process across two external systems, needing compensation when step two fails, and no appetite for a workflow engine. A state machine in a table, advanced by…

  • Deleting thirty alerts, and the one that mattered

    Thirty-one rules, 412 firings in a month, four of which corresponded to something a user would have noticed. The rule that survived unchanged is the one written last…

  • InnerBlocks with a template lock, and the editor who wanted it open

    A locked layout that guaranteed the design held, and an editor who needed one more column on one page and had to file a ticket. all prevents insertion,…

  • A block variation instead of a second block

    A “featured” version of an existing block, which had been built as a separate block with a duplicated edit component. A variation is the same block with different…