Skip to content

Commit a85810c

Browse files
committed
chore: update dev dependencies and clean up lint
1 parent 162e8c9 commit a85810c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1484
-1824
lines changed

.eslintrc.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn commitlint --edit $1

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

electron/electron-build-tools-typescript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const exports: typeof typescript = {
1313
const output = service.getEmitOutput(
1414
fileName,
1515
emitOnlyDtsFiles,
16-
forceDtsEmit
16+
forceDtsEmit,
1717
);
1818
contentMap.set(fileName, output.outputFiles[1].text);
1919

electron/listMochaTests.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,15 @@ process.once("uncaughtException", (err) => {
1414
// @ts-ignore
1515
import { app } from "electron";
1616

17-
const { SourceMapConsumer } = require(path.resolve(
18-
process.cwd(),
19-
"node_modules",
20-
"source-map"
21-
));
22-
const { retrieveSourceMap } = require(path.resolve(
23-
process.cwd(),
24-
"node_modules",
25-
"source-map-support"
26-
));
27-
const { getFileContent } = require(path.resolve(
28-
__dirname,
29-
"electron-build-tools-typescript"
30-
));
17+
const { SourceMapConsumer } = require(
18+
path.resolve(process.cwd(), "node_modules", "source-map"),
19+
);
20+
const { retrieveSourceMap } = require(
21+
path.resolve(process.cwd(), "node_modules", "source-map-support"),
22+
);
23+
const { getFileContent } = require(
24+
path.resolve(__dirname, "electron-build-tools-typescript"),
25+
);
3126

3227
const sourceMapConsumers = new Map<string, any>();
3328

@@ -127,12 +122,9 @@ app
127122
require(path.resolve(process.cwd(), "node_modules", "ts-node/register"));
128123

129124
// Don't load Mocha until after setting up ts-node
130-
const Mocha = require(path.resolve(
131-
process.cwd(),
132-
"spec",
133-
"node_modules",
134-
"mocha"
135-
));
125+
const Mocha = require(
126+
path.resolve(process.cwd(), "spec", "node_modules", "mocha"),
127+
);
136128

137129
const mocha: MochaType = new Mocha({
138130
ui: path.resolve(__dirname, "mocha-interface.js"),
@@ -164,7 +156,7 @@ app
164156
await mocha.loadFiles();
165157
const parsedSuites = parseTestSuites(mocha.suite);
166158
socket.write(JSON.stringify(parsedSuites, undefined, 4), () =>
167-
process.exit(0)
159+
process.exit(0),
168160
);
169161
} catch (err: any) {
170162
console.error(err);

electron/mocha-interface.ts

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,32 @@ import * as path from "path";
66
import type { Func, Suite, Test as TestType } from "mocha";
77
import type { CommonFunctions } from "mocha/lib/interfaces/common";
88

9-
const Test: typeof TestType = require(path.resolve(
10-
process.env["ELECTRON_ROOT"]!,
11-
"spec",
12-
"node_modules",
13-
"mocha",
14-
"lib",
15-
"test"
16-
));
9+
const Test: typeof TestType = require(
10+
path.resolve(
11+
process.env["ELECTRON_ROOT"]!,
12+
"spec",
13+
"node_modules",
14+
"mocha",
15+
"lib",
16+
"test",
17+
),
18+
);
1719

1820
function Interface(suite: Suite) {
1921
const suites = [suite];
2022

2123
suite.on("pre-require", (context, file, mocha) => {
22-
const common: CommonFunctions = require(path.resolve(
23-
process.env["ELECTRON_ROOT"]!,
24-
"spec",
25-
"node_modules",
26-
"mocha",
27-
"lib",
28-
"interfaces",
29-
"common"
30-
))(suites, context, mocha);
24+
const common: CommonFunctions = require(
25+
path.resolve(
26+
process.env["ELECTRON_ROOT"]!,
27+
"spec",
28+
"node_modules",
29+
"mocha",
30+
"lib",
31+
"interfaces",
32+
"common",
33+
),
34+
)(suites, context, mocha);
3135

3236
context.before = common.before;
3337
context.after = common.after;
@@ -42,7 +46,7 @@ function Interface(suite: Suite) {
4246
*/
4347
(context.describe as any) = (context.context as any) = (
4448
title: string,
45-
fn: (this: Suite) => void
49+
fn: (this: Suite) => void,
4650
) => {
4751
const suite = common.suite.create({ title, file, fn });
4852

@@ -72,7 +76,7 @@ function Interface(suite: Suite) {
7276
*/
7377
(context.describe.only as any) = (
7478
title: string,
75-
fn: (this: Suite) => void
79+
fn: (this: Suite) => void,
7680
) => {
7781
const suite = common.suite.only({ title, file, fn });
7882

@@ -89,7 +93,7 @@ function Interface(suite: Suite) {
8993
*/
9094
(context.it as any) = (context.specify as any) = (
9195
title: string,
92-
fn?: Func
96+
fn?: Func,
9397
) => {
9498
const suite = suites[0];
9599
if (suite.isPending()) {

electron/mocha-reporter.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ import * as path from "path";
33

44
import type { reporters, Runner, Test } from "mocha";
55

6-
const Base: reporters.Base = require(path.resolve(
7-
process.env["ELECTRON_ROOT"]!,
8-
"spec",
9-
"node_modules",
10-
"mocha",
11-
"lib",
12-
"reporters",
13-
"base"
14-
));
6+
const Base: reporters.Base = require(
7+
path.resolve(
8+
process.env["ELECTRON_ROOT"]!,
9+
"spec",
10+
"node_modules",
11+
"mocha",
12+
"lib",
13+
"reporters",
14+
"base",
15+
),
16+
);
1517

1618
// Encode any newlines so we can use newline as a delimeter
1719
function encodeNewlines(value: string) {
@@ -42,7 +44,7 @@ function Reporter(runner: Runner) {
4244
JSON.stringify({
4345
stream: "mocha-test-results",
4446
data: ["start", { total: runner.total }],
45-
})
47+
}),
4648
);
4749
});
4850

@@ -51,7 +53,7 @@ function Reporter(runner: Runner) {
5153
JSON.stringify({
5254
stream: "mocha-test-results",
5355
data: ["test-start", clean(test)],
54-
})
56+
}),
5557
);
5658
});
5759

@@ -60,7 +62,7 @@ function Reporter(runner: Runner) {
6062
JSON.stringify({
6163
stream: "mocha-test-results",
6264
data: ["test-end", clean(test)],
63-
})
65+
}),
6466
);
6567
});
6668

@@ -69,7 +71,7 @@ function Reporter(runner: Runner) {
6971
JSON.stringify({
7072
stream: "mocha-test-results",
7173
data: ["pass", clean(test)],
72-
})
74+
}),
7375
);
7476
});
7577

