Skip to content

Commit

Permalink
build: configure import/order eslint rule (#2997)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound authored Oct 26, 2022
1 parent 1472149 commit 247bcc8
Show file tree
Hide file tree
Showing 128 changed files with 570 additions and 375 deletions.
23 changes: 21 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"plugins": ["mocha"],
"plugins": ["mocha", "import"],
"env": {
"mocha": true
},
Expand All @@ -17,7 +17,26 @@
"vars": "all"
}
],
"mocha/no-exclusive-tests": "error"
"mocha/no-exclusive-tests": "error",
"import/order": [
"error",
{
"groups": ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
],
"sort-imports": [
"error",
{
"ignoreDeclarationSort": true,
"allowSeparatedGroups": true,
"ignoreCase": true
}
]
},
"overrides": [
{
Expand Down
1 change: 1 addition & 0 deletions ci/fix-changelog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs');
const path = require('path');

const prettier = require('prettier');

const changelogPath = path.resolve(__dirname, '..', 'CHANGELOG.md');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"cross-env": "^7.0.2",
"electron-installer-common": "^0.10.2",
"eslint": "^8.0.1",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-mocha": "^9.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/api/cli/src/electron-forge-import.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { api } from '@electron-forge/core';
import path from 'path';

import fs from 'fs-extra';
import { api } from '@electron-forge/core';
import program from 'commander';
import path from 'path';
import fs from 'fs-extra';

import './util/terminate';
import workingDir from './util/working-dir';
Expand Down
6 changes: 3 additions & 3 deletions packages/api/cli/src/electron-forge-init.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { api, InitOptions } from '@electron-forge/core';
import path from 'path';

import fs from 'fs-extra';
import { api, InitOptions } from '@electron-forge/core';
import program from 'commander';
import path from 'path';
import fs from 'fs-extra';

import './util/terminate';
import workingDir from './util/working-dir';
Expand Down
6 changes: 3 additions & 3 deletions packages/api/cli/src/electron-forge-make.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { api, MakeOptions } from '@electron-forge/core';
import path from 'path';

import fs from 'fs-extra';
import { api, MakeOptions } from '@electron-forge/core';
import { initializeProxy } from '@electron/get';
import program from 'commander';
import path from 'path';
import fs from 'fs-extra';

import './util/terminate';
import workingDir from './util/working-dir';
Expand Down
6 changes: 3 additions & 3 deletions packages/api/cli/src/electron-forge-package.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { api, PackageOptions } from '@electron-forge/core';
import path from 'path';

import fs from 'fs-extra';
import { api, PackageOptions } from '@electron-forge/core';
import { initializeProxy } from '@electron/get';
import program from 'commander';
import path from 'path';
import fs from 'fs-extra';

import './util/terminate';
import workingDir from './util/working-dir';
Expand Down
8 changes: 4 additions & 4 deletions packages/api/cli/src/electron-forge-publish.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { api, PublishOptions } from '@electron-forge/core';
import path from 'path';

import fs from 'fs-extra';
import { api, PublishOptions } from '@electron-forge/core';
import { initializeProxy } from '@electron/get';
import program from 'commander';
import path from 'path';
import fs from 'fs-extra';

import './util/terminate';
import workingDir from './util/working-dir';
import { getMakeOptions } from './electron-forge-make';
import workingDir from './util/working-dir';

(async () => {
let dir = process.cwd();
Expand Down
5 changes: 3 additions & 2 deletions packages/api/cli/src/electron-forge-start.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import path from 'path';

import { api, StartOptions } from '@electron-forge/core';
import { ElectronProcess } from '@electron-forge/shared-types';
import fs from 'fs-extra';
import path from 'path';
import program from 'commander';
import fs from 'fs-extra';

import './util/terminate';
import workingDir from './util/working-dir';
Expand Down
8 changes: 4 additions & 4 deletions packages/api/cli/src/util/check-system.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { exec } from 'child_process';
import debug from 'debug';
import fs from 'fs-extra';
import os from 'os';
import path from 'path';
import semver from 'semver';

import { utils as forgeUtils } from '@electron-forge/core';
import { OraImpl } from '@electron-forge/async-ora';
import { utils as forgeUtils } from '@electron-forge/core';
import debug from 'debug';
import fs from 'fs-extra';
import semver from 'semver';

const d = debug('electron-forge:check-system');

Expand Down
3 changes: 2 additions & 1 deletion packages/api/cli/src/util/working-dir.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs-extra';
import path from 'path';

import fs from 'fs-extra';

export default function workingDir(dir: string, cwd: string, checkExisting = true): string {
let finalDir = dir;
if (cwd) {
Expand Down
5 changes: 3 additions & 2 deletions packages/api/cli/test/cli_spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import path from 'path';

import { spawn } from '@malept/cross-spawn-promise';
import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';

chai.use(chaiAsPromised);

Expand Down
11 changes: 6 additions & 5 deletions packages/api/core/src/api/import.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import path from 'path';

import { asyncOra } from '@electron-forge/async-ora';
import baseTemplate from '@electron-forge/template-base';
import chalk from 'chalk';
import debug from 'debug';
import fs from 'fs-extra';
import { merge } from 'lodash';
import path from 'path';

import initGit from './init-scripts/init-git';
import { deps, devDeps, exactDevDeps } from './init-scripts/init-npm';

import { updateElectronDependency } from '../util/electron-version';
import { setInitialForgeConfig } from '../util/forge-config';
import { info, warn } from '../util/messages';
import installDepList, { DepType, DepVersionRestriction } from '../util/install-dependencies';
import { info, warn } from '../util/messages';
import { readRawPackageJson } from '../util/read-package-json';
import upgradeForgeConfig, { updateUpgradedForgeDevDeps } from '../util/upgrade-forge-config';

import initGit from './init-scripts/init-git';
import { deps, devDeps, exactDevDeps } from './init-scripts/init-npm';

const d = debug('electron-forge:import');

export interface ImportOptions {
Expand Down
4 changes: 2 additions & 2 deletions packages/api/core/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ElectronProcess, ForgeMakeResult } from '@electron-forge/shared-types';

import ForgeUtils from '../util';

import _import, { ImportOptions } from './import';
import init, { InitOptions } from './init';
import make, { MakeOptions } from './make';
import _package, { PackageOptions } from './package';
import publish, { PublishOptions } from './publish';
import start, { StartOptions } from './start';

import ForgeUtils from '../util';

export class ForgeAPI {
/**
* Attempt to import a given module directory to the Electron Forge standard.
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/api/init-scripts/find-template.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { asyncOra } from '@electron-forge/async-ora';
import { ForgeTemplate } from '@electron-forge/shared-types';
import debug from 'debug';
import resolvePackage from 'resolve-package';

import { ForgeTemplate } from '@electron-forge/shared-types';
import { PossibleModule } from '../../util/require-search';

const d = debug('electron-forge:init:find-template');
Expand Down
3 changes: 2 additions & 1 deletion packages/api/core/src/api/init-scripts/init-git.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { asyncOra } from '@electron-forge/async-ora';
import { exec } from 'child_process';

import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';

const d = debug('electron-forge:init:git');
Expand Down
3 changes: 2 additions & 1 deletion packages/api/core/src/api/init-scripts/init-npm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import path from 'path';

import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';
import fs from 'fs-extra';
import path from 'path';

import installDepList, { DepType, DepVersionRestriction } from '../../util/install-dependencies';

Expand Down
12 changes: 7 additions & 5 deletions packages/api/core/src/api/init.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import path from 'path';

import { asyncOra } from '@electron-forge/async-ora';
import debug from 'debug';
import { ForgeTemplate } from '@electron-forge/shared-types';
import debug from 'debug';
import fs from 'fs-extra';
import path from 'path';
import semver from 'semver';

import { setInitialForgeConfig } from '../util/forge-config';
import installDepList, { DepType } from '../util/install-dependencies';
import { readRawPackageJson } from '../util/read-package-json';

import findTemplate from './init-scripts/find-template';
import initDirectory from './init-scripts/init-directory';
import initGit from './init-scripts/init-git';
import initNPM from './init-scripts/init-npm';
import installDepList, { DepType } from '../util/install-dependencies';
import { readRawPackageJson } from '../util/read-package-json';
import { setInitialForgeConfig } from '../util/forge-config';

const d = debug('electron-forge:init');

Expand Down
17 changes: 9 additions & 8 deletions packages/api/core/src/api/make.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import path from 'path';

import { asyncOra } from '@electron-forge/async-ora';
import chalk from 'chalk';
import { getHostArch } from '@electron/get';
import { IForgeResolvableMaker, ForgeConfig, ForgeArch, ForgePlatform, ForgeMakeResult, ForgeConfigMaker } from '@electron-forge/shared-types';
import MakerBase from '@electron-forge/maker-base';
import fs from 'fs-extra';
import path from 'path';
import { ForgeArch, ForgeConfig, ForgeConfigMaker, ForgeMakeResult, ForgePlatform, IForgeResolvableMaker } from '@electron-forge/shared-types';
import { getHostArch } from '@electron/get';
import chalk from 'chalk';
import filenamify from 'filenamify';
import fs from 'fs-extra';

import { getElectronVersion } from '../util/electron-version';
import getForgeConfig from '../util/forge-config';
import { runHook, runMutatingHook } from '../util/hook';
import { info, warn } from '../util/messages';
import getCurrentOutDir from '../util/out-dir';
import parseArchs from '../util/parse-archs';
import { readMutatedPackageJson } from '../util/read-package-json';
import resolveDir from '../util/resolve-dir';
import getCurrentOutDir from '../util/out-dir';
import { getElectronVersion } from '../util/electron-version';
import requireSearch from '../util/require-search';
import resolveDir from '../util/resolve-dir';

import packager from './package';

Expand Down
17 changes: 9 additions & 8 deletions packages/api/core/src/api/package.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import { ora as realOra, fakeOra, OraImpl } from '@electron-forge/async-ora';
import path from 'path';
import { promisify } from 'util';

import { fakeOra, OraImpl, ora as realOra } from '@electron-forge/async-ora';
import { ForgeArch, ForgePlatform } from '@electron-forge/shared-types';
import { getHostArch } from '@electron/get';
import chalk from 'chalk';
import debug from 'debug';
import fs from 'fs-extra';
import { getHostArch } from '@electron/get';
import glob from 'fast-glob';
import packager, { HookFunction } from 'electron-packager';
import path from 'path';
import { promisify } from 'util';
import glob from 'fast-glob';
import fs from 'fs-extra';

import { getElectronVersion } from '../util/electron-version';
import getForgeConfig from '../util/forge-config';
import { runHook } from '../util/hook';
import { warn } from '../util/messages';
import getCurrentOutDir from '../util/out-dir';
import { readMutatedPackageJson } from '../util/read-package-json';
import rebuildHook from '../util/rebuild';
import requireSearch from '../util/require-search';
import resolveDir from '../util/resolve-dir';
import getCurrentOutDir from '../util/out-dir';
import { getElectronVersion } from '../util/electron-version';

const d = debug('electron-forge:packager');

Expand Down
16 changes: 8 additions & 8 deletions packages/api/core/src/api/publish.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import path from 'path';

import { asyncOra } from '@electron-forge/async-ora';
import PublisherBase from '@electron-forge/publisher-base';
import {
IForgeResolvablePublisher,
IForgePublisher,
ForgeConfigPublisher,
ForgeMakeResult,
IForgePublisher,
IForgeResolvablePublisher,
// ForgePlatform,
} from '@electron-forge/shared-types';
import PublisherBase from '@electron-forge/publisher-base';

import chalk from 'chalk';
import debug from 'debug';
import fs from 'fs-extra';
import path from 'path';

import getForgeConfig from '../util/forge-config';
import resolveDir from '../util/resolve-dir';
import PublishState from '../util/publish-state';
import getCurrentOutDir from '../util/out-dir';
import PublishState from '../util/publish-state';
import requireSearch from '../util/require-search';
import resolveDir from '../util/resolve-dir';

import make, { MakeOptions } from './make';
import requireSearch from '../util/require-search';

const d = debug('electron-forge:publish');

Expand Down
9 changes: 5 additions & 4 deletions packages/api/core/src/api/start.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { spawn, SpawnOptions } from 'child_process';

import { asyncOra } from '@electron-forge/async-ora';
import { ElectronProcess, ForgeArch, ForgePlatform, StartOptions } from '@electron-forge/shared-types';
import chalk from 'chalk';
import debug from 'debug';
import { ElectronProcess, ForgeArch, ForgePlatform, StartOptions } from '@electron-forge/shared-types';
import { spawn, SpawnOptions } from 'child_process';

import locateElectronExecutable from '../util/electron-executable';
import { getElectronVersion } from '../util/electron-version';
import getForgeConfig from '../util/forge-config';
import locateElectronExecutable from '../util/electron-executable';
import { runHook } from '../util/hook';
import { readMutatedPackageJson } from '../util/read-package-json';
import rebuild from '../util/rebuild';
import resolveDir from '../util/resolve-dir';
import { runHook } from '../util/hook';

const d = debug('electron-forge:start');

Expand Down
3 changes: 2 additions & 1 deletion packages/api/core/src/util/download-to-file.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as path from 'path';

import * as fs from 'fs-extra';
import got, { HTTPError } from 'got';
import * as path from 'path';
import ProgressBar from 'progress';

const PROGRESS_BAR_DELAY_IN_SECONDS = 30;
Expand Down
Loading

0 comments on commit 247bcc8

Please sign in to comment.