Merge pull request #32516 from backstage/freben/nodecolon

Add a rule for the use of `node:` prefix on native imports
This commit is contained in:
Fredrik Adelöw
2026-01-27 14:17:14 +01:00
committed by GitHub
444 changed files with 749 additions and 634 deletions
@@ -9,11 +9,11 @@ import { ErrorRequestHandler } from 'express';
import { Express as Express_2 } from 'express';
import { Handler } from 'express';
import { HelmetOptions } from 'helmet';
import * as http from 'http';
import * as http from 'node:http';
import { LifecycleService } from '@backstage/backend-plugin-api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { RequestHandler } from 'express';
import { RequestListener } from 'http';
import { RequestListener } from 'node:http';
import { RootConfigService } from '@backstage/backend-plugin-api';
import { RootHealthService } from '@backstage/backend-plugin-api';
import { RootHttpRouterService } from '@backstage/backend-plugin-api';
@@ -20,7 +20,7 @@ import { GithubIntegration } from '@backstage/integration';
import { GitLabIntegration } from '@backstage/integration';
import { HarnessIntegration } from '@backstage/integration';
import { LoggerService } from '@backstage/backend-plugin-api';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { RootConfigService } from '@backstage/backend-plugin-api';
import { ServiceFactory } from '@backstage/backend-plugin-api';
import { ServiceRef } from '@backstage/backend-plugin-api';
@@ -15,7 +15,7 @@
*/
import fs from 'fs-extra';
import { resolve as resolvePath, dirname } from 'path';
import { resolve as resolvePath, dirname } from 'node:path';
import {
BackendFeature,
@@ -22,7 +22,7 @@ import {
mockServices,
registerMswTestHooks,
} from '@backstage/backend-test-utils';
import { randomBytes } from 'crypto';
import { randomBytes } from 'node:crypto';
import { SignJWT, exportJWK, generateKeyPair } from 'jose';
import { DateTime } from 'luxon';
import { v4 as uuid } from 'uuid';
@@ -15,7 +15,7 @@
*/
import { ConfigReader } from '@backstage/config';
import { randomBytes } from 'crypto';
import { randomBytes } from 'node:crypto';
import { SignJWT, importJWK } from 'jose';
import { DateTime } from 'luxon';
import { legacyTokenHandler } from './legacy';
@@ -22,7 +22,7 @@ import {
BackstageUserPrincipal,
} from '@backstage/backend-plugin-api';
import { InternalBackstageCredentials } from './types';
import { createHash } from 'crypto';
import { createHash } from 'node:crypto';
export function createCredentialsWithServicePrincipal(
sub: string,
@@ -16,7 +16,7 @@
import { Config } from '@backstage/config';
import { HumanDuration, durationToMilliseconds } from '@backstage/types';
import { promises as fs } from 'fs';
import { promises as fs } from 'node:fs';
import { JWK, exportJWK, importPKCS8, importSPKI } from 'jose';
import { KeyLike } from 'jose';
import { KeyPayload } from './types';
@@ -20,7 +20,7 @@ import {
CacheServiceSetOptions,
} from '@backstage/backend-plugin-api';
import { JsonValue } from '@backstage/types';
import { createHash } from 'crypto';
import { createHash } from 'node:crypto';
import Keyv from 'keyv';
import { ttlToMilliseconds } from './types';
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { EventEmitter } from 'events';
import { EventEmitter } from 'node:events';
import { LoggerService } from '@backstage/backend-plugin-api';
import { InfinispanPutOptions } from '../../types';
@@ -15,7 +15,7 @@
*/
import { ConfigReader } from '@backstage/config';
import path from 'path';
import path from 'node:path';
import {
buildSqliteDatabaseConfig,
createSqliteDatabaseClient,
@@ -21,7 +21,7 @@ import { JsonObject } from '@backstage/types';
import { ensureDirSync } from 'fs-extra';
import knexFactory, { Knex } from 'knex';
import { merge, omit } from 'lodash';
import path from 'path';
import path from 'node:path';
import { Connector } from '../types';
import { mergeDatabaseConfig } from './mergeDatabaseConfig';
@@ -15,7 +15,7 @@
*/
import { ForwardedError, InputError, NotFoundError } from '@backstage/errors';
import { resolveSrv, SrvRecord } from 'dns';
import { resolveSrv, SrvRecord } from 'node:dns';
const PROTOCOL_SUFFIX = '+srv:';
@@ -16,7 +16,7 @@
import { LoggerService } from '@backstage/backend-plugin-api';
import { assertError } from '@backstage/errors';
import { randomBytes } from 'crypto';
import { randomBytes } from 'node:crypto';
function handleBadError(error: Error, logger: LoggerService) {
const logId = randomBytes(10).toString('hex');
@@ -14,9 +14,9 @@
* limitations under the License.
*/
import * as http from 'http';
import * as https from 'https';
import { RequestListener } from 'http';
import * as http from 'node:http';
import * as https from 'node:https';
import { RequestListener } from 'node:http';
import { LoggerService } from '@backstage/backend-plugin-api';
import { HttpServerOptions, ExtendedHttpServer } from './types';
import { getGeneratedCertificate } from './getGeneratedCertificate';
@@ -15,7 +15,7 @@
*/
import fs from 'fs-extra';
import { resolve as resolvePath, dirname } from 'path';
import { resolve as resolvePath, dirname } from 'node:path';
import { LoggerService } from '@backstage/backend-plugin-api';
import forge from 'node-forge';
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import * as http from 'http';
import * as http from 'node:http';
/**
* An HTTP server extended with utility methods.
@@ -16,7 +16,7 @@
import { Knex } from 'knex';
import { TestDatabases } from '@backstage/backend-test-utils';
import fs from 'fs';
import fs from 'node:fs';
import { migrationsDir } from './migrateBackendTasks';
const migrationsFiles = fs.readdirSync(migrationsDir).sort();
@@ -19,7 +19,7 @@ import { JsonObject } from '@backstage/types';
import { DefaultReadTreeResponseFactory } from './tree';
import { AwsCodeCommitUrlReader, parseUrl } from './AwsCodeCommitUrlReader';
import { UrlReaderPredicateTuple } from './types';
import path from 'path';
import path from 'node:path';
import { NotModifiedError } from '@backstage/errors';
import { mockClient } from 'aws-sdk-client-mock';
import {
@@ -27,7 +27,7 @@ import {
GetFileCommand,
GetFolderCommand,
} from '@aws-sdk/client-codecommit';
import fs from 'fs';
import fs from 'node:fs';
import { DefaultAwsCredentialsManager } from '@backstage/integration-aws-node';
import {
AwsCodeCommitIntegration,
@@ -46,9 +46,9 @@ import {
GetFolderCommand,
} from '@aws-sdk/client-codecommit';
import { AwsCredentialIdentityProvider } from '@aws-sdk/types';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { ReadUrlResponseFactory } from './ReadUrlResponseFactory';
import { relative } from 'path/posix';
import { relative } from 'node:path/posix';
import { AbortController } from '@aws-sdk/abort-controller';
export function parseUrl(
@@ -24,7 +24,7 @@ import {
} from '@backstage/integration';
import { DefaultAwsCredentialsManager } from '@backstage/integration-aws-node';
import { UrlReaderPredicateTuple } from './types';
import path from 'path';
import path from 'node:path';
import { NotModifiedError } from '@backstage/errors';
import { mockClient } from 'aws-sdk-client-mock';
import {
@@ -35,7 +35,7 @@ import {
S3ServiceException,
} from '@aws-sdk/client-s3';
import { sdkStreamMixin } from '@aws-sdk/util-stream-node';
import fs from 'fs';
import fs from 'node:fs';
import { mockServices } from '@backstage/backend-test-utils';
const treeResponseFactory = DefaultReadTreeResponseFactory.create({
@@ -49,8 +49,8 @@ import {
} from '@aws-sdk/client-s3';
import { AbortController } from '@aws-sdk/abort-controller';
import { ReadUrlResponseFactory } from './ReadUrlResponseFactory';
import { Readable } from 'stream';
import { relative } from 'path/posix';
import { Readable } from 'node:stream';
import { relative } from 'node:path/posix';
export const DEFAULT_REGION = 'us-east-1';
@@ -28,7 +28,7 @@ import {
} from '@backstage/integration';
import { UrlReaderPredicateTuple } from './types';
import { mockServices } from '@backstage/backend-test-utils';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
// Mock Azure Blob Storage SDK
const mockBlobDownload = jest.fn();
@@ -26,8 +26,8 @@ import {
ForwardedError,
NotModifiedError,
} from '@backstage/errors';
import { Readable } from 'stream';
import { relative } from 'path/posix';
import { Readable } from 'node:stream';
import { relative } from 'node:path/posix';
import { ReadUrlResponseFactory } from './ReadUrlResponseFactory';
import {
AzureBlobStorageIntergation,
@@ -31,7 +31,7 @@ import {
import fs from 'fs-extra';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import path from 'path';
import path from 'node:path';
import { NotModifiedError } from '@backstage/errors';
import { AzureUrlReader } from './AzureUrlReader';
import { DefaultReadTreeResponseFactory } from './tree';
@@ -26,7 +26,7 @@ import {
import fs from 'fs-extra';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import path from 'path';
import path from 'node:path';
import { NotModifiedError } from '@backstage/errors';
import { BitbucketCloudUrlReader } from './BitbucketCloudUrlReader';
import { DefaultReadTreeResponseFactory } from './tree';
@@ -26,7 +26,7 @@ import {
import fs from 'fs-extra';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import path from 'path';
import path from 'node:path';
import { NotModifiedError } from '@backstage/errors';
import { BitbucketServerUrlReader } from './BitbucketServerUrlReader';
import { DefaultReadTreeResponseFactory } from './tree';
@@ -27,7 +27,7 @@ import {
import fs from 'fs-extra';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import path from 'path';
import path from 'node:path';
import { NotModifiedError } from '@backstage/errors';
import { BitbucketUrlReader } from './BitbucketUrlReader';
import { DefaultReadTreeResponseFactory } from './tree';
@@ -28,7 +28,7 @@ import {
NotModifiedError,
} from '@backstage/errors';
import { ReaderFactory } from './types';
import path from 'path';
import path from 'node:path';
import { ReadUrlResponseFactory } from './ReadUrlResponseFactory';
import { Config } from '@backstage/config';
@@ -29,7 +29,7 @@ import { JsonObject } from '@backstage/types';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import fs from 'fs-extra';
import path from 'path';
import path from 'node:path';
import { UrlReaderPredicateTuple } from './types';
import { DefaultReadTreeResponseFactory } from './tree';
import { GerritUrlReader } from './GerritUrlReader';
@@ -25,7 +25,7 @@ import {
} from '@backstage/backend-plugin-api';
import { Base64Decode } from 'base64-stream';
import fetch, { Response } from 'node-fetch';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import {
GerritIntegration,
ScmIntegrations,
@@ -29,7 +29,7 @@ import getRawBody from 'raw-body';
import { GiteaUrlReader } from './GiteaUrlReader';
import { NotFoundError, NotModifiedError } from '@backstage/errors';
import fs from 'fs-extra';
import path from 'path';
import path from 'node:path';
const treeResponseFactory = DefaultReadTreeResponseFactory.create({
config: new ConfigReader({}),
@@ -40,7 +40,7 @@ import {
NotFoundError,
NotModifiedError,
} from '@backstage/errors';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { parseLastModified } from './util';
import parseGitUrl from 'git-url-parse';
@@ -27,7 +27,7 @@ import {
import fs from 'fs-extra';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import path from 'path';
import path from 'node:path';
import { NotFoundError, NotModifiedError } from '@backstage/errors';
import {
GhBlobResponse,
@@ -36,7 +36,7 @@ import { RestEndpointMethodTypes } from '@octokit/rest';
import fetch, { RequestInit, Response } from 'node-fetch';
import parseGitUrl from 'git-url-parse';
import { Minimatch } from 'minimatch';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import {
assertError,
NotFoundError,
@@ -23,7 +23,7 @@ import {
import fs from 'fs-extra';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import path from 'path';
import path from 'node:path';
import { GitlabUrlReader } from './GitlabUrlReader';
import { DefaultReadTreeResponseFactory } from './tree';
import { NotFoundError, NotModifiedError } from '@backstage/errors';
@@ -41,7 +41,7 @@ import {
import parseGitUrl from 'git-url-parse';
import { trimEnd, trimStart } from 'lodash';
import { Minimatch } from 'minimatch';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { ReadUrlResponseFactory } from './ReadUrlResponseFactory';
import { ReaderFactory, ReadTreeResponseFactory } from './types';
import { parseLastModified } from './util';
@@ -23,7 +23,7 @@ import { UrlReaderPredicateTuple } from './types';
import packageinfo from '../../../../package.json';
import { mockServices } from '@backstage/backend-test-utils';
import { UrlReaderServiceReadUrlResponse } from '@backstage/backend-plugin-api';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
const bucketGetFilesMock = jest.fn();
class Bucket {
@@ -31,11 +31,11 @@ import {
readGoogleGcsIntegrationConfig,
} from '@backstage/integration';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { ReadUrlResponseFactory } from './ReadUrlResponseFactory';
import packageinfo from '../../../../package.json';
import { assertError } from '@backstage/errors';
import { relative } from 'path/posix';
import { relative } from 'node:path/posix';
const GOOGLE_GCS_HOST = 'storage.cloud.google.com';
@@ -29,7 +29,7 @@ import getRawBody from 'raw-body';
import { HarnessUrlReader } from './HarnessUrlReader';
import { NotFoundError, NotModifiedError } from '@backstage/errors';
import fs from 'fs-extra';
import path from 'path';
import path from 'node:path';
const treeResponseFactory = DefaultReadTreeResponseFactory.create({
config: new ConfigReader({}),
@@ -41,7 +41,7 @@ import {
NotFoundError,
NotModifiedError,
} from '@backstage/errors';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
/**
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for the Harness code v1 api.
@@ -16,7 +16,7 @@
import { ConflictError } from '@backstage/errors';
import getRawBody from 'raw-body';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { ReadUrlResponseFactory } from './ReadUrlResponseFactory';
describe('ReadUrlResponseFactory', () => {
@@ -17,7 +17,7 @@
import { ConflictError } from '@backstage/errors';
import { UrlReaderServiceReadUrlResponse } from '@backstage/backend-plugin-api';
import getRawBody from 'raw-body';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { ReadUrlResponseFactoryFromStreamOptions } from './types';
import { parseLastModified, responseToReadable } from './util';
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import os from 'os';
import { Readable } from 'stream';
import os from 'node:os';
import { Readable } from 'node:stream';
import { Config } from '@backstage/config';
import {
ReadTreeResponseFactoryOptions,
@@ -15,11 +15,11 @@
*/
import fs from 'fs-extra';
import path from 'path';
import path from 'node:path';
import { FromReadableArrayOptions } from '../types';
import { ReadableArrayResponse } from './ReadableArrayResponse';
import { createMockDirectory } from '@backstage/backend-test-utils';
import { relative } from 'path/posix';
import { relative } from 'node:path/posix';
const name1 = 'file1.yaml';
const file1 = fs.readFileSync(
@@ -21,12 +21,12 @@ import {
UrlReaderServiceReadTreeResponseFile,
} from '@backstage/backend-plugin-api';
import concatStream from 'concat-stream';
import platformPath, { dirname } from 'path';
import platformPath, { dirname } from 'node:path';
import getRawBody from 'raw-body';
import fs from 'fs-extra';
import { promisify } from 'util';
import { promisify } from 'node:util';
import * as tar from 'tar';
import { pipeline as pipelineCb, Readable } from 'stream';
import { pipeline as pipelineCb, Readable } from 'node:stream';
import { FromReadableArrayOptions } from '../types';
const pipeline = promisify(pipelineCb);
@@ -15,7 +15,7 @@
*/
import fs from 'fs-extra';
import { resolve as resolvePath, join as joinPath } from 'path';
import { resolve as resolvePath, join as joinPath } from 'node:path';
import { TarArchiveResponse } from './TarArchiveResponse';
import { createMockDirectory } from '@backstage/backend-test-utils';
import * as tar from 'tar';
@@ -22,11 +22,11 @@ import {
} from '@backstage/backend-plugin-api';
import concatStream from 'concat-stream';
import fs from 'fs-extra';
import platformPath from 'path';
import { pipeline as pipelineCb, Readable } from 'stream';
import platformPath from 'node:path';
import { pipeline as pipelineCb, Readable } from 'node:stream';
import * as tar from 'tar';
import type { ReadEntry } from 'tar';
import { promisify } from 'util';
import { promisify } from 'node:util';
import { stripFirstDirectoryFromPath } from './util';
const pipeline = promisify(pipelineCb);
@@ -15,9 +15,9 @@
*/
import fs from 'fs-extra';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { create as createArchive } from 'archiver';
import { resolve as resolvePath } from 'path';
import { resolve as resolvePath } from 'node:path';
import { ZipArchiveResponse } from './ZipArchiveResponse';
import { createMockDirectory } from '@backstage/backend-test-utils';
@@ -22,8 +22,8 @@ import {
import archiver from 'archiver';
import yauzl, { Entry } from 'yauzl';
import fs from 'fs-extra';
import platformPath from 'path';
import { Readable } from 'stream';
import platformPath from 'node:path';
import { Readable } from 'node:stream';
import { streamToBuffer } from './util';
import { resolveSafeChildPath } from '@backstage/backend-plugin-api';
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { Readable, pipeline as pipelineCb } from 'stream';
import { promisify } from 'util';
import { Readable, pipeline as pipelineCb } from 'node:stream';
import { promisify } from 'node:util';
import concatStream from 'concat-stream';
const pipeline = promisify(pipelineCb);
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import {
UrlReaderService,
UrlReaderServiceReadTreeResponse,
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { PassThrough, Readable } from 'stream';
import { ReadableStream as WebReadableStream } from 'stream/web';
import { PassThrough, Readable } from 'node:stream';
import { ReadableStream as WebReadableStream } from 'node:stream/web';
export function parseLastModified(
value: string | null | undefined,
@@ -16,7 +16,7 @@
import { Knex } from 'knex';
import { TestDatabases } from '@backstage/backend-test-utils';
import fs from 'fs';
import fs from 'node:fs';
const migrationsDir = `${__dirname}/../migrations/scheduler`;
const migrationsFiles = fs.readdirSync(migrationsDir).sort();