Skip to content

Commit

Permalink
tools: move webcrypto into no-restricted-properties
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zeeqko committed May 18, 2024
1 parent 9807ede commit d34b551
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 4 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ module.exports = {
property: 'notEqual',
message: 'Use `assert.notStrictEqual()` rather than `assert.notEqual()`.',
},
{
property: 'webcrypto',
message: 'Use `globalThis.crypto`.',
},
{
property: '__defineGetter__',
message: '__defineGetter__ is deprecated.',
Expand Down Expand Up @@ -220,12 +224,6 @@ module.exports = {
selector: "CallExpression[callee.name='isNaN']",
message: 'Use Number.isNaN() instead of the global isNaN() function.',
},
{
// 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`.',
},
],
'no-self-compare': 'error',
'no-template-curly-in-string': 'error',
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-global-webcrypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ if (!common.hasCrypto)
const assert = require('assert');
const crypto = require('crypto');

/* eslint-disable no-restricted-syntax */
/* eslint-disable no-restricted-properties, no-restricted-syntax */
// TODO(zi): Remove no-restricted-syntax once we add no-restricted-properties to test/.eslintrc.yaml
assert.strictEqual(globalThis.crypto, crypto.webcrypto);
assert.strictEqual(Crypto, crypto.webcrypto.constructor);
assert.strictEqual(SubtleCrypto, crypto.webcrypto.subtle.constructor);

0 comments on commit d34b551

Please sign in to comment.