Skip to content

Commit

Permalink
chore: lint JavaScript code (#1741)
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao authored Jun 25, 2024
1 parent 4cd9da5 commit 92e2cbe
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 102 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ typedoc/**/*
**/test/fixtures/**/node_modules/**
**/test/work/*
dist/
src/targets.js
64 changes: 44 additions & 20 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
'use strict'
const eslintConfig = {
extends: [
'eslint:recommended',
'plugin:ava/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:promise/recommended',
'standard',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
'eslint:recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
"ecmaVersion": "latest"
},
env: {
"es6": true,
"node": true
},
plugins: [
'ava',
'ava'
],
rules: {
'ava/no-import-test-files': 0,
Expand All @@ -25,17 +21,45 @@ const eslintConfig = {
2,
{
CallExpression: {
arguments: 'first',
arguments: 'first'
},
SwitchCase: 1,
},
SwitchCase: 1
}
],
'no-console': 0,
strict: 'error',
'comma-dangle': ['error', 'only-multiline'],
semi: ['error', 'always'],
'space-before-function-paren': ['error', 'never']
'comma-dangle': ['error', 'never'],
semi: ['error', 'never'],
'space-before-function-paren': ['error', 'always']
},
};
overrides: [
{
files: ["**/*.ts"],
extends: [
'eslint:recommended',
'plugin:ava/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:promise/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript'
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module'
},
rules: {
'comma-dangle': ['error', 'always-multiline'],
semi: ['error', 'always'],
'space-before-function-paren': ['error', {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}]
}
}
]
}

module.exports = eslintConfig;
module.exports = eslintConfig
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@
"@types/parse-author": "^2.0.2",
"@types/plist": "^3.0.4",
"@types/resolve": "^1.20.4",
"@types/semver": "^7.5.8",
"@types/yargs-parser": "^21.0.2",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/eslint-plugin": "7.2.0",
"@typescript-eslint/parser": "^6.9.1",
"ava": "^3.10.1",
"buffer-equal": "^1.0.0",
"codecov": "^3.0.0",
"copyfiles": "^2.4.1",
"eslint": "^8.52.0",
"eslint-config-standard": "^16.0.0",
"eslint-plugin-ava": "^14.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-promise": "^6.2.0",
"lodash": "^4.17.21",
"nyc": "^15.0.0",
"pkg-up": "^4.0.0",
Expand All @@ -82,7 +82,7 @@
"codecov": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"coverage": "nyc ava test/index.js",
"docs:build": "node test/ci/build_docs.js",
"lint": "eslint --ext .ts .",
"lint": "eslint .",
"prepublish": "npm run build",
"pretest": "npm run build",
"test": "npm run lint && npm run coverage"
Expand Down
8 changes: 4 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ export function parseArgs(argv: string[]) {
'junk',
'overwrite',
'prune',
'quiet'
'quiet',
],
default: {
'deref-symlinks': true,
junk: true,
prune: true
prune: true,
},
string: [
'electron-version',
'out'
]
'out',
],
});

args.dir = args._[0];
Expand Down
2 changes: 1 addition & 1 deletion src/infer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export async function getMetadataFromPackageJSON(platforms: SupportedPlatform[],
'dependencies.electron',
'devDependencies.electron',
'dependencies.electron-nightly',
'devDependencies.electron-nightly'
'devDependencies.electron-nightly',
]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/prune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'path';

const ELECTRON_MODULES = [
'electron',
'electron-nightly'
'electron-nightly',
];

export class Pruner {
Expand All @@ -20,7 +20,7 @@ export class Pruner {
this.quiet = quiet;
this.galactus = new DestroyerOfModules({
rootDirectory: dir,
shouldKeepModuleTest: (module, isDevDep) => this.shouldKeepModule(module, isDevDep)
shouldKeepModuleTest: (module, isDevDep) => this.shouldKeepModule(module, isDevDep),
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/resedit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function resedit(exePath: string, options: ExeMetadata) {
res.entries,
existingIconGroups[0].id,
existingIconGroups[0].lang,
iconFile.icons.map((item) => item.data)
iconFile.icons.map((item) => item.data),
);
}

Expand All @@ -78,7 +78,7 @@ export async function resedit(exePath: string, options: ExeMetadata) {
const currentManifestContent = Buffer.from(manifestEntry.bin).toString('utf-8');
const newContent = currentManifestContent.replace(
/(<requestedExecutionLevel level=")asInvoker(" uiAccess="false"\/>)/g,
`$1${options.win32Metadata?.['requested-execution-level']}$2`
`$1${options.win32Metadata?.['requested-execution-level']}$2`,
);
manifestEntry.bin = Buffer.from(newContent, 'utf-8');
}
Expand Down
2 changes: 1 addition & 1 deletion src/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function packageUniversalMac(packageForPlatformAndArchWithOpts: Pac

const tempPackages = {} as Record<SupportedArch, string>;

await Promise.all((['x64', 'arm64'] as SupportedArch[]).map(async(tempArch) => {
await Promise.all((['x64', 'arm64'] as SupportedArch[]).map(async (tempArch) => {
const tempOpts = {
...comboOpts,
arch: tempArch,
Expand Down
1 change: 1 addition & 0 deletions temp/targets.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
'use strict'
module.exports = require('../dist/targets')
2 changes: 1 addition & 1 deletion test/_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function fixtureSubdir (subdir) {
* Skip testing darwin/mas target on Windows since Electron Packager itself skips it
* (see https://github.com/electron/packager/issues/71)
*/
function skipDownloadingMacZips (platform, arch) {
function skipDownloadingMacZips (platform) {
return isPlatformMac(platform) && process.platform === 'win32'
}

Expand Down
4 changes: 2 additions & 2 deletions test/_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ const test = require('ava')

const ORIGINAL_CWD = process.cwd()

test.before(async t => {
test.before(async () => {
if (!process.env.CI) {
await setup.setupTestsuite()
process.chdir(setup.WORK_CWD)
}
return Promise.resolve(process.chdir(setup.WORK_CWD))
})

test.after.always(async t => {
test.after.always(async () => {
process.chdir(ORIGINAL_CWD)
await fs.remove(setup.WORK_CWD)
})
Expand Down
2 changes: 1 addition & 1 deletion test/prune.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function assertDependencyExists (t, resourcesPath, moduleName) {
await util.assertDirectory(t, modulePath, 'module is a directory')
}

async function createPruneOptionTest (t, baseOpts, prune, testMessage) {
async function createPruneOptionTest (t, baseOpts, prune) {
const opts = {
...baseOpts,
name: 'pruneTest',
Expand Down
2 changes: 1 addition & 1 deletion test/targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const config = require('./config.json')
const sinon = require('sinon')
const { allOfficialArchsForPlatformAndVersion, createPlatformArchPairs, osModules, supported, validateListFromOptions } = require('../dist/targets')
const { allOfficialArchsForPlatformAndVersion, createPlatformArchPairs, supported, validateListFromOptions } = require('../dist/targets')
const test = require('ava')
const util = require('./_util')

Expand Down
Loading

0 comments on commit 92e2cbe

Please sign in to comment.