Skip to content

Commit

Permalink
cache + use plugin-n
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao committed Jan 20, 2025
1 parent 0408595 commit 2923757
Show file tree
Hide file tree
Showing 35 changed files with 112 additions and 84 deletions.
9 changes: 9 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ commands:
name: 'Build Electron Forge'
command: |
yarn build
- restore_cache:
name: Restore ESLint Cache
keys:
- v1-lint-dependencies-{{ checksum "yarn.lock" }}-{{ checksum ".eslintrc.json" }}
- run:
name: 'Lint codebase'
command: |
yarn lint
yarn syncpack
- save_cache:
name: Save ESlint Cache
paths:
- .eslintcache
key: v1-lint-dependencies-{{ checksum "yarn.lock" }}-{{ checksum ".eslintrc.json" }}
run-fast-tests:
steps:
- node/install-packages:
Expand Down
53 changes: 28 additions & 25 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"globals": {
"NodeJS": "readonly"
},
"extends": ["eslint:recommended", "plugin:import/errors", "plugin:import/warnings", "plugin:node/recommended", "plugin:promise/recommended", "prettier"],
"extends": ["eslint:recommended", "plugin:import/errors", "plugin:import/warnings", "plugin:n/recommended", "plugin:promise/recommended", "prettier"],
"rules": {
"no-unused-vars": [
"error",
Expand Down Expand Up @@ -39,7 +39,8 @@
"ignoreCase": true
}
],
"import/no-named-as-default": "error"
"import/no-named-as-default": "error",
"n/no-process-exit": "off"
},
"overrides": [
{
Expand All @@ -56,16 +57,11 @@
"rules": {
// There is no "recommended" ruleset for tsdoc yet.
"tsdoc/syntax": "warn",
"node/no-unsupported-features/es-syntax": [
"n/no-missing-import": [
"error",
{
"ignores": ["modules"]
}
],
"node/no-missing-import": [
"error",
{
"tryExtensions": [".js", ".ts", ".d.ts"]
"tryExtensions": [".js", ".ts", ".d.ts"],
"ignoreTypeImport": true
}
],
"no-throw-literal": "off",
Expand All @@ -86,24 +82,25 @@
{
"files": ["ci/**/*.js"],
"rules": {
"node/no-unpublished-require": "off"
"n/no-unpublished-require": "off"
}
},
{
"files": ["packages/*/*/spec/**/*.spec.ts", "packages/*/*/spec/fixture/**/*.ts"],
"rules": {
"global-require": "off",
"import/no-dynamic-require": "off",
"node/no-extraneous-import": "off",
"node/no-unpublished-import": "off",
"node/no-unpublished-require": "off"
"n/no-extraneous-import": "off",
"n/no-unpublished-import": "off",
"n/no-unpublished-require": "off",
"n/no-unsupported-features/node-builtins": "off"
}
},
{
"files": ["packages/api/cli/src/**/*.ts", "packages/external/create-electron-app/src/**/*.ts", "tools/*.{js,ts}"],
"rules": {
"no-process-exit": "off",
"node/shebang": [
"n/hashbang": [
"error",
{
"convertPath": {
Expand All @@ -122,9 +119,9 @@
{
"files": ["packages/*/*/spec/fixture/**/*.js", "packages/*/*/spec/fixtures/**/*.js"],
"rules": {
"node/no-extraneous-require": "off",
"node/no-missing-require": "off",
"node/no-unpublished-require": "off"
"n/no-extraneous-require": "off",
"n/no-missing-require": "off",
"n/no-unpublished-require": "off"
}
},
{
Expand All @@ -133,9 +130,9 @@
"no-process-exit": "off",
"no-undef": "off",
"import/no-unresolved": "off",
"node/no-missing-import": "off",
"node/no-unpublished-import": "off",
"node/no-unsupported-features/es-syntax": "off"
"n/no-missing-import": "off",
"n/no-unpublished-import": "off",
"n/no-unsupported-features/es-syntax": "off"
}
},
{
Expand All @@ -148,21 +145,27 @@
{
"files": ["tools/*.{js,ts}"],
"rules": {
"node/no-unpublished-import": "off",
"node/no-unpublished-require": "off",
"node/shebang": "off"
"n/no-unpublished-import": "off",
"n/no-unpublished-require": "off",
"n/hashbang": "off"
}
},
{
"files": ["packages/plugin/vite/src/**/*.ts"],
"rules": {
"node/no-unpublished-import": [
"n/no-unpublished-import": [
"error",
{
"allowModules": ["vite"]
}
]
}
},
{
"files": ["packages/utils/web-multi-logger/static/*.js"],
"rules": {
"n/no-unsupported-features/node-builtins": "off"
}
}
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ packages/plugin/fuses/spec/fixture/app
.links
reports
packages/**/typedoc.json
.eslintcache
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"postbuild": "ts-node tools/test-dist",
"docs": "yarn build && npx typedoc",
"lerna:publish": "lerna publish --force-publish --conventional-commits --no-changelog --exact",
"lint:js": "prettier --check . && eslint .",
"lint:js": "prettier --check . && eslint . --cache",
"lint:markdown": "electron-markdownlint \"**/*.md\"",
"lint:markdown-js": "electron-lint-markdown-standard --root . --ignore-path .markdownlintignore --semi \"**/*.md\"",
"lint:markdown-links": "electron-lint-markdown-links --root . --ignore-path .markdownlintignore \"**/*.md\"",
"lint": "npm run lint:js && npm run lint:markdown && npm run lint:markdown-js && npm run lint:markdown-links",
"lint:fix": "prettier --write . && eslint --fix .",
"lint:fix": "prettier --write . && eslint --fix . --cache",
"link:prepare": "lerna exec -- node ../../../tools/silent.js yarn link --silent --no-bin-links --link-folder ../../../.links",
"link:remove": "lerna exec -- node ../../../tools/silent.js yarn unlink --silent --no-bin-links --link-folder ../../../.links",
"test": "xvfb-maybe vitest run --project fast --project slow",
Expand Down Expand Up @@ -106,7 +106,7 @@
"eslint": "^8.56.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-n": "^17.15.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-tsdoc": "^0.2.14",
"fork-ts-checker-webpack-plugin": "^7.2.13",
Expand Down
1 change: 0 additions & 1 deletion packages/api/core/spec/fast/make.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import * as path from 'node:path';

import { describe, expect, it, vi } from 'vitest';
Expand Down
1 change: 0 additions & 1 deletion packages/api/core/spec/fast/publish.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
Expand Down
1 change: 0 additions & 1 deletion packages/api/core/spec/fast/start.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import { ChildProcess, spawn } from 'node:child_process';

import { ElectronProcess } from '@electron-forge/shared-types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import { hasYarn, yarnOrNpmSpawn } from '@electron-forge/core-utils';
import { beforeEach, describe, expect, it, vi } from 'vitest';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line node/no-unsupported-features/es-syntax
export default {
buildIdentifier: 'esm',
defaultResolved: true,
Expand Down
7 changes: 3 additions & 4 deletions packages/api/core/spec/slow/api.slow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ensureTestDirIsNonexistent, expectLintToPass } from '@electron-forge/te
import { readMetadata } from 'electron-installer-common';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

// eslint-disable-next-line n/no-missing-import
import { api, InitOptions } from '../../src/api';
import installDeps from '../../src/util/install-dependencies';
import { readRawPackageJson } from '../../src/util/read-package-json';
Expand Down Expand Up @@ -88,13 +89,11 @@ describe.each([{ installer: 'npm' }, { installer: 'yarn' }])(`init (with $instal
beforeInitTest({ template: path.resolve(__dirname, '../fixture/custom_init') });

it('should add custom dependencies', async () => {
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const packageJSON = await import(path.resolve(dir, 'package.json'));
expect(packageJSON.dependencies).toHaveProperty('debug');
});

it('should add custom devDependencies', async () => {
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const packageJSON = await import(path.resolve(dir, 'package.json'));
expect(packageJSON.devDependencies).toHaveProperty('lodash');
});
Expand Down Expand Up @@ -281,7 +280,7 @@ describe('Electron Forge API', () => {

it('can make from custom outDir without errors', async () => {
await updatePackageJSON(dir, async (packageJSON) => {
// eslint-disable-next-line node/no-missing-require
// eslint-disable-next-line n/no-missing-require
packageJSON.config.forge.makers = [{ name: require.resolve('@electron-forge/maker-zip') } as IForgeResolvableMaker];
});

Expand Down Expand Up @@ -475,7 +474,7 @@ describe('Electron Forge API', () => {
await expect(
api.make({
dir,
// eslint-disable-next-line node/no-missing-require
// eslint-disable-next-line n/no-missing-require
overrideTargets: [require.resolve('@electron-forge/maker-zip'), require.resolve('@electron-forge/maker-dmg')],
platform: 'mas',
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe.runIf(!(process.platform === 'linux' && process.env.CI))('install-depen
it('should install the latest minor version when the dependency has a caret', async () => {
await installDeps(installDir, ['debug@^2.0.0']);

// eslint-disable-next-line node/no-unsupported-features/es-syntax
const packageJSON = await import(path.resolve(installDir, 'node_modules', 'debug', 'package.json'));
expect(packageJSON.version).not.toEqual('2.0.0');
});
Expand Down
1 change: 1 addition & 0 deletions packages/api/core/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ElectronProcess, ForgeMakeResult } from '@electron-forge/shared-types';

// eslint-disable-next-line n/no-missing-import
import ForgeUtils from '../util';

import _import, { ImportOptions } from './import';
Expand Down
1 change: 1 addition & 0 deletions packages/api/core/src/util/forge-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as interpret from 'interpret';
import { template } from 'lodash';
import * as rechoir from 'rechoir';

// eslint-disable-next-line n/no-missing-import
import { dynamicImportMaybe } from '../../helper/dynamic-import.js';

import { runMutatingHook } from './hook';
Expand Down
1 change: 1 addition & 0 deletions packages/api/core/src/util/import-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'node:path';

import debug from 'debug';

// eslint-disable-next-line n/no-missing-import
import { dynamicImportMaybe } from '../../helper/dynamic-import.js';

const d = debug('electron-forge:import-search');
Expand Down
1 change: 1 addition & 0 deletions packages/api/core/src/util/plugin-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { autoTrace } from '@electron-forge/tracer';
import chalk from 'chalk';
import debug from 'debug';

// eslint-disable-next-line n/no-missing-import
import { StartOptions } from '../api';

import importSearch from './import-search';
Expand Down
1 change: 0 additions & 1 deletion packages/maker/deb/spec/MakerDeb.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import path from 'node:path';

import { MakerOptions } from '@electron-forge/maker-base';
Expand Down
2 changes: 1 addition & 1 deletion packages/maker/deb/src/MakerDeb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class MakerDeb extends MakerBase<MakerDebConfig> {
}

async make({ dir, makeDir, targetArch }: MakerOptions): Promise<string[]> {
// eslint-disable-next-line node/no-missing-require
// eslint-disable-next-line n/no-missing-require
const installer = require('electron-installer-debian');

const outDir = path.resolve(makeDir, 'deb', targetArch);
Expand Down
1 change: 0 additions & 1 deletion packages/maker/dmg/spec/MakerDMG.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import { MakerOptions } from '@electron-forge/maker-base';
import fs from 'fs-extra';
import { describe, expect, it, vi } from 'vitest';
Expand Down
1 change: 0 additions & 1 deletion packages/maker/flatpak/spec/MakerFlatpak.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import path from 'node:path';

import { MakerOptions } from '@electron-forge/maker-base';
Expand Down
2 changes: 1 addition & 1 deletion packages/maker/flatpak/src/MakerFlatpak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class MakerFlatpak extends MakerBase<MakerFlatpakConfig> {
}

async make({ dir, makeDir, targetArch }: MakerOptions): Promise<string[]> {
// eslint-disable-next-line node/no-missing-require
// eslint-disable-next-line n/no-missing-require
const installer = require('@malept/electron-installer-flatpak');

const arch = flatpakArch(targetArch);
Expand Down
1 change: 0 additions & 1 deletion packages/maker/pkg/spec/MakerPKG.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import path from 'node:path';

import { flatAsync } from '@electron/osx-sign';
Expand Down
1 change: 0 additions & 1 deletion packages/maker/rpm/spec/MakerRpm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import path from 'node:path';

import { MakerOptions } from '@electron-forge/maker-base';
Expand Down
2 changes: 1 addition & 1 deletion packages/maker/rpm/src/MakerRpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class MakerRpm extends MakerBase<MakerRpmConfig> {
}

async make({ dir, makeDir, targetArch }: MakerOptions): Promise<string[]> {
// eslint-disable-next-line node/no-missing-require
// eslint-disable-next-line n/no-missing-require
const installer = require('electron-installer-redhat');

const outDir = path.resolve(makeDir, 'rpm', targetArch);
Expand Down
1 change: 0 additions & 1 deletion packages/maker/snap/spec/MakerSnap.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import path from 'node:path';

import { MakerOptions } from '@electron-forge/maker-base';
Expand Down
1 change: 0 additions & 1 deletion packages/maker/zip/spec/MakerZip.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import os from 'node:os';
import path from 'node:path';

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/vite/spec/ViteConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('ViteConfigGenerator', () => {

expect(buildConfig.root).toEqual(configRoot);
expect(buildConfig.mode).toEqual('production');
expect(buildConfig.build?.emptyOutDir).false;
expect(buildConfig.build?.emptyOutDir).toBe(false);
expect(buildConfig.build?.outDir).toEqual('.vite/build');
expect(buildConfig.build?.watch).toBeNull();
expect(buildConfig.build?.minify).toBe(true);
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/vite/src/VitePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ViteConfigGenerator from './ViteConfig';
import type { VitePluginConfig } from './Config';
import type { ForgeMultiHookMap, ResolvedForgeConfig } from '@electron-forge/shared-types';
import type { AddressInfo } from 'node:net';
// eslint-disable-next-line node/no-extraneous-import
// eslint-disable-next-line n/no-extraneous-import
import type { RollupWatcher } from 'rollup';

const d = debug('electron-forge:plugin:vite');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */

import { ForgeMakeResult, ResolvedForgeConfig } from '@electron-forge/shared-types';
import { http, HttpResponse } from 'msw';
import { setupServer } from 'msw/node';
Expand Down
1 change: 1 addition & 0 deletions packages/publisher/gcs/src/Config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PredefinedAcl, StorageOptions } from '@google-cloud/storage';
// eslint-disable-next-line n/no-missing-import
import { ConfigMetadata } from '@google-cloud/storage/build/cjs/src/resumable-upload';

import { GCSArtifact } from './PublisherGCS';
Expand Down
1 change: 0 additions & 1 deletion packages/publisher/github/spec/util/github.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import { OctokitOptions } from '@octokit/core/dist-types/types.d';
import { beforeEach, describe, expect, it, vi } from 'vitest';

Expand Down
1 change: 0 additions & 1 deletion packages/template/base/spec/determine-author.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
import { describe, expect, it, vi } from 'vitest';

import determineAuthor from '../src/determine-author';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import testUtils from '@electron-forge/test-utils';
import glob from 'fast-glob';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

// eslint-disable-next-line n/no-missing-import
import { api } from '../../../api/core/dist/api';
import { initLink } from '../../../api/core/src/api/init-scripts/init-link';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import testUtils from '@electron-forge/test-utils';
import glob from 'fast-glob';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

// eslint-disable-next-line n/no-missing-import
import { api } from '../../../api/core/dist/api';
import { initLink } from '../../../api/core/src/api/init-scripts/init-link';

Expand Down
Loading

0 comments on commit 2923757

Please sign in to comment.