Skip to content

Commit d38be6a

Browse files
chore(internal): codegen related update
1 parent 5cb6c18 commit d38be6a

8 files changed

Lines changed: 58 additions & 13 deletions

File tree

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @ts-check
22
import tseslint from 'typescript-eslint';
33
import unusedImports from 'eslint-plugin-unused-imports';
4+
import prettier from 'eslint-plugin-prettier';
45

56
export default tseslint.config(
67
{
@@ -13,9 +14,11 @@ export default tseslint.config(
1314
plugins: {
1415
'@typescript-eslint': tseslint.plugin,
1516
'unused-imports': unusedImports,
17+
prettier,
1618
},
1719
rules: {
1820
'no-unused-vars': 'off',
21+
'prettier/prettier': 'error',
1922
'unused-imports/no-unused-imports': 'error',
2023
'no-restricted-imports': [
2124
'error',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@typescript-eslint/eslint-plugin": "8.31.1",
3939
"@typescript-eslint/parser": "8.31.1",
4040
"eslint": "^9.39.1",
41+
"eslint-plugin-prettier": "^5.4.1",
4142
"eslint-plugin-unused-imports": "^4.1.4",
4243
"iconv-lite": "^0.6.3",
4344
"jest": "^29.4.0",

scripts/fast-format

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ if ! [ -z "$ESLINT_FILES" ]; then
3131
fi
3232

3333
echo "==> Running prettier --write"
34-
PRETTIER_FILES="$(grep '\.\([mc]?tsx?\|[mc]?jsx?\|json\)$' "$FILE_LIST" || true)"
34+
# format things eslint didn't
35+
PRETTIER_FILES="$(grep '\.\(js\|json\)$' "$FILE_LIST" || true)"
3536
if ! [ -z "$PRETTIER_FILES" ]; then
3637
echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \
37-
--write --cache --cache-strategy metadata --no-error-on-unmatched-pattern
38+
--write --cache --cache-strategy metadata --no-error-on-unmatched-pattern \
39+
'!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs'
3840
fi

scripts/format

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ echo "==> Running eslint --fix"
88
./node_modules/.bin/eslint --fix .
99

1010
echo "==> Running prettier --write"
11-
./node_modules/.bin/prettier --write --cache --cache-strategy metadata .
11+
# format things eslint didn't
12+
./node_modules/.bin/prettier --write --cache --cache-strategy metadata . '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs'

scripts/lint

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7-
echo "==> Running prettier --check"
8-
./node_modules/.bin/prettier --check .
9-
107
echo "==> Running eslint"
118
./node_modules/.bin/eslint .
129

scripts/utils/postprocess-files.cjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@ async function postprocess() {
2323

2424
// strip out lib="dom", types="node", and types="react" references; these
2525
// are needed at build time, but would pollute the user's TS environment
26-
const transformed = code.replace(
26+
let transformed = code.replace(
2727
/^ *\/\/\/ *<reference +(lib="dom"|types="(node|react)").*?\n/gm,
2828
// replace with same number of characters to avoid breaking source maps
2929
(match) => ' '.repeat(match.length - 1) + '\n',
3030
);
3131

32+
// TypeScript's declaration emitter collapses /** @ts-ignore */ onto the same
33+
// line as the type declaration, which doesn't work. So we convert to // @ts-ignore
34+
// on its own line to properly suppresses errors.
35+
if (file.endsWith('.d.ts') || file.endsWith('.d.mts') || file.endsWith('.d.cts')) {
36+
transformed = transformed.replace(/\/\*\* @ts-ignore\b[^*]*\*\/ /gm, '// @ts-ignore\n');
37+
}
38+
3239
if (transformed !== code) {
3340
console.error(`wrote ${path.relative(process.cwd(), file)}`);
3441
await fs.promises.writeFile(file, transformed, 'utf8');

src/internal/types.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type OverloadedParameters<T> =
4040
: T extends (...args: infer A) => unknown ? A
4141
: never;
4242

43+
/* eslint-disable */
4344
/**
4445
* These imports attempt to get types from a parent package's dependencies.
4546
* Unresolved bare specifiers can trigger [automatic type acquisition][1] in some projects, which
@@ -62,18 +63,19 @@ type OverloadedParameters<T> =
6263
*
6364
* [1]: https://www.typescriptlang.org/tsconfig/#typeAcquisition
6465
*/
65-
/** @ts-ignore For users with \@types/node */ /* prettier-ignore */
66+
/** @ts-ignore For users with \@types/node */
6667
type UndiciTypesRequestInit = NotAny<import('../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit>;
67-
/** @ts-ignore For users with undici */ /* prettier-ignore */
68+
/** @ts-ignore For users with undici */
6869
type UndiciRequestInit = NotAny<import('../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici/index.d.ts').RequestInit>;
69-
/** @ts-ignore For users with \@types/bun */ /* prettier-ignore */
70+
/** @ts-ignore For users with \@types/bun */
7071
type BunRequestInit = globalThis.FetchRequestInit;
71-
/** @ts-ignore For users with node-fetch@2 */ /* prettier-ignore */
72+
/** @ts-ignore For users with node-fetch@2 */
7273
type NodeFetch2RequestInit = NotAny<import('../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit>;
73-
/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ /* prettier-ignore */
74+
/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */
7475
type NodeFetch3RequestInit = NotAny<import('../node_modules/node-fetch').RequestInit> | NotAny<import('../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/node-fetch').RequestInit>;
75-
/** @ts-ignore For users who use Deno */ /* prettier-ignore */
76+
/** @ts-ignore For users who use Deno */
7677
type FetchRequestInit = NonNullable<OverloadedParameters<typeof fetch>[1]>;
78+
/* eslint-enable */
7779

7880
type RequestInits =
7981
| NotAny<UndiciTypesRequestInit>

yarn.lock

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,11 @@
709709
"@nodelib/fs.scandir" "2.1.5"
710710
fastq "^1.6.0"
711711

712+
"@pkgr/core@^0.2.4":
713+
version "0.2.4"
714+
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.2.4.tgz#d897170a2b0ba51f78a099edccd968f7b103387c"
715+
integrity sha512-ROFF39F6ZrnzSUEmQQZUar0Jt4xVoP9WnDRdWwF4NNcXs3xBTLgBUDoOwW141y1jP+S8nahIbdxbFC7IShw9Iw==
716+
712717
"@sinclair/typebox@^0.27.8":
713718
version "0.27.8"
714719
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e"
@@ -1515,6 +1520,14 @@ escape-string-regexp@^4.0.0:
15151520
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
15161521
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
15171522

1523+
eslint-plugin-prettier@^5.4.1:
1524+
version "5.4.1"
1525+
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.4.1.tgz#99b55d7dd70047886b2222fdd853665f180b36af"
1526+
integrity sha512-9dF+KuU/Ilkq27A8idRP7N2DH8iUR6qXcjF3FR2wETY21PZdBrIjwCau8oboyGj9b7etWmTGEeM8e7oOed6ZWg==
1527+
dependencies:
1528+
prettier-linter-helpers "^1.0.0"
1529+
synckit "^0.11.7"
1530+
15181531
eslint-plugin-unused-imports@^4.1.4:
15191532
version "4.1.4"
15201533
resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.1.4.tgz#62ddc7446ccbf9aa7b6f1f0b00a980423cda2738"
@@ -1666,6 +1679,11 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
16661679
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
16671680
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
16681681

1682+
fast-diff@^1.1.2:
1683+
version "1.3.0"
1684+
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0"
1685+
integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==
1686+
16691687
fast-glob@^3.3.2:
16701688
version "3.3.2"
16711689
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129"
@@ -2833,6 +2851,13 @@ prelude-ls@^1.2.1:
28332851
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
28342852
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
28352853

2854+
prettier-linter-helpers@^1.0.0:
2855+
version "1.0.0"
2856+
resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b"
2857+
integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==
2858+
dependencies:
2859+
fast-diff "^1.1.2"
2860+
28362861
prettier@^3.0.0:
28372862
version "3.1.1"
28382863
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.1.tgz#6ba9f23165d690b6cbdaa88cb0807278f7019848"
@@ -3137,6 +3162,13 @@ supports-preserve-symlinks-flag@^1.0.0:
31373162
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
31383163
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
31393164

3165+
synckit@^0.11.7:
3166+
version "0.11.8"
3167+
resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.8.tgz#b2aaae998a4ef47ded60773ad06e7cb821f55457"
3168+
integrity sha512-+XZ+r1XGIJGeQk3VvXhT6xx/VpbHsRzsTkGgF6E5RX9TTXD0118l87puaEBZ566FhqblC6U0d4XnubznJDm30A==
3169+
dependencies:
3170+
"@pkgr/core" "^0.2.4"
3171+
31403172
test-exclude@^6.0.0:
31413173
version "6.0.0"
31423174
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e"

0 commit comments

Comments
 (0)