Skip to content

Commit

Permalink
style: apply prefer-node-protocol lint rule (#5627)
Browse files Browse the repository at this point in the history
it makes it perfectly clear that the package is a Node.js builtin module.
  • Loading branch information
Brooooooklyn committed Jan 19, 2024
1 parent 9d28eb5 commit fa8655e
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 23 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 3 additions & 2 deletions packages/backend/server/src/fundamentals/graphql/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions packages/common/infra/src/__tests__/migration.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/common/y-indexeddb/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/common/y-provider/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/electron/scripts/dev.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/electron/scripts/make-squirrel.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/electron/src/main/config-storage/persist.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/electron/src/main/main-window.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/electron/src/main/onboarding.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/electron/src/main/protocol.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/electron/src/main/ui/google-auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { parse } from 'node:url';

import { app, BrowserWindow, shell } from 'electron';
import { parse } from 'url';

import { logger } from '../logger';

Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/electron/test/main/mocks/updater.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/i18n/build.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fileURLToPath } from 'node:url';

import { runCli } from '@magic-works/i18n-codegen';
import { fileURLToPath } from 'url';

runCli(
{
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/i18n/dev.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fileURLToPath } from 'node:url';

import { runCli } from '@magic-works/i18n-codegen';
import { fileURLToPath } from 'url';

runCli(
{
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/templates/build.mjs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion tests/affine-cloud/e2e/collaboration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { resolve } from 'node:path';

import { skipOnboarding, test } from '@affine-test/kit/playwright';
import {
addUserToWorkspace,
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion tests/affine-local/e2e/image-preview.spec.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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(
Expand Down

0 comments on commit fa8655e

Please sign in to comment.