Files
pezkuwi-dev/packages/dev/scripts/pezkuwi-dev-deno-map.mjs
T
Satoshi Qazi Muhammed f10614dd7d Add pezkuwi-dev-migrate-eslint10, and fix the Deno map's disable comment
Moving a repository to 0.86 renames rules (formatting rules to @stylistic,
import/* to import-x/*, deprecation/deprecation to
@typescript-eslint/no-deprecated, and typescript-eslint 8's removals). A
disable comment that still names the old rule disables nothing: eslint
reports it unused, --fix deletes it, and the rule it held back applies.
Measured on pezkuwi-apps: the generated typesBundle.ts carries
/* eslint-disable quotes */, and without a rename --fix rewrote all 188k
lines of it.

pezkuwi-dev-migrate-eslint10 renames the rules in eslint-disable /
eslint-enable comments across the tracked files, before the first lint on
0.86, including such comments inside string literals, which is how
generators emit them. Core renames come from eslint's own rule metadata
(meta.deprecated.replacedBy); the rest are the mappings of #9. --check
reports without writing and exits 1 when there is work.

Run on this repository it found one: pezkuwi-dev-deno-map writes
/* eslint-disable import/extensions */ into the Deno mod.ts it generates.

The spec runs the tool in a scratch git repository: every kind of rename,
descriptions kept, duplicates merged, a directive inside a string, current
names and bare disables left alone, and --check. Its fixture is spelt so
the tool, run here, cannot rewrite it.
2026-10-09 10:03:59 +04:00

36 lines
1.2 KiB
JavaScript
Executable File

#!/usr/bin/env node
// Copyright 2017-2026 @pezkuwi/dev authors & contributors
// SPDX-License-Identifier: Apache-2.0
import fs from 'node:fs';
import { DENO_POL_PRE } from './util.mjs';
const [e, i] = fs
.readdirSync('packages')
.filter((p) => fs.existsSync(`packages/${p}/src/mod.ts`))
.sort()
.reduce((/** @type {[string[], Record<String, string>]} */ [e, i], p) => {
e.push(`export * as ${p.replace(/-/g, '_')} from '${DENO_POL_PRE}/${p}/mod.ts';`);
i[`${DENO_POL_PRE}/${p}/`] = `./packages/${p}/build-deno/`;
return [e, i];
}, [[], {}]);
if (!fs.existsSync('mod.ts')) {
fs.writeFileSync('mod.ts', `// Copyright 2017-${new Date().getFullYear()} @pezkuwi/dev authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\n// auto-generated via pezkuwi-dev-deno-map, do not edit\n\n// This is a Deno file, so we can allow .ts imports
/* eslint-disable import-x/extensions */\n\n${e.join('\n')}\n`);
}
if (fs.existsSync('import_map.in.json')) {
const o = JSON.parse(fs.readFileSync('import_map.in.json', 'utf-8'));
Object
.entries(o.imports)
.forEach(([k, v]) => {
i[k] = v;
});
}
fs.writeFileSync('import_map.json', JSON.stringify({ imports: i }, null, 2));