Skip to content

Commit 997f272

Browse files
authored
@metamask/eslint-config*@8.0.0 (#50)
Bumps our `eslint` config dependencies to their latest version, adds our `jest` config and `eslint-plugin-jest` as new dev dependencies, and extends the that config for all tests from the root `.eslintrc.js`. Also adds an exception to the `@typescript-eslint/no-shadow` rule so that it doesn't complain about shadowing `jest` globals in tests.
1 parent bc5238e commit 997f272

8 files changed

Lines changed: 101 additions & 22 deletions

File tree

.eslintrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ module.exports = {
1313
files: ['**/*.ts'],
1414
extends: ['@metamask/eslint-config-typescript'],
1515
},
16+
17+
{
18+
files: ['**/*.test.ts', '**/*.test.js'],
19+
extends: ['@metamask/eslint-config-jest'],
20+
rules: {
21+
'@typescript-eslint/no-shadow': [
22+
'error',
23+
{ allow: ['describe', 'expect', 'it'] },
24+
],
25+
},
26+
},
1627
],
1728

1829
ignorePatterns: ['**/!.eslintrc.js', '**/dist*/'],

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@
3232
"@jest-runner/electron": "^3.0.1",
3333
"@lavamoat/allow-scripts": "^1.0.6",
3434
"@metamask/auto-changelog": "^2.5.0",
35-
"@metamask/eslint-config": "^7.0.1",
36-
"@metamask/eslint-config-nodejs": "^7.0.1",
37-
"@metamask/eslint-config-typescript": "^7.0.1",
35+
"@metamask/eslint-config": "^8.0.0",
36+
"@metamask/eslint-config-jest": "^8.0.0",
37+
"@metamask/eslint-config-nodejs": "^8.0.0",
38+
"@metamask/eslint-config-typescript": "^8.0.0",
3839
"@typescript-eslint/eslint-plugin": "^4.28.1",
3940
"@typescript-eslint/parser": "^4.28.1",
4041
"electron": "^12.0.7",
4142
"eslint": "^7.30.0",
4243
"eslint-config-prettier": "^8.3.0",
4344
"eslint-plugin-import": "^2.23.4",
45+
"eslint-plugin-jest": "^24.4.0",
4446
"eslint-plugin-node": "^11.1.0",
4547
"eslint-plugin-prettier": "^3.4.0",
4648
"prettier": "^2.3.2",

