RoboHash: generate the import-sort directive only where it is used

The generator put `/* eslint-disable simple-import-sort/imports */` in
every generated image module, but only the two index files import
anything; eslint 10 reports the other 1533 as unused directives. It also
wrote import paths without the `.js` extension the committed index files
carry, so regenerating no longer reproduced them. Both fixed; the
generator now reproduces all 1535 committed files byte for byte.
This commit is contained in:
Satoshi Qazi Muhammed authored and SatoshiQaziMuhammed committed 2026-10-10 02:06:12 +04:00
1 parent 00e4a2f67b
commit c800e9affb
1534 files changed
+7 -3070

No files matched your search

+7 -4
View File
@@ -7,7 +7,10 @@ const path = require('node:path');
const HEADER = `// Copyright 2017-2026 @pezkuwi/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Automatically generated, do not edit
// Automatically generated, do not edit`;
// Only the index files import, and they keep the generated order.
const IMPORT_HEADER = `${HEADER}
/* eslint-disable simple-import-sort/imports */`;
const PATH = 'packages/react-components/src/IdentityIcon/RoboHash';
@@ -77,7 +80,7 @@ function extractBg () {
getFiles(path.join(root, sub)).forEach((entry) => files.push(`./${sub}/generated/${entry}`));
});
fs.writeFileSync(path.join(root, 'index.ts'), `${HEADER}\n\n${files.map((file, index) => `import b${getCounter(index)} from '${file.replace('.png', '')}';`).join('\n')}\n\nexport default [${files.map((_, index) => `b${getCounter(index)}`).join(', ')}];\n`);
fs.writeFileSync(path.join(root, 'index.ts'), `${IMPORT_HEADER}\n\n${files.map((file, index) => `import b${getCounter(index)} from '${file.replace('.png', '.js')}';`).join('\n')}\n\nexport default [${files.map((_, index) => `b${getCounter(index)}`).join(', ')}];\n`);
}
function extractSets () {
@@ -99,7 +102,7 @@ function extractSets () {
const indexes = files.map((file, findex) => {
const index = `s${getCounter(sindex)}${getCounter(aindex)}${getCounter(findex)}`;
imports.push(`import ${index} from '${file.replace('.png', '')}';`);
imports.push(`import ${index} from '${file.replace('.png', '.js')}';`);
return index;
});
@@ -112,7 +115,7 @@ function extractSets () {
list = `${list}\n];`;
fs.writeFileSync(path.join(root, 'index.ts'), `${HEADER}\n\n${imports.join('\n')}\n\nexport default ${list}\n`);
fs.writeFileSync(path.join(root, 'index.ts'), `${IMPORT_HEADER}\n\n${imports.join('\n')}\n\nexport default ${list}\n`);
}
extractBg();