Fix lint errors: add eslint-disable for __dirname, fix no-use-before-define

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2026-02-22 14:32:02 +01:00
parent 6fa63d411f
commit 553e727d5f
13 changed files with 26 additions and 16 deletions
+7 -8
View File
@@ -28,6 +28,9 @@ import mysql from 'mysql2/promise';
import pgtools from 'pgtools';
import { findOwnPaths, runOutput, run } from '@backstage/cli-common';
/* eslint-disable-next-line no-restricted-syntax */
const ownPaths = findOwnPaths(__dirname);
import { OptionValues } from 'commander';
const templatePackagePaths = [
@@ -135,7 +138,7 @@ async function buildDistWorkspace(workspaceName: string, rootDir: string) {
}
for (const pkgJsonPath of templatePackagePaths) {
const jsonPath = findOwnPaths(__dirname).resolveRoot(pkgJsonPath);
const jsonPath = ownPaths.resolveRoot(pkgJsonPath);
const pkgTemplate = await fs.readFile(jsonPath, 'utf8');
const pkg = JSON.parse(
handlebars.compile(pkgTemplate)(
@@ -193,7 +196,7 @@ async function buildDistWorkspace(workspaceName: string, rootDir: string) {
print('Pinning yarn version in workspace');
await pinYarnVersion(workspaceDir);
const yarnPatchesPath = findOwnPaths(__dirname).resolveRoot('.yarn/patches');
const yarnPatchesPath = ownPaths.resolveRoot('.yarn/patches');
if (await fs.pathExists(yarnPatchesPath)) {
print('Copying yarn patches');
await fs.copy(yarnPatchesPath, resolvePath(workspaceDir, '.yarn/patches'));
@@ -211,10 +214,7 @@ async function buildDistWorkspace(workspaceName: string, rootDir: string) {
* Pin the yarn version in a directory to the one we're using in the Backstage repo
*/
async function pinYarnVersion(dir: string) {
const yarnRc = await fs.readFile(
findOwnPaths(__dirname).resolveRoot('.yarnrc.yml'),
'utf8',
);
const yarnRc = await fs.readFile(ownPaths.resolveRoot('.yarnrc.yml'), 'utf8');
const yarnRcLines = yarnRc.split(/\r?\n/);
const yarnPathLine = yarnRcLines.find(line => line.startsWith('yarnPath:'));
if (!yarnPathLine) {
@@ -225,7 +225,6 @@ async function pinYarnVersion(dir: string) {
throw new Error(`Invalid 'yarnPath' in ${yarnRc}`);
}
const [, localYarnPath] = match;
const ownPaths = findOwnPaths(__dirname);
const yarnPath = ownPaths.resolveRoot(localYarnPath);
const yarnPluginPath = ownPaths.resolveRoot(
localYarnPath,
@@ -329,7 +328,7 @@ async function createApp(
*/
async function overrideYarnLockSeed(appDir: string) {
const content = await fs.readFile(
findOwnPaths(__dirname).resolveRoot('packages/create-app/seed-yarn.lock'),
ownPaths.resolveRoot('packages/create-app/seed-yarn.lock'),
'utf8',
);
const trimmedContent = content