packages/controllers/src/plugins/PluginController.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ describe('PluginController Controller', () => {
4343

4444
expect(pluginController).toBeDefined();
4545
});
46+
4647
it('can create a worker and plugin controller and add a plugin and update its state', async () => {
4748
const workerExecutionEnvironment = new WebWorkerExecutionEnvironmentService(
4849
{
@@ -92,8 +93,8 @@ describe('PluginController Controller', () => {
9293
await pluginController.startPlugin(plugin.name);
9394
await pluginController.updatePluginState(plugin.name, { hello: 'world' });
9495
const pluginState = await pluginController.getPluginState(plugin.name);
95-
expect(pluginState).toEqual({ hello: 'world' });
96-
expect(pluginController.state.pluginStates).toEqual({
96+
expect(pluginState).toStrictEqual({ hello: 'world' });
97+
expect(pluginController.state.pluginStates).toStrictEqual({
9798
TestPlugin: {
9899
hello: 'world',
99100
},
@@ -160,7 +161,7 @@ describe('PluginController Controller', () => {
160161
params: {},
161162
id: 1,
162163
});
163-
expect(result).toEqual('test1');
164+
expect(result).toStrictEqual('test1');
164165
});
165166

166167
it('can add a plugin and use its JSON-RPC api with a stub execution env service', async () => {
@@ -240,7 +241,7 @@ describe('PluginController Controller', () => {
240241
params: {},
241242
id: 1,
242243
});
243-
expect(result).toEqual('test1');
244+
expect(result).toStrictEqual('test1');
244245
});
245246

246247
it('errors if attempting to start a plugin that was already started', async () => {

packages/controllers/src/plugins/PluginController.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ export class PluginController extends BaseController<
250250
if (!plugin) {
251251
throw new Error(`Plugin "${pluginName}" not found.`);
252252
}
253+
253254
if (!plugin.isRunning) {
254255
throw new Error(`Plugin "${pluginName}" already stopped.`);
255256
}
@@ -656,6 +657,7 @@ export class PluginController extends BaseController<
656657
if (Object.keys(initialPermissions).length === 0) {
657658
return [];
658659
}
660+
659661
if (initialPermissions === null) {
660662
return [];
661663
}
@@ -679,6 +681,7 @@ export class PluginController extends BaseController<
679681
pluginName: 'inlinePlugin',
680682
sourceCode: INLINE_PLUGINS[inlinePluginName],
681683
});
684+
682685
this.update((state: any) => {
683686
state.inlinePluginIsRunning = true;
684687
});

packages/controllers/src/services/WebWorkerExecutionEnvironmentService.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('Worker Controller', () => {
1717
});
1818
expect(webWorkerExecutionEnvironmentService).toBeDefined();
1919
});
20+
2021
it('can create a plugin worker and start the plugin', async () => {
2122
const webWorkerExecutionEnvironmentService =
2223
new WebWorkerExecutionEnvironmentService({
@@ -32,6 +33,6 @@ describe('Worker Controller', () => {
3233
console.log('foo');
3334
`,
3435
});
35-
expect(response).toEqual('OK');
36+
expect(response).toStrictEqual('OK');
3637
});
3738
});

packages/iframe-execution-environment-service/src/IframeExecutionEnvironmentService.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect } from '@jest/globals';
1+
import { describe, expect, it } from '@jest/globals';
22
import fixJSDOMPostMessageEventSource from './testHelpers/fixJSDOMPostMessageEventSource';
33
import { IframeExecutionEnvironmentService } from './IframeExecutionEnvironmentService';
44

@@ -16,6 +16,7 @@ describe('Iframe Controller', () => {
1616
iframeExecutionEnvironmentService.terminateAllPlugins();
1717
expect(iframeExecutionEnvironmentService).toBeDefined();
1818
});
19+
1920
it('can create a plugin worker and start the plugin', async () => {
2021
const iframeExecutionEnvironmentService =
2122
new IframeExecutionEnvironmentService({
@@ -35,7 +36,7 @@ describe('Iframe Controller', () => {
3536
console.log('foo');
3637
`,
3738
});
38-
expect(response).toEqual('OK');
39+
expect(response).toStrictEqual('OK');
3940
removeListener();
4041
});
4142
});

packages/iframe-execution-environment-service/src/testHelpers/fixJSDOMPostMessageEventSource.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const fixJSDOMPostMessageEventSource = (
5353

5454
return result;
5555
};
56+
5657
const listener = (event: MessageEvent) => {
5758
if (event.source === null && !event.origin) {
5859
let source;
@@ -64,6 +65,7 @@ const fixJSDOMPostMessageEventSource = (
6465
source = iframeExecutionEnvironmentService._iframeWindow;
6566
origin = iframeExecutionEnvironmentService.iframeUrl.toString();
6667
}
68+
6769
if (event.data.target) {
6870
event.stopImmediatePropagation();
6971
const args = Object.assign({

yarn.lock

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,20 +2368,25 @@
23682368
web3 "^0.20.7"
23692369
web3-provider-engine "^16.0.1"
23702370

2371-
"@metamask/eslint-config-nodejs@^7.0.1":
2372-
version "7.0.1"
2373-
resolved "https://registry.yarnpkg.com/@metamask/eslint-config-nodejs/-/eslint-config-nodejs-7.0.1.tgz#7d3214b2c8eccfe2dbc9156b484456dce2dca91c"
2374-
integrity sha512-V9C1jYuLnhZOhW9dAKB7zMDmDKS1r907rYirUMcoU4mi8ggPTP6JqT87EAEX9bsA2ZpeTYXUXf5bkfLM+BTGyA==
2371+
"@metamask/eslint-config-jest@^8.0.0":
2372+
version "8.0.0"
2373+
resolved "https://registry.yarnpkg.com/@metamask/eslint-config-jest/-/eslint-config-jest-8.0.0.tgz#1433c2dffbd60239430ea789c71df11e94872a1c"
2374+
integrity sha512-m2/crRcaiRO8z6NC04+AudfjgIXvdrUy2oDjecjELa3nmgkJ+cVemCfioREpjaXoXW/soNImZXbgLrA98uQ6ig==
23752375

2376-
"@metamask/eslint-config-typescript@^7.0.1":
2377-
version "7.0.1"
2378-
resolved "https://registry.yarnpkg.com/@metamask/eslint-config-typescript/-/eslint-config-typescript-7.0.1.tgz#e013f7f0505741b9321cab21351136f651abbba6"
2379-
integrity sha512-nqWivz9XHjiHAE2Aqf/y+p8R3xDoN9ScX2i97vtTxNKjAqkzmUwAd8lEHEibRfPOYaRBQJ0x85wrof++PpLfZg==
2376+
"@metamask/eslint-config-nodejs@^8.0.0":
2377+
version "8.0.0"
2378+
resolved "https://registry.yarnpkg.com/@metamask/eslint-config-nodejs/-/eslint-config-nodejs-8.0.0.tgz#2181f2777a8e66825c2fd9882cb173b5a4d2b689"
2379+
integrity sha512-hN49rqgzhqo7WCJuCCD8P3e9ZhwNt6m9+XEKxnj3v1DKw8v6P6BW210LvOfzd6TfpZxN20qqnt5kxZOcN/ZPpA==
23802380

2381-
"@metamask/eslint-config@^7.0.1":
2382-
version "7.0.1"
2383-
resolved "https://registry.yarnpkg.com/@metamask/eslint-config/-/eslint-config-7.0.1.tgz#eeb87baa902965ca7931c26911d7027373706f34"
2384-
integrity sha512-dMZ+iyZrHdZK0D1uStTx8UN6Q6IK9YGbqPUwxgTj63M0mZOsuqs8qpGf+9Dn7uqS+8Oe9jNqejKxozjTiJvsEw==
2381+
"@metamask/eslint-config-typescript@^8.0.0":
2382+
version "8.0.0"
2383+
resolved "https://registry.yarnpkg.com/@metamask/eslint-config-typescript/-/eslint-config-typescript-8.0.0.tgz#72f5b0cd72ffdfb8c6bbad86437801267316f254"
2384+
integrity sha512-tCCgh5nMg/GTtQ1e84jF48PoelG9MWZxe3GrBZOdKw1JgTanmyapRND4TukbUFghruoXi/HmwlY2qHQSQTVlIg==
2385+
2386+
"@metamask/eslint-config@^8.0.0":
2387+
version "8.0.0"
2388+
resolved "https://registry.yarnpkg.com/@metamask/eslint-config/-/eslint-config-8.0.0.tgz#f4e3bcd6b37ec135b5a72902b0526cba2a6b5a4d"
2389+
integrity sha512-ZO9B3ohNhjomrufNAkxnDXV46Kut7NKzri7itDxUzHJncNtI1of7ewWh6fKPl/hr6Al6Gd7WgjPdJZGFpzKPQw==
23852390

23862391
"@metamask/inpage-provider@^8.0.3", "@metamask/inpage-provider@^8.0.4":
23872392
version "8.0.4"
@@ -2766,6 +2771,18 @@
27662771
eslint-scope "^5.1.1"
27672772
eslint-utils "^3.0.0"
27682773

2774+
"@typescript-eslint/experimental-utils@^4.0.1":
2775+
version "4.29.2"
2776+
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.29.2.tgz#5f67fb5c5757ef2cb3be64817468ba35c9d4e3b7"
2777+
integrity sha512-P6mn4pqObhftBBPAv4GQtEK7Yos1fz/MlpT7+YjH9fTxZcALbiiPKuSIfYP/j13CeOjfq8/fr9Thr2glM9ub7A==
2778+
dependencies:
2779+
"@types/json-schema" "^7.0.7"
2780+
"@typescript-eslint/scope-manager" "4.29.2"
2781+
"@typescript-eslint/types" "4.29.2"
2782+
"@typescript-eslint/typescript-estree" "4.29.2"
2783+
eslint-scope "^5.1.1"
2784+
eslint-utils "^3.0.0"
2785+
27692786
"@typescript-eslint/parser@^4.28.1":
27702787
version "4.28.1"
27712788
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.28.1.tgz#5181b81658414f47291452c15bf6cd44a32f85bd"
@@ -2784,11 +2801,24 @@
27842801
"@typescript-eslint/types" "4.28.1"
27852802
"@typescript-eslint/visitor-keys" "4.28.1"
27862803

2804+
"@typescript-eslint/scope-manager@4.29.2":
2805+
version "4.29.2"
2806+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.29.2.tgz#442b0f029d981fa402942715b1718ac7fcd5aa1b"
2807+
integrity sha512-mfHmvlQxmfkU8D55CkZO2sQOueTxLqGvzV+mG6S/6fIunDiD2ouwsAoiYCZYDDK73QCibYjIZmGhpvKwAB5BOA==
2808+
dependencies:
2809+
"@typescript-eslint/types" "4.29.2"
2810+
"@typescript-eslint/visitor-keys" "4.29.2"
2811+
27872812
"@typescript-eslint/types@4.28.1":
27882813
version "4.28.1"
27892814
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.28.1.tgz#d0f2ecbef3684634db357b9bbfc97b94b828f83f"
27902815
integrity sha512-4z+knEihcyX7blAGi7O3Fm3O6YRCP+r56NJFMNGsmtdw+NCdpG5SgNz427LS9nQkRVTswZLhz484hakQwB8RRg==
27912816

2817+
"@typescript-eslint/types@4.29.2":
2818+
version "4.29.2"
2819+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.29.2.tgz#fc0489c6b89773f99109fb0aa0aaddff21f52fcd"
2820+
integrity sha512-K6ApnEXId+WTGxqnda8z4LhNMa/pZmbTFkDxEBLQAbhLZL50DjeY0VIDCml/0Y3FlcbqXZrABqrcKxq+n0LwzQ==
2821+
27922822
"@typescript-eslint/typescript-estree@4.28.1":
27932823
version "4.28.1"
27942824
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.28.1.tgz#af882ae41740d1f268e38b4d0fad21e7e8d86a81"
@@ -2802,6 +2832,19 @@
28022832
semver "^7.3.5"
28032833
tsutils "^3.21.0"
28042834

2835+
"@typescript-eslint/typescript-estree@4.29.2":
2836+
version "4.29.2"
2837+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.2.tgz#a0ea8b98b274adbb2577100ba545ddf8bf7dc219"
2838+
integrity sha512-TJ0/hEnYxapYn9SGn3dCnETO0r+MjaxtlWZ2xU+EvytF0g4CqTpZL48SqSNn2hXsPolnewF30pdzR9a5Lj3DNg==
2839+
dependencies:
2840+
"@typescript-eslint/types" "4.29.2"
2841+
"@typescript-eslint/visitor-keys" "4.29.2"
2842+
debug "^4.3.1"
2843+
globby "^11.0.3"
2844+
is-glob "^4.0.1"
2845+
semver "^7.3.5"
2846+
tsutils "^3.21.0"
2847+
28052848
"@typescript-eslint/visitor-keys@4.28.1":
28062849
version "4.28.1"
28072850
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.28.1.tgz#162a515ee255f18a6068edc26df793cdc1ec9157"
@@ -2810,6 +2853,14 @@
28102853
"@typescript-eslint/types" "4.28.1"
28112854
eslint-visitor-keys "^2.0.0"
28122855

2856+
"@typescript-eslint/visitor-keys@4.29.2":
2857+
version "4.29.2"
2858+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.2.tgz#d2da7341f3519486f50655159f4e5ecdcb2cd1df"
2859+
integrity sha512-bDgJLQ86oWHJoZ1ai4TZdgXzJxsea3Ee9u9wsTAvjChdj2WLcVsgWYAPeY7RQMn16tKrlQaBnpKv7KBfs4EQag==
2860+
dependencies:
2861+
"@typescript-eslint/types" "4.29.2"
2862+
eslint-visitor-keys "^2.0.0"
2863+
28132864
"@yarnpkg/lockfile@^1.1.0":
28142865
version "1.1.0"
28152866
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
@@ -5069,6 +5120,13 @@ eslint-plugin-import@^2.23.4:
50695120
resolve "^1.20.0"
50705121
tsconfig-paths "^3.9.0"
50715122

5123+
eslint-plugin-jest@^24.4.0:
5124+
version "24.4.0"
5125+
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.4.0.tgz#fa4b614dbd46a98b652d830377971f097bda9262"
5126+
integrity sha512-8qnt/hgtZ94E9dA6viqfViKBfkJwFHXgJmTWlMGDgunw1XJEGqm3eiPjDsTanM3/u/3Az82nyQM9GX7PM/QGmg==
5127+
dependencies:
5128+
"@typescript-eslint/experimental-utils" "^4.0.1"
5129+
50725130
eslint-plugin-node@^11.1.0:
50735131
version "11.1.0"
50745132
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz#c95544416ee4ada26740a30474eefc5402dc671d"

0 commit comments

Comments
 (0)