Skip to content

Instantly share code, notes, and snippets.

View JoshuaKGoldberg's full-sized avatar
💖

Josh Goldberg ✨ JoshuaKGoldberg

💖
View GitHub Profile
@JoshuaKGoldberg
JoshuaKGoldberg / README.md
Last active July 6, 2023 15:16
DefinitelyFormatted

👉 This has since been posted to DefinitelyTyped's GitHub Discussions: DefinitelyTyped/DefinitelyTyped#65993 👈

Context

👋 Hi all! I've been working with the TypeScript team on overhauling DefinitelyTyped's usage of formatting and linting tools. Alongside the effort to finally migrate from TSLint to ESLint (https://typescript-eslint.io/linting/troubleshooting/tslint -> microsoft/DefinitelyTyped-tools#648), we'd like to align with how much of the industry & many linter maintainers recommend using a formatter vs. a linter (myself included).

This is a surfacing of a plan we've formulated that we think will get DefinitelyTyped onto using a proper formatter for formatting. I'd very much like to see the community's reaction: does this seem reasonable to you? What edge cases are we missing? Will this offend your sensibilities as a program

@JoshuaKGoldberg
JoshuaKGoldberg / README.md
Last active July 20, 2023 19:23
Draft Astro RFC for ESLint in the setup experience

withastro/roadmap#621

Summary

ESLint is generally considered to be a useful, even necessary, tool for JavaScript/TypeScript web apps. However, configuring it can involve wrangling several configurations and plugins together. It would be useful for many Astro users if npm create astro et al. offered to set up a starting ESLint configuration.

Background & Motivation

Contained here are the most common setup points I think many Astro would need.
@sindresorhus
sindresorhus / esm-package.md
Last active November 16, 2024 22:43
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@shicks
shicks / num.ts
Last active October 16, 2020 10:14
Parsing integers in TypeScript's type system
type NumCat<X, Y> = X extends any[] ? Y extends any[] ? [...X, ...X, ...X, ...X, ...X, ...X, ...X, ...X, ...X, ...X, ...Y] : never : never;
type OneDigit = {
'0': [], '1': [any], '2': [any, any], '3': [any, any, any],
'4': [any, any, any, any], '5': [any, any, any, any, any],
'6': [any, any, any, any, any, any], '7': [any, any, any, any, any, any, any],
'8': [any, any, any, any, any, any, any, any],
'9': [any, any, any, any, any, any, any, any, any],
};
type Digit<S> = S extends keyof OneDigit ? OneDigit[S] : never;
type Len<X> = X extends any[] ? X['length'] : never;
// Requires >= TS 4.1
type Put<Board, Player extends ('O' | 'X'), Position> = Board extends `
${infer P0} ${infer P1} ${infer P2}
${infer P3} ${infer P4} ${infer P5}
${infer P6} ${infer P7} ${infer P8}
` ? `
${Position extends P0 ? Player : P0} ${Position extends P1 ? Player : P1} ${Position extends P2 ? Player : P2}
${Position extends P3 ? Player : P3} ${Position extends P4 ? Player : P4} ${Position extends P5 ? Player : P5}
${Position extends P6 ? Player : P6} ${Position extends P7 ? Player : P7} ${Position extends P8 ? Player : P8}
FullScreenMario by JoshuaKGoldberg
http://www.uta.edu/utari/acs/ASL_site/Homepage/Misc/Mario/index.html
handtrack.js by Victor Dibia
https://github.com/victordibia/handtrack.js/
Gesture controls integration to Mario game by Miquel Camps @vivirenremoto
Disclaimer
Mario, Super Mario Brothers, and all associated games and media are property of Nintendo and/or Nintendo of America Inc., and are protected by United States and international copyright, trademark and other intellectual property laws.
@JoshuaKGoldberg
JoshuaKGoldberg / babel.config.js.diff
Last active March 29, 2020 17:44
Babel configuration diff
const presets = [
'codecademy',
+ '@babel/preset-typescript',
];
@JoshuaKGoldberg
JoshuaKGoldberg / README.md
Last active November 25, 2019 17:03
Codecademy Public CLA

Contribution License Agreement

This Contribution License Agreement ("Agreement") is agreed to by the party signing below (“You”), and conveys certain license rights to Ryzac, Inc and its affiliates (“RyzacInc”) for Your contributions to RyzacInc open source projects. This Agreement is effective as of the latest signature date below.

1. Definitions

"Code" means the computer software code, whether in human-readable or machine-executable form, that is delivered by You to RyzacInc under this Agreement. “Project” means any of the projects owned or managed by RyzacInc in which software is offered under a license approved by the Open Source Initiative (OSI) (www.opensource.org) and documentation offered under an OSI or a Creative Commons license (https://creativecommons.org/licenses). “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any Project, including but not limited to communication on electronic mailing lists, source code control systems, and

@JoshuaKGoldberg
JoshuaKGoldberg / binary.ts
Last active August 6, 2019 21:51
Silly Binary Logic in TypeScript's Type System
type Bit = 0 | 1;
type BitFlip<A> = A extends 0
? 1
: 0;
type BitOr<A, B> = [A, B] extends [0, 0]
? 0
: 1;
@JoshuaKGoldberg
JoshuaKGoldberg / LogicMathLol.ts
Last active May 3, 2023 18:25
Silly Binary Arithmetic in TypeScript's Type System
type Bit = 0 | 1;
type BitOr<A extends Bit, B extends Bit> =
[A, B] extends [0, 0] ? 0 :
[A, B] extends [0, 1] | [1, 0] | [1, 1] ? 1 :
Bit
;
type BitAnd<A extends Bit, B extends Bit> =
[A, B] extends [0, 0] | [1, 0] | [0, 1] ? 0 :