style: apply prefer-node-protocol lint rule (#5627)

it makes it perfectly clear that the package is a Node.js builtin module.
This commit is contained in:
LongYinan 2024-01-19 03:47:08 +00:00
parent 9d28eb530a
commit fa8655e43e
No known key found for this signature in database
GPG Key ID: 30B1140CE1C07C99
19 changed files with 37 additions and 23 deletions

View File

@ -217,6 +217,7 @@ const config = {
'unicorn/no-useless-promise-resolve-reject': 'error',
'unicorn/no-new-array': 'error',
'unicorn/new-for-builtins': 'error',
'unicorn/prefer-node-protocol': 'error',
'sonarjs/no-all-duplicated-branches': 'error',
'sonarjs/no-element-overwrite': 'error',
'sonarjs/no-empty-collection': 'error',

View File

@ -1,10 +1,11 @@
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import type { ApolloDriverConfig } from '@nestjs/apollo';
import { ApolloDriver } from '@nestjs/apollo';
import { Global, Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { Request, Response } from 'express';
import { join } from 'path';
import { fileURLToPath } from 'url';
import { Config } from '../config';
import { GQLLoggerPlugin } from './logger-plugin';

View File

@ -11,9 +11,9 @@ import {
writeFileSync,
} from 'node:fs';
import { join, parse, resolve } from 'node:path';
import { Readable } from 'node:stream';
import { Logger } from '@nestjs/common';
import { Readable } from 'stream';
import { FsStorageConfig } from '../../config/storage';
import {

View File

@ -1,6 +1,7 @@
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, test } from 'vitest';
import type { Array as YArray, Map as YMap } from 'yjs';
import { applyUpdate, Doc } from 'yjs';

View File

@ -1,6 +1,6 @@
import { resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';

View File

@ -1,6 +1,6 @@
import { resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';

View File

@ -1,7 +1,7 @@
import type { ChildProcessWithoutNullStreams } from 'node:child_process';
import { spawn } from 'node:child_process';
import { resolve } from 'node:path';
import type { ChildProcessWithoutNullStreams } from 'child_process';
import type { BuildContext } from 'esbuild';
import * as esbuild from 'esbuild';
import kill from 'tree-kill';

View File

@ -1,7 +1,8 @@
import path from 'node:path';
import type { Options as ElectronWinstallerOptions } from 'electron-winstaller';
import { convertVersion, createWindowsInstaller } from 'electron-winstaller';
import fs from 'fs-extra';
import path from 'path';
import {
arch,

View File

@ -1,10 +1,11 @@
import fs from 'node:fs';
import path from 'node:path';
import {
AppConfigStorage,
defaultAppConfig,
} from '@toeverything/infra/app-config-storage';
import { app } from 'electron';
import fs from 'fs';
import path from 'path';
const FILENAME = 'config.json';
const FILEPATH = path.join(app.getPath('userData'), FILENAME);

View File

@ -1,8 +1,8 @@
import assert from 'node:assert';
import { join } from 'node:path';
import { BrowserWindow, type CookiesSetDetails, nativeTheme } from 'electron';
import electronWindowState from 'electron-window-state';
import { join } from 'path';
import { isMacOS, isWindows } from '../shared/utils';
import { mainWindowOrigin } from './constants';

View File

@ -1,5 +1,6 @@
import { join } from 'node:path';
import { BrowserWindow, type Display, screen } from 'electron';
import { join } from 'path';
import { isMacOS } from '../shared/utils';
import { mainWindowOrigin } from './constants';

View File

@ -1,5 +1,6 @@
import { join } from 'node:path';
import { net, protocol, session } from 'electron';
import { join } from 'path';
import { CLOUD_BASE_URL } from './config';
import { logger } from './logger';

View File

@ -1,5 +1,6 @@
import { parse } from 'node:url';
import { app, BrowserWindow, shell } from 'electron';
import { parse } from 'url';
import { logger } from '../logger';

View File

@ -1,7 +1,8 @@
import 'electron-updater'; // Prevent BaseUpdater is undefined.
import { randomBytes } from 'node:crypto';
import { type AllPublishOptions, UUID } from 'builder-util-runtime';
import { randomBytes } from 'crypto';
import type { AppAdapter } from 'electron-updater/out/AppAdapter';
import type { DownloadUpdateOptions } from 'electron-updater/out/AppUpdater';
import type { InstallOptions } from 'electron-updater/out/BaseUpdater';

View File

@ -1,5 +1,6 @@
import { fileURLToPath } from 'node:url';
import { runCli } from '@magic-works/i18n-codegen';
import { fileURLToPath } from 'url';
runCli(
{

View File

@ -1,5 +1,6 @@
import { fileURLToPath } from 'node:url';
import { runCli } from '@magic-works/i18n-codegen';
import { fileURLToPath } from 'url';
runCli(
{

View File

@ -1,6 +1,7 @@
import fs from 'fs';
import fs from 'node:fs';
import path from 'node:path';
import * as glob from 'glob';
import path from 'path';
// purpose: bundle all json files into one json file in onboarding folder
const __dirname = new URL('.', import.meta.url).pathname;

View File

@ -1,3 +1,5 @@
import { resolve } from 'node:path';
import { skipOnboarding, test } from '@affine-test/kit/playwright';
import {
addUserToWorkspace,
@ -16,7 +18,6 @@ import { clickUserInfoCard } from '@affine-test/kit/utils/setting';
import { clickSideBarSettingButton } from '@affine-test/kit/utils/sidebar';
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
import { expect } from '@playwright/test';
import { resolve } from 'path';
let user: {
id: string;

View File

@ -1,4 +1,6 @@
/* eslint-disable unicorn/prefer-dom-node-dataset */
import fs from 'node:fs';
import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import {
@ -7,7 +9,6 @@ import {
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import { expect, type Page } from '@playwright/test';
import fs from 'fs';
async function importImage(page: Page, url: string) {
await page.evaluate(