You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Only enable Node lint rules for Node files (#3672)
In a previous commit, we mistakenly introduced a Node-specific function
for testing deep equality, and this ended up crashing the extension.
This would usually have been caught by our ESLint rules, as they
prohibit use of Node libraries by default. However, the ESLint
configuration for this repo imports rules from our
`@metamask/eslint-config-nodejs` package and applies them to all files,
marking everything as Node-compatible, thereby allowing such usage. This
is incorrect: these rules should only apply to test files and scripts.
This commit fix the ESLint configuration to match. Doing so revealed a
couple of categories of violations, which this commit also fixes:
- Some packages import and make use of EventEmitter from Node's `events`
module. We add a notice to the README for these packages which advises
consumers that these packages are designed to be used in a
Node-compatible environment.
- Some packages import and make use of Node's `assert` module to check
values at runtime. It isn't strictly necessary to use this module, and
so we replace its usage with simpler code.
- Some packages import and make use of Node's `inspect` utility
function. We don't strictly need this either, and we replace its usage
with simpler code as well.
Copy file name to clipboardExpand all lines: packages/message-manager/README.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,10 @@ or
10
10
11
11
`npm install @metamask/message-manager`
12
12
13
+
## Compatibility
14
+
15
+
This package relies implicitly upon the `EventEmitter` module. This module is available natively in Node.js, but when using this package for the browser, make sure to use a polyfill such as `events`.
16
+
13
17
## Contributing
14
18
15
19
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
`NetworkController state is invalid: \`selectedNetworkClientId\` '${state.selectedNetworkClientId}' does not refer to an RPC endpoint within a network configuration`,
794
792
);
795
793
}
796
794
}
@@ -1354,19 +1352,16 @@ export class NetworkController extends BaseController<
1354
1352
* removed in a future release
1355
1353
*/
1356
1354
asyncsetProviderType(type: InfuraNetworkType){
1357
-
assert.notStrictEqual(
1358
-
type,
1359
-
NetworkType.rpc,
1360
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
`Could not update network: Cannot update RPC endpoints in such a way that the selected network '${this.state.selectedNetworkClientId}' would be removed without a replacement. Choose a different RPC endpoint as the selected network via the \`replacementSelectedRpcEndpointIndex\` option.`,
1808
1801
);
@@ -1899,7 +1892,7 @@ export class NetworkController extends BaseController<
1899
1892
1900
1893
if(existingNetworkConfiguration===undefined){
1901
1894
thrownewError(
1902
-
`Cannot find network configuration for chain ${inspect(chainId)}`,
1895
+
`Cannot find network configuration for chain '${chainId}'`,
1903
1896
);
1904
1897
}
1905
1898
@@ -2031,9 +2024,7 @@ export class NetworkController extends BaseController<
`Could not add network for chain ${args.networkFields.chainId} as another network for that chain already exists ('${existingNetworkConfigurationViaChainId.name}')`,
`Cannot move network from chain ${existingNetworkConfiguration.chainId} to ${networkFields.chainId} as another network for that chain already exists ('${existingNetworkConfigurationViaChainId.name}')`,
2058
2049
);
@@ -2082,9 +2073,9 @@ export class NetworkController extends BaseController<
`Could not update network to point to same RPC endpoint as existing network for chain ${networkConfiguration.chainId} ('${networkConfiguration.name}')`
`Could not add network that points to same RPC endpoint as existing network for chain ${networkConfiguration.chainId} ('${networkConfiguration.name}')`,
`Could not update network to point to same RPC endpoint as existing network for chain ${networkConfiguration.chainId} ('${networkConfiguration.name}')`,
`Could not add network that points to same RPC endpoint as existing network for chain ${networkConfiguration.chainId} ('${networkConfiguration.name}')`,
2150
+
);
2151
+
}
2161
2152
}
2162
2153
}
2163
2154
}
@@ -2561,7 +2552,7 @@ export class NetworkController extends BaseController<
2561
2552
/* istanbul ignore if */
2562
2553
if(!possibleAutoManagedNetworkClient){
2563
2554
thrownewError(
2564
-
`No Infura network client found with ID ${inspect(networkClientId)}`,
2555
+
`No Infura network client found with ID '${networkClientId}'`,
2565
2556
);
2566
2557
}
2567
2558
@@ -2573,9 +2564,7 @@ export class NetworkController extends BaseController<
2573
2564
];
2574
2565
2575
2566
if(!possibleAutoManagedNetworkClient){
2576
-
thrownewError(
2577
-
`No network client found with ID ${inspect(networkClientId)}`,
2578
-
);
2567
+
thrownewError(`No network client found with ID '${networkClientId}'`);
Copy file name to clipboardExpand all lines: packages/signature-controller/README.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,10 @@ or
10
10
11
11
`npm install @metamask/signature-controller`
12
12
13
+
## Compatibility
14
+
15
+
This package relies implicitly upon the `EventEmitter` module. This module is available natively in Node.js, but when using this package for the browser, make sure to use a polyfill such as `events`.
16
+
13
17
## Contributing
14
18
15
19
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
Copy file name to clipboardExpand all lines: packages/transaction-controller/README.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,10 @@ or
10
10
11
11
`npm install @metamask/transaction-controller`
12
12
13
+
## Compatibility
14
+
15
+
This package relies implicitly upon the `EventEmitter` module. This module is available natively in Node.js, but when using this package for the browser, make sure to use a polyfill such as `events`.
16
+
13
17
## Contributing
14
18
15
19
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
Copy file name to clipboardExpand all lines: packages/user-operation-controller/README.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,10 @@ or
10
10
11
11
`npm install @metamask/user-operation-controller`
12
12
13
+
## Compatibility
14
+
15
+
This package relies implicitly upon the `EventEmitter` module. This module is available natively in Node.js, but when using this package for the browser, make sure to use a polyfill such as `events`.
16
+
13
17
## Contributing
14
18
15
19
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
0 commit comments