diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ef35b0800df5..62117ad1727a 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -707,21 +707,22 @@ module.exports = { 'unicorn/prefer-array-some': 'off', 'unicorn/prefer-at': 'off', 'unicorn/prefer-date-now': 'off', - 'unicorn/prefer-export-from': 'off', 'unicorn/prefer-logical-operator-over-ternary': 'off', 'unicorn/prefer-math-trunc': 'off', 'unicorn/prefer-native-coercion-functions': 'off', - 'unicorn/prefer-node-protocol': 'off', 'unicorn/prefer-number-properties': 'off', 'unicorn/prefer-object-from-entries': 'off', - 'unicorn/prefer-optional-catch-binding': 'off', 'unicorn/prefer-prototype-methods': 'off', 'unicorn/prefer-regexp-test': 'off', - 'unicorn/prefer-set-has': 'off', 'unicorn/prefer-spread': 'off', 'unicorn/prefer-string-replace-all': 'off', 'unicorn/prevent-abbreviations': 'off', 'unicorn/text-encoding-identifier-case': 'off', + + // enabling this is blocked by https://github.com/microsoft/rushstack/issues/2780 + 'unicorn/prefer-export-from': 'off', + // enabling this is blocked by https://github.com/jestjs/jest/pull/14297 + 'unicorn/prefer-node-protocol': 'off', }, settings: { 'import/ignore': ['react-native'], diff --git a/packages/expect/src/__tests__/assertionCounts.test.ts b/packages/expect/src/__tests__/assertionCounts.test.ts index 7759a3241310..1607bd4245e6 100644 --- a/packages/expect/src/__tests__/assertionCounts.test.ts +++ b/packages/expect/src/__tests__/assertionCounts.test.ts @@ -71,7 +71,7 @@ describe('numPassingAsserts', () => { expect('a').toBe('a'); try { expect('a').toBe('b'); - } catch (error) {} + } catch {} const {numPassingAsserts} = jestExpect.getState(); expect(numPassingAsserts).toBe(1); }); diff --git a/packages/jest-config/src/setFromArgv.ts b/packages/jest-config/src/setFromArgv.ts index 0dc4a7f36034..539940018d44 100644 --- a/packages/jest-config/src/setFromArgv.ts +++ b/packages/jest-config/src/setFromArgv.ts @@ -8,7 +8,7 @@ import type {Config} from '@jest/types'; import {isJSONString} from './utils'; -const specialArgs = ['_', '$0', 'h', 'help', 'config']; +const specialArgs = new Set(['_', '$0', 'h', 'help', 'config']); export default function setFromArgv( options: Config.InitialOptions, @@ -16,7 +16,7 @@ export default function setFromArgv( ): Config.InitialOptions { const argvToOptions = Object.keys(argv).reduce( (options: Record, key) => { - if (argv[key] === undefined || specialArgs.includes(key)) { + if (argv[key] === undefined || specialArgs.has(key)) { return options; } diff --git a/packages/jest-core/src/SearchSource.ts b/packages/jest-core/src/SearchSource.ts index 4ce806983f39..b8c378c28604 100644 --- a/packages/jest-core/src/SearchSource.ts +++ b/packages/jest-core/src/SearchSource.ts @@ -191,7 +191,9 @@ export default class SearchSource { {skipNodeResolution: this._context.config.skipNodeResolution}, ); - const allPathsAbsolute = Array.from(allPaths).map(p => path.resolve(p)); + const allPathsAbsolute = new Set( + Array.from(allPaths).map(p => path.resolve(p)), + ); const collectCoverageFrom = new Set(); @@ -201,7 +203,7 @@ export default class SearchSource { } for (const p of testModule.dependencies) { - if (!allPathsAbsolute.includes(p)) { + if (!allPathsAbsolute.has(p)) { continue; } diff --git a/packages/jest-matcher-utils/src/Replaceable.ts b/packages/jest-matcher-utils/src/Replaceable.ts index 1044e1b9f28f..b14ca5420972 100644 --- a/packages/jest-matcher-utils/src/Replaceable.ts +++ b/packages/jest-matcher-utils/src/Replaceable.ts @@ -7,7 +7,7 @@ import {getType} from 'jest-get-type'; -const supportTypes = ['map', 'array', 'object']; +const supportTypes = new Set(['map', 'array', 'object']); type ReplaceableForEachCallBack = ( value: unknown, @@ -23,7 +23,7 @@ export default class Replaceable { constructor(object: any) { this.object = object; this.type = getType(object); - if (!supportTypes.includes(this.type)) { + if (!supportTypes.has(this.type)) { throw new Error(`Type ${this.type} is not support in Replaceable!`); } } @@ -31,7 +31,7 @@ export default class Replaceable { static isReplaceable(obj1: unknown, obj2: unknown): boolean { const obj1Type = getType(obj1); const obj2Type = getType(obj2); - return obj1Type === obj2Type && supportTypes.includes(obj1Type); + return obj1Type === obj2Type && supportTypes.has(obj1Type); } forEach(cb: ReplaceableForEachCallBack): void { diff --git a/packages/pretty-format/src/plugins/DOMCollection.ts b/packages/pretty-format/src/plugins/DOMCollection.ts index 29beb8b61f64..a6ccd9aec3a9 100644 --- a/packages/pretty-format/src/plugins/DOMCollection.ts +++ b/packages/pretty-format/src/plugins/DOMCollection.ts @@ -10,11 +10,11 @@ import type {Config, NewPlugin, Printer, Refs} from '../types'; const SPACE = ' '; -const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap']; +const OBJECT_NAMES = new Set(['DOMStringMap', 'NamedNodeMap']); const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/; const testName = (name: any) => - OBJECT_NAMES.includes(name) || ARRAY_REGEXP.test(name); + OBJECT_NAMES.has(name) || ARRAY_REGEXP.test(name); export const test: NewPlugin['test'] = (val: object) => val && @@ -40,7 +40,7 @@ export const serialize: NewPlugin['serialize'] = ( return ( (config.min ? '' : name + SPACE) + - (OBJECT_NAMES.includes(name) + (OBJECT_NAMES.has(name) ? `{${printObjectProperties( isNamedNodeMap(collection) ? Array.from(collection).reduce>(