diff --git a/packages/backend-common/src/config.ts b/packages/backend-common/src/config.ts index 247eb593cc..7432b204dd 100644 --- a/packages/backend-common/src/config.ts +++ b/packages/backend-common/src/config.ts @@ -21,6 +21,7 @@ import { loadConfig } from '@backstage/config-loader'; * Load configuration for a Backend */ export async function loadBackendConfig() { + /* eslint-disable-next-line no-restricted-syntax */ const paths = findPaths(__dirname); const configs = await loadConfig({ env: process.env.NODE_ENV ?? 'development', diff --git a/packages/cli-common/src/paths.test.ts b/packages/cli-common/src/paths.test.ts index 087f95af38..2278ee3581 100644 --- a/packages/cli-common/src/paths.test.ts +++ b/packages/cli-common/src/paths.test.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +/* eslint-disable no-restricted-syntax */ import { resolve as resolvePath } from 'path'; import { findPaths, findRootPath, findOwnDir, findOwnRootDir } from './paths'; diff --git a/packages/cli/bin/backstage-cli b/packages/cli/bin/backstage-cli index a065b8ac5a..5c127af2ec 100755 --- a/packages/cli/bin/backstage-cli +++ b/packages/cli/bin/backstage-cli @@ -18,6 +18,7 @@ const path = require('path'); // Figure out whether we're running inside the backstage repo or as an installed dependency +/* eslint-disable-next-line no-restricted-syntax */ const isLocal = require('fs').existsSync(path.resolve(__dirname, '../src')); if (!isLocal || process.env.BACKSTAGE_E2E_CLI_TEST) { @@ -25,6 +26,7 @@ if (!isLocal || process.env.BACKSTAGE_E2E_CLI_TEST) { } else { require('ts-node').register({ transpileOnly: true, + /* eslint-disable-next-line no-restricted-syntax */ project: path.resolve(__dirname, '../../../tsconfig.json'), compilerOptions: { module: 'CommonJS', diff --git a/packages/cli/config/eslint.backend.js b/packages/cli/config/eslint.backend.js index 113ba55818..2c0b05c196 100644 --- a/packages/cli/config/eslint.backend.js +++ b/packages/cli/config/eslint.backend.js @@ -67,6 +67,11 @@ module.exports = { selector: 'ImportDeclaration[source.value="winston"] ImportDefaultSpecifier', }, + { + message: + "`__dirname` doesn't refer to the same dir in production builds, try `resolvePackagePath()` from `@backstage/backend-common` instead.", + selector: 'Identifier[name="__dirname"]', + }, ], }, overrides: [ diff --git a/packages/cli/src/lib/bundler/config.ts b/packages/cli/src/lib/bundler/config.ts index 118cb1b40c..00a555eebe 100644 --- a/packages/cli/src/lib/bundler/config.ts +++ b/packages/cli/src/lib/bundler/config.ts @@ -209,6 +209,7 @@ export async function createBackendConfig( ], target: 'node' as const, node: { + /* eslint-disable-next-line no-restricted-syntax */ __dirname: true, __filename: true, global: true, diff --git a/packages/cli/src/lib/paths.ts b/packages/cli/src/lib/paths.ts index 06c8f2ab38..a17034344d 100644 --- a/packages/cli/src/lib/paths.ts +++ b/packages/cli/src/lib/paths.ts @@ -16,4 +16,5 @@ import { findPaths } from '@backstage/cli-common'; +/* eslint-disable-next-line no-restricted-syntax */ export const paths = findPaths(__dirname); diff --git a/packages/create-app/bin/backstage-create-app b/packages/create-app/bin/backstage-create-app index a065b8ac5a..467a0cae8f 100755 --- a/packages/create-app/bin/backstage-create-app +++ b/packages/create-app/bin/backstage-create-app @@ -15,6 +15,7 @@ * limitations under the License. */ +/* eslint-disable no-restricted-syntax */ const path = require('path'); // Figure out whether we're running inside the backstage repo or as an installed dependency diff --git a/packages/create-app/src/createApp.ts b/packages/create-app/src/createApp.ts index 4f25dc9b9e..83e052c91b 100644 --- a/packages/create-app/src/createApp.ts +++ b/packages/create-app/src/createApp.ts @@ -87,6 +87,7 @@ async function moveApp(tempDir: string, destination: string, id: string) { } export default async (cmd: Command): Promise => { + /* eslint-disable-next-line no-restricted-syntax */ const paths = findPaths(__dirname); const questions: Question[] = [ diff --git a/packages/docgen/bin/backstage-docgen b/packages/docgen/bin/backstage-docgen index a065b8ac5a..467a0cae8f 100755 --- a/packages/docgen/bin/backstage-docgen +++ b/packages/docgen/bin/backstage-docgen @@ -15,6 +15,7 @@ * limitations under the License. */ +/* eslint-disable no-restricted-syntax */ const path = require('path'); // Figure out whether we're running inside the backstage repo or as an installed dependency diff --git a/packages/docgen/src/generate.ts b/packages/docgen/src/generate.ts index 3587e2776b..66ee1a07a6 100644 --- a/packages/docgen/src/generate.ts +++ b/packages/docgen/src/generate.ts @@ -37,6 +37,7 @@ export async function generate( ); } + /* eslint-disable-next-line no-restricted-syntax */ const rootDir = resolvePath(__dirname, '../../..'); const srcDir = resolvePath(rootDir, 'packages', 'core-api', 'src'); const targetDir = resolvePath(targetPath); diff --git a/packages/docgen/src/index.ts b/packages/docgen/src/index.ts index 866299151a..f41629e7fd 100644 --- a/packages/docgen/src/index.ts +++ b/packages/docgen/src/index.ts @@ -21,6 +21,7 @@ import fs from 'fs-extra'; import { generate } from './generate'; const main = (argv: string[]) => { + /* eslint-disable-next-line no-restricted-syntax */ const pkgJson = fs.readJsonSync(resolvePath(__dirname, '../package.json')); program.name('docgen').version(pkgJson.version); diff --git a/packages/e2e-test/src/e2e-test.ts b/packages/e2e-test/src/e2e-test.ts index fe3a9f6bb4..2ead11c429 100644 --- a/packages/e2e-test/src/e2e-test.ts +++ b/packages/e2e-test/src/e2e-test.ts @@ -33,6 +33,7 @@ import { import pgtools from 'pgtools'; import { findPaths } from '@backstage/cli-common'; +/* eslint-disable-next-line no-restricted-syntax */ const paths = findPaths(__dirname); const templatePackagePaths = [ diff --git a/packages/e2e-test/src/index.js b/packages/e2e-test/src/index.js index 90f8030a0e..525f20cdd1 100644 --- a/packages/e2e-test/src/index.js +++ b/packages/e2e-test/src/index.js @@ -16,6 +16,7 @@ require('ts-node').register({ transpileOnly: true, + /* eslint-disable-next-line no-restricted-syntax */ project: require('path').resolve(__dirname, '../../../tsconfig.json'), compilerOptions: { module: 'CommonJS', diff --git a/packages/storybook/.storybook/main.js b/packages/storybook/.storybook/main.js index 2c58144acc..136b3945da 100644 --- a/packages/storybook/.storybook/main.js +++ b/packages/storybook/.storybook/main.js @@ -14,6 +14,7 @@ module.exports = { 'storybook-dark-mode/register', ], webpackFinal: async config => { + /* eslint-disable-next-line no-restricted-syntax */ const coreSrc = path.resolve(__dirname, '../../core/src'); // Mirror config in packages/cli/src/lib/bundler diff --git a/packages/techdocs-cli/bin/techdocs-cli b/packages/techdocs-cli/bin/techdocs-cli index ccc9c23beb..9818edf417 100755 --- a/packages/techdocs-cli/bin/techdocs-cli +++ b/packages/techdocs-cli/bin/techdocs-cli @@ -15,6 +15,7 @@ * limitations under the License. */ +/* eslint-disable no-restricted-syntax */ const path = require('path'); // Figure out whether we're running inside the backstage repo or as an installed dependency diff --git a/packages/techdocs-cli/src/index.ts b/packages/techdocs-cli/src/index.ts index da196d10b8..824bdb84fc 100644 --- a/packages/techdocs-cli/src/index.ts +++ b/packages/techdocs-cli/src/index.ts @@ -101,6 +101,7 @@ const main = (argv: string[]) => { // Local Backstage Preview const techdocsPreviewBundlePath = path.join( + /* eslint-disable-next-line no-restricted-syntax */ __dirname, '..', 'dist', diff --git a/plugins/app-backend/src/service/router.test.ts b/plugins/app-backend/src/service/router.test.ts index 417fdc43b6..aed4280ca5 100644 --- a/plugins/app-backend/src/service/router.test.ts +++ b/plugins/app-backend/src/service/router.test.ts @@ -25,6 +25,7 @@ import { createRouter } from './router'; jest.mock('../lib/config', () => ({ injectEnvConfig: jest.fn() })); global.__non_webpack_require__ = { + /* eslint-disable-next-line no-restricted-syntax */ resolve: () => resolvePath(__dirname, '__fixtures__/app-dir/package.json'), }; diff --git a/plugins/techdocs-backend/src/techdocs/stages/publish/local.test.ts b/plugins/techdocs-backend/src/techdocs/stages/publish/local.test.ts index 64edc5c294..d97a4014f6 100644 --- a/plugins/techdocs-backend/src/techdocs/stages/publish/local.test.ts +++ b/plugins/techdocs-backend/src/techdocs/stages/publish/local.test.ts @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/* eslint-disable no-restricted-syntax */ import fs from 'fs-extra'; import path from 'path'; import { getVoidLogger } from '@backstage/backend-common';