refactoring

  • A module with too many variables is a copy

    A module exposing every attribute of the resources it wraps has not abstracted anything — it is the same configuration with an extra indirection. The test is whether…

  • A GitHub Actions workflow that other repositories can call

    Eleven repositories with the same ninety-line workflow and eleven copies drifting. A fix applied to four of them.

  • Generators are one-shot and rewind throws

    A generator can be iterated once, and the second foreach over the same instance throws rather than returning nothing. Returning a generator from a method is therefore a…

  • ignoreErrors with a message regex ages badly

    Ignoring an error by matching its message couples the configuration to wording that changes between releases. reportUnmatchedIgnoredErrors is on by default and worth keeping on, because it turns…

  • yield from flattens, and loses the keys you expected

    yield from preserves the inner generator’s keys, which means two delegated generators both starting at zero produce duplicate keys. The keys are preserved because yield from is delegation…

  • replaceAll, and the regex with /g you no longer need

    String.replace with a string pattern replaces the first occurrence only, which is the most surprised anybody has been by a standard library method. Escaping user input to build…

  • Numeric separators make a constant readable

    An underscore in a numeric literal is ignored by the parser and exists solely so a person can see how many zeros there are. The mistake this prevents…

  • script setup, and the Vue component that lost its boilerplate

    3.2 in August makes the compiler macro stable. Every component ended with a return listing what it had just declared, and a compiler can work that out.

  • script setup infers what setup() had to return

    Every Composition API component ended with a return statement listing what it had just declared, which is information a compiler can work out. Every top-level binding is exposed…

  • Block-based widgets broke every widget we had written

    5.8 replaced the widget screen with a block editor. Six custom widgets became six HTML blocks full of rendered markup.