@@ -78,7 +80,7 @@ function Reporter(runner: Runner) {
7880
JSON.stringify({
7981
stream: "mocha-test-results",
8082
data: ["pending", clean(test)],
81-
})
83+
}),
8284
);
8385
});
8486

@@ -87,7 +89,10 @@ function Reporter(runner: Runner) {
8789
(output as any).err = err;
8890
(output as any).stack = err.stack || null;
8991
writeToSocket(
90-
JSON.stringify({ stream: "mocha-test-results", data: ["fail", output] })
92+
JSON.stringify({
93+
stream: "mocha-test-results",
94+
data: ["fail", output],
95+
}),
9196
);
9297
});
9398

@@ -97,7 +102,7 @@ function Reporter(runner: Runner) {
97102
stream: "mocha-test-results",
98103
// @ts-ignore
99104
data: ["end", this.stats],
100-
})
105+
}),
101106
);
102107
});
103108
});

electron/spec-runner.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ import * as path from "path";
66

77
export async function setupSpecRunner(electronRoot: string) {
88
const fs = require(path.resolve(electronRoot, "node_modules", "fs-extra"));
9-
const { hashElement } = require(path.resolve(
10-
electronRoot,
11-
"node_modules",
12-
"folder-hash"
13-
));
9+
const { hashElement } = require(
10+
path.resolve(electronRoot, "node_modules", "folder-hash"),
11+
);
1412

1513
const SCRIPT_DIR = path.resolve(electronRoot, "script");
1614

@@ -28,11 +26,11 @@ export async function setupSpecRunner(electronRoot: string) {
2826
cwd: electronRoot,
2927
stdio: "inherit",
3028
shell: true,
31-
}
29+
},
3230
);
3331
if (status !== 0) {
3432
throw new Error(
35-
`Electron typescript definition generation failed with exit code: ${status}.`
33+
`Electron typescript definition generation failed with exit code: ${status}.`,
3634
);
3735
}
3836
}
@@ -42,21 +40,21 @@ export async function setupSpecRunner(electronRoot: string) {
4240
(async () => {
4341
const hasher = crypto.createHash("SHA256");
4442
hasher.update(
45-
fs.readFileSync(path.resolve(electronRoot, "spec", "package.json"))
43+
fs.readFileSync(path.resolve(electronRoot, "spec", "package.json")),
4644
);
4745
hasher.update(
48-
fs.readFileSync(path.resolve(electronRoot, "spec", "yarn.lock"))
46+
fs.readFileSync(path.resolve(electronRoot, "spec", "yarn.lock")),
4947
);
5048
hasher.update(
51-
fs.readFileSync(path.resolve(SCRIPT_DIR, "spec-runner.js"))
49+
fs.readFileSync(path.resolve(SCRIPT_DIR, "spec-runner.js")),
5250
);
5351
return hasher.digest("hex");
5452
})(),
5553
(async () => {
5654
const specNodeModulesPath = path.resolve(
5755
electronRoot,
5856
"spec",
59-
"node_modules"
57+
"node_modules",
6058
);
6159
if (!fs.existsSync(specNodeModulesPath)) {
6260
return null;
@@ -80,7 +78,7 @@ export async function setupSpecRunner(electronRoot: string) {
8078

8179
const nodeDir = path.resolve(
8280
BASE,
83-
`out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`
81+
`out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`,
8482
);
8583
const env = {
8684
...process.env,
@@ -99,7 +97,7 @@ export async function setupSpecRunner(electronRoot: string) {
9997
env,
10098
cwd: dir,
10199
stdio: "inherit",
102-
}
100+
},
103101
);
104102
if (status !== 0 && !process.env.IGNORE_YARN_INSTALL_ERROR) {
105103
console.log(`Failed to yarn install in '${dir}'`);

eslint.config.mjs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// @ts-check
2+
3+
import eslint from '@eslint/js';
4+
import tseslint from 'typescript-eslint';
5+
6+
export default tseslint.config(
7+
eslint.configs.recommended,
8+
...tseslint.configs.recommended,
9+
{
10+
plugins: {
11+
'@typescript-eslint': tseslint.plugin,
12+
},
13+
languageOptions: {
14+
parser: tseslint.parser,
15+
parserOptions: {
16+
ecmaVersion: 2020,
17+
sourceType: 'module',
18+
},
19+
},
20+
rules: {
21+
'@typescript-eslint/naming-convention': [
22+
'warn',
23+
{
24+
selector: 'property',
25+
format: ['strictCamelCase', 'UPPER_CASE'],
26+
leadingUnderscore: 'allow'
27+
}
28+
],
29+
'@typescript-eslint/no-unused-vars': [
30+
'error',
31+
{
32+
args: 'all',
33+
argsIgnorePattern: '^_',
34+
caughtErrors: 'all',
35+
caughtErrorsIgnorePattern: '^_',
36+
destructuredArrayIgnorePattern: '^_',
37+
varsIgnorePattern: '^_',
38+
ignoreRestSiblings: true
39+
}
40+
],
41+
curly: 'warn',
42+
eqeqeq: 'warn',
43+
'no-throw-literal': 'warn',
44+
'no-useless-escape': 'warn',
45+
semi: 'off'
46+
},
47+
}
48+
);

0 commit comments

Comments
 (0)