Skip to content

Commit 86e80dc

Browse files
zeeqkotargos
authored andcommitted
tools: move webcrypto into no-restricted-properties
Since eslint fixed eslint/eslint#16412 and we are on eslint v8.57.0 so that we can take advantage of no-restricted-properties rule for webcrypto. PR-URL: #53023 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent b5c30e2 commit 86e80dc

5 files changed

+5
-15
lines changed

eslint.config.mjs

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import toolsConfig from './tools/eslint.config_partial.mjs';
99
import {
1010
noRestrictedSyntaxCommonAll,
1111
noRestrictedSyntaxCommonLib,
12-
noRestrictedSyntaxCommonTest,
1312
requireEslintTool,
1413
resolveEslintTool,
1514
} from './tools/eslint.config_utils.mjs';
@@ -191,12 +190,15 @@ export default [
191190
property: '__defineSetter__',
192191
message: '__defineSetter__ is deprecated.',
193192
},
193+
{
194+
property: 'webcrypto',
195+
message: 'Use `globalThis.crypto`.',
196+
},
194197
],
195198
'no-restricted-syntax': [
196199
'error',
197200
...noRestrictedSyntaxCommonAll,
198201
...noRestrictedSyntaxCommonLib,
199-
...noRestrictedSyntaxCommonTest,
200202
],
201203
'no-self-compare': 'error',
202204
'no-template-curly-in-string': 'error',

test/eslint.config_partial.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import {
44
noRestrictedSyntaxCommonAll,
5-
noRestrictedSyntaxCommonTest,
65
requireEslintTool,
76
} from '../tools/eslint.config_utils.mjs';
87

@@ -26,7 +25,6 @@ export default [
2625
'no-restricted-syntax': [
2726
'error',
2827
...noRestrictedSyntaxCommonAll,
29-
...noRestrictedSyntaxCommonTest,
3028
{
3129
selector: "CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual']):matches([arguments.1.type='Literal']:not([arguments.1.regex]), [arguments.1.type='Identifier'][arguments.1.name='undefined'])",
3230
message: 'Use strictEqual instead of deepStrictEqual for literals or undefined.',

test/parallel/test-global-webcrypto-classes.js

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ if (!common.hasCrypto)
77

88
const assert = require('assert');
99

10-
/* eslint-disable no-restricted-syntax */
1110
const webcrypto = require('internal/crypto/webcrypto');
1211
assert.strictEqual(Crypto, webcrypto.Crypto);
1312
assert.strictEqual(CryptoKey, webcrypto.CryptoKey);

test/parallel/test-global-webcrypto.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (!common.hasCrypto)
77
const assert = require('assert');
88
const crypto = require('crypto');
99

10-
/* eslint-disable no-restricted-syntax */
10+
/* eslint-disable no-restricted-properties */
1111
assert.strictEqual(globalThis.crypto, crypto.webcrypto);
1212
assert.strictEqual(Crypto, crypto.webcrypto.constructor);
1313
assert.strictEqual(SubtleCrypto, crypto.webcrypto.subtle.constructor);

tools/eslint.config_utils.mjs

-9
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,3 @@ export const noRestrictedSyntaxCommonLib = [
2424
message: '`setTimeout()` must be invoked with at least two arguments.',
2525
},
2626
];
27-
28-
export const noRestrictedSyntaxCommonTest = [
29-
{
30-
// TODO(@panva): move this to no-restricted-properties
31-
// when https://github.com/eslint/eslint/issues/16412 is fixed.
32-
selector: "Identifier[name='webcrypto']",
33-
message: 'Use `globalThis.crypto`.',
34-
},
35-
];

0 commit comments

Comments
 (0)