tools: move webcrypto into no-restricted-properties

Since eslint fixed https://github.com/eslint/eslint/issues/16412 and we
are on eslint v8.57.0 so that we can take advantage of
no-restricted-properties rule for webcrypto.

PR-URL: https://github.com/nodejs/node/pull/53023
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Zihong Qu 2024-05-31 06:25:02 +09:30 committed by GitHub
parent f88386561c
commit 74dff83fad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 5 additions and 15 deletions

View File

@ -9,7 +9,6 @@ import toolsConfig from './tools/eslint.config_partial.mjs';
import {
noRestrictedSyntaxCommonAll,
noRestrictedSyntaxCommonLib,
noRestrictedSyntaxCommonTest,
requireEslintTool,
resolveEslintTool,
} from './tools/eslint.config_utils.mjs';
@ -191,12 +190,15 @@ export default [
property: '__defineSetter__',
message: '__defineSetter__ is deprecated.',
},
{
property: 'webcrypto',
message: 'Use `globalThis.crypto`.',
},
],
'no-restricted-syntax': [
'error',
...noRestrictedSyntaxCommonAll,
...noRestrictedSyntaxCommonLib,
...noRestrictedSyntaxCommonTest,
],
'no-self-compare': 'error',
'no-template-curly-in-string': 'error',

View File

@ -2,7 +2,6 @@
import {
noRestrictedSyntaxCommonAll,
noRestrictedSyntaxCommonTest,
requireEslintTool,
} from '../tools/eslint.config_utils.mjs';
@ -26,7 +25,6 @@ export default [
'no-restricted-syntax': [
'error',
...noRestrictedSyntaxCommonAll,
...noRestrictedSyntaxCommonTest,
{
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'])",
message: 'Use strictEqual instead of deepStrictEqual for literals or undefined.',

View File

@ -7,7 +7,6 @@ if (!common.hasCrypto)
const assert = require('assert');
/* eslint-disable no-restricted-syntax */
const webcrypto = require('internal/crypto/webcrypto');
assert.strictEqual(Crypto, webcrypto.Crypto);
assert.strictEqual(CryptoKey, webcrypto.CryptoKey);

View File

@ -7,7 +7,7 @@ if (!common.hasCrypto)
const assert = require('assert');
const crypto = require('crypto');
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-restricted-properties */
assert.strictEqual(globalThis.crypto, crypto.webcrypto);
assert.strictEqual(Crypto, crypto.webcrypto.constructor);
assert.strictEqual(SubtleCrypto, crypto.webcrypto.subtle.constructor);

View File

@ -24,12 +24,3 @@ export const noRestrictedSyntaxCommonLib = [
message: '`setTimeout()` must be invoked with at least two arguments.',
},
];
export const noRestrictedSyntaxCommonTest = [
{
// TODO(@panva): move this to no-restricted-properties
// when https://github.com/eslint/eslint/issues/16412 is fixed.
selector: "Identifier[name='webcrypto']",
message: 'Use `globalThis.crypto`.',
},
];