chore: remove unused ignore comment (#16069)

This commit is contained in:
Simen Bekkhus
2026-04-29 15:47:15 +02:00
committed by GitHub
parent df21967423
commit 1307dda1a2
22 changed files with 779 additions and 707 deletions
+30
View File
@@ -274,6 +274,10 @@ const config = defineConfig(
'wrap-regex': 'off',
yoda: 'off',
// Needs Node 20 as minimum
'unicorn/no-array-reverse': 'off',
'unicorn/no-array-sort': 'off',
// doesn't work without ESModuleInterop
'unicorn/import-style': 'off',
// we're a CJS project
@@ -522,10 +526,13 @@ const config = defineConfig(
'unicorn/error-message': 'off',
'unicorn/no-anonymous-default-export': 'off',
'unicorn/no-await-expression-member': 'off',
'unicorn/no-immediate-mutation': 'off',
'unicorn/no-static-only-class': 'off',
'unicorn/prefer-class-fields': 'off',
'unicorn/prefer-number-properties': 'off',
'unicorn/prefer-string-raw': 'off',
'unicorn/prefer-global-this': 'off',
'unicorn/require-module-specifiers': 'off',
// The following disabled when upgrade ESLint to v9, some of them make sense to enable
'prefer-template': 'off',
'@typescript-eslint/no-require-imports': 'off',
@@ -835,6 +842,29 @@ const config = defineConfig(
'examples/react-native/index.js',
],
},
{
files: [
'packages/expect/src/__tests__/**/*',
'packages/expect-utils/src/__tests__/**/*',
'packages/jest-get-type/src/__tests__/**/*',
'packages/jest-matcher-utils/src/__tests__/**/*',
'packages/pretty-format/src/__tests__/**/*',
],
rules: {
'unicorn/no-immediate-mutation': 'off',
'unicorn/prefer-bigint-literals': 'off',
},
},
{
files: [
'e2e/coverage-provider-v8/*/uncovered.{ts,js}',
'e2e/babel-plugin-jest-hoist/__test_modules__/**/*',
],
rules: {
'unicorn/prefer-class-fields': 'off',
'unicorn/require-module-specifiers': 'off',
},
},
);
export default config;
+1 -5
View File
@@ -1,9 +1,5 @@
export default class Memory {
current: number;
constructor() {
this.current = 0;
}
current = 0;
add(entry: number) {
this.current += entry;
+8 -8
View File
@@ -12,7 +12,7 @@
"@crowdin/cli": "^4.7.0",
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
"@eslint/js": "^9.28.0",
"@eslint/markdown": "^6.4.0",
"@eslint/markdown": "^7.0.0",
"@jest/globals": "workspace:*",
"@jest/test-utils": "workspace:*",
"@lerna-lite/cli": "^4.3.0",
@@ -37,25 +37,25 @@
"eslint-config-prettier": "^10.1.5",
"eslint-import-resolver-typescript": "^4.4.2",
"eslint-plugin-import-x": "^4.15.0",
"eslint-plugin-jest": "^28.12.0",
"eslint-plugin-jsdoc": "^50.7.1",
"eslint-plugin-jest": "^29.0.0",
"eslint-plugin-jsdoc": "^61.0.0",
"eslint-plugin-prettier": "^5.4.1",
"eslint-plugin-promise": "^7.2.1",
"eslint-plugin-unicorn": "^59.0.1",
"eslint-plugin-unicorn": "^64.0.0",
"execa": "^5.1.1",
"find-process": "^1.4.10",
"glob": "^10.5.0",
"globals": "^16.2.0",
"globals": "^17.0.0",
"graceful-fs": "^4.2.11",
"isbinaryfile": "^5.0.4",
"isbinaryfile": "^6.0.0",
"istanbul-lib-coverage": "^3.0.0",
"istanbul-lib-report": "^3.0.0",
"istanbul-reports": "^3.1.3",
"jest": "workspace:*",
"jest-changed-files": "workspace:*",
"jest-junit": "^16.0.0",
"jest-junit": "^17.0.0",
"jest-mock": "workspace:*",
"jest-serializer-ansi-escapes": "^3.0.0",
"jest-serializer-ansi-escapes": "^4.0.0",
"jest-silent-reporter": "^0.6.0",
"jest-snapshot": "workspace:*",
"jest-util": "workspace:*",
+4 -2
View File
@@ -55,8 +55,10 @@ function addIstanbulInstrumentation(
transformOptions: JestTransformOptions,
): BabelTransformOptions {
if (transformOptions.instrument) {
const copiedBabelOptions: BabelTransformOptions = {...babelOptions};
copiedBabelOptions.auxiliaryCommentBefore = ' istanbul ignore next ';
const copiedBabelOptions: BabelTransformOptions = {
...babelOptions,
auxiliaryCommentBefore: ' istanbul ignore next ',
};
// Copied from jest-runtime transform.js
copiedBabelOptions.plugins = [
...(copiedBabelOptions.plugins ?? []),
@@ -75,9 +75,7 @@ const generateConfigFile = (
if (overrideKeys.includes(opt)) {
properties.push(stringifyOption(opt, overrides));
} else {
properties.push(
stringifyOption(opt, defaults as Config.InitialOptions, '// '),
);
properties.push(stringifyOption(opt, defaults, '// '));
}
}
+1 -4
View File
@@ -93,10 +93,7 @@ export async function runCreate(rootDir = process.cwd()): Promise<void> {
}
// Add test script installation only if needed
if (
!projectPackageJson.scripts ||
projectPackageJson.scripts.test !== 'jest'
) {
if (projectPackageJson.scripts?.test !== 'jest') {
questions.unshift(testScriptQuestion);
}
+89 -97
View File
@@ -594,49 +594,46 @@ export default async function normalize(
switch (key) {
case 'setupFiles':
case 'setupFilesAfterEnv':
case 'snapshotSerializers':
{
const option = oldOptions[key];
value =
option &&
option.map(filePath =>
resolve(newOptions.resolver, {
filePath,
key,
rootDir: options.rootDir,
}),
);
}
case 'snapshotSerializers': {
const option = oldOptions[key];
value =
option &&
option.map(filePath =>
resolve(newOptions.resolver, {
filePath,
key,
rootDir: options.rootDir,
}),
);
break;
}
case 'modulePaths':
case 'roots':
{
const option = oldOptions[key];
value =
option &&
option.map(filePath =>
path.resolve(
options.rootDir,
replaceRootDirInPath(options.rootDir, filePath),
),
);
}
case 'roots': {
const option = oldOptions[key];
value =
option &&
option.map(filePath =>
path.resolve(
options.rootDir,
replaceRootDirInPath(options.rootDir, filePath),
),
);
break;
}
case 'collectCoverageFrom':
value = normalizeCollectCoverageFrom(oldOptions, key);
break;
case 'cacheDirectory':
case 'coverageDirectory':
{
const option = oldOptions[key];
value =
option &&
path.resolve(
options.rootDir,
replaceRootDirInPath(options.rootDir, option),
);
}
case 'coverageDirectory': {
const option = oldOptions[key];
value =
option &&
path.resolve(
options.rootDir,
replaceRootDirInPath(options.rootDir, option),
);
break;
}
case 'dependencyExtractor':
case 'globalSetup':
case 'globalTeardown':
@@ -644,48 +641,45 @@ export default async function normalize(
case 'snapshotResolver':
case 'testResultsProcessor':
case 'testRunner':
case 'filter':
{
const option = oldOptions[key];
value =
option &&
resolve(newOptions.resolver, {
filePath: option,
key,
rootDir: options.rootDir,
});
}
case 'filter': {
const option = oldOptions[key];
value =
option &&
resolve(newOptions.resolver, {
filePath: option,
key,
rootDir: options.rootDir,
});
break;
case 'runner':
{
const option = oldOptions[key];
value =
option &&
resolveRunner(newOptions.resolver, {
filePath: option,
requireResolveFunction: requireResolve,
rootDir: options.rootDir,
});
}
}
case 'runner': {
const option = oldOptions[key];
value =
option &&
resolveRunner(newOptions.resolver, {
filePath: option,
requireResolveFunction: requireResolve,
rootDir: options.rootDir,
});
break;
case 'prettierPath':
{
// We only want this to throw if "prettierPath" is explicitly passed
// from config or CLI, and the requested path isn't found. Otherwise we
// set it to null and throw an error lazily when it is used.
}
case 'prettierPath': {
// We only want this to throw if "prettierPath" is explicitly passed
// from config or CLI, and the requested path isn't found. Otherwise we
// set it to null and throw an error lazily when it is used.
const option = oldOptions[key];
const option = oldOptions[key];
value =
option &&
resolve(newOptions.resolver, {
filePath: option,
key,
optional: option === DEFAULT_CONFIG[key],
rootDir: options.rootDir,
});
}
value =
option &&
resolve(newOptions.resolver, {
filePath: option,
key,
optional: option === DEFAULT_CONFIG[key],
rootDir: options.rootDir,
});
break;
}
case 'moduleNameMapper':
const moduleNameMapper = oldOptions[key];
value =
@@ -769,35 +763,33 @@ export default async function normalize(
);
break;
case 'moduleDirectories':
case 'testMatch':
{
const option = oldOptions[key];
const rawValue =
Array.isArray(option) || option == null ? option : [option];
const replacedRootDirTags = _replaceRootDirTags(
escapeGlobCharacters(options.rootDir),
rawValue,
);
case 'testMatch': {
const option = oldOptions[key];
const rawValue =
Array.isArray(option) || option == null ? option : [option];
const replacedRootDirTags = _replaceRootDirTags(
escapeGlobCharacters(options.rootDir),
rawValue,
);
if (replacedRootDirTags) {
value = Array.isArray(replacedRootDirTags)
? replacedRootDirTags.map(replacePathSepForGlob)
: replacePathSepForGlob(replacedRootDirTags);
} else {
value = replacedRootDirTags;
}
if (replacedRootDirTags) {
value = Array.isArray(replacedRootDirTags)
? replacedRootDirTags.map(replacePathSepForGlob)
: replacePathSepForGlob(replacedRootDirTags);
} else {
value = replacedRootDirTags;
}
break;
case 'testRegex':
{
const option = oldOptions[key];
value = option
? (Array.isArray(option) ? option : [option]).map(
replacePathSepForRegex,
)
: [];
}
}
case 'testRegex': {
const option = oldOptions[key];
value = option
? (Array.isArray(option) ? option : [option]).map(
replacePathSepForRegex,
)
: [];
break;
}
case 'moduleFileExtensions': {
value = oldOptions[key];
@@ -157,7 +157,7 @@ export default abstract class BaseJSDOMEnvironment implements JestEnvironment<nu
this.fakeTimers = new LegacyFakeTimers({
config: projectConfig,
global: global as unknown as typeof globalThis,
global,
moduleMocker: this.moduleMocker,
timerConfig: {
idToRef: (id: number) => id,
@@ -167,7 +167,7 @@ export default abstract class BaseJSDOMEnvironment implements JestEnvironment<nu
this.fakeTimersModern = new ModernFakeTimers({
config: projectConfig,
global: global as unknown as typeof globalThis,
global,
});
}
@@ -118,7 +118,6 @@ export default class FakeTimers {
runAllTicks(): void {
if (this._checkFakeTimers()) {
// @ts-expect-error needs an upstream fix: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/73943
this._clock.runMicrotasks();
}
}
@@ -32,7 +32,7 @@ describe('dependencyExtractor', () => {
' */',
].join('\r\n');
expect(extractor.extract(code)).toEqual(new Set([]));
expect(extractor.extract(code)).toEqual(new Set());
});
it('should not extract dependencies inside comments (unicode line endings)', () => {
@@ -44,7 +44,7 @@ describe('dependencyExtractor', () => {
' */',
].join('');
expect(extractor.extract(code)).toEqual(new Set([]));
expect(extractor.extract(code)).toEqual(new Set());
});
it('should extract dependencies from `import` statements', () => {
@@ -93,7 +93,7 @@ describe('dependencyExtractor', () => {
import typeof {foo} from 'inv1';
import type {foo} from 'inv2';
`;
expect(extractor.extract(code)).toEqual(new Set([]));
expect(extractor.extract(code)).toEqual(new Set());
});
it('should extract dependencies from `export` statements', () => {
@@ -148,7 +148,7 @@ describe('dependencyExtractor', () => {
export typeof {foo} from 'inv1';
export type {foo} from 'inv2';
`;
expect(extractor.extract(code)).toEqual(new Set([]));
expect(extractor.extract(code)).toEqual(new Set());
});
it('should extract dependencies from dynamic `import` calls', () => {
+3 -6
View File
@@ -68,14 +68,11 @@ export default class Suite {
children: Array<Suite | Spec>;
result: SuiteResult;
sharedContext?: object;
markedPending: boolean;
markedTodo: boolean;
isFocused: boolean;
markedPending = false;
markedTodo = false;
isFocused = false;
constructor(attrs: Attributes) {
this.markedPending = false;
this.markedTodo = false;
this.isFocused = false;
this.id = attrs.id;
this.parentSuite = attrs.parentSuite;
this.description = convertDescriptorToString(attrs.description);
@@ -176,6 +176,7 @@ test('should only copy the properties mapped to be serializable', () => {
});
test('json from Response', async () => {
// eslint-disable-next-line unicorn/prefer-response-static-json
const response = () => new Response(JSON.stringify({}));
const text = JSON.parse(await response().text());
+1 -2
View File
@@ -71,7 +71,7 @@ type Cache = {
* from the terminal.
*/
export default class Status {
private _cache: Cache | null;
private _cache: Cache | null = null;
private _callback?: () => void;
private readonly _currentTests: CurrentTestList;
private _currentTestCases: Array<{
@@ -86,7 +86,6 @@ export default class Status {
private _showStatus: boolean;
constructor(private readonly _globalConfig: Config.GlobalConfig) {
this._cache = null;
this._currentTests = new CurrentTestList();
this._currentTestCases = [];
this._done = false;
@@ -31,21 +31,22 @@ beforeEach(() => {
libSourceMaps = require('istanbul-lib-source-maps');
istanbulReports = require('istanbul-reports');
const fileTree = {};
fileTree[`${process.cwd()}/path-test-files`] = {
'000pc_coverage_file.js': '',
'050pc_coverage_file.js': '',
'100pc_coverage_file.js': '',
'full_path_file.js': '',
'glob-path': {
'file1.js': '',
'file2.js': '',
const fileTree = {
[`${process.cwd()}/path-test-files`]: {
'000pc_coverage_file.js': '',
'050pc_coverage_file.js': '',
'100pc_coverage_file.js': '',
'full_path_file.js': '',
'glob-path': {
'file1.js': '',
'file2.js': '',
},
'non_covered_file.js': '',
'relative_path_file.js': '',
},
[`${process.cwd()}/path-test`]: {
'100pc_coverage_file.js': '',
},
'non_covered_file.js': '',
'relative_path_file.js': '',
};
fileTree[`${process.cwd()}/path-test`] = {
'100pc_coverage_file.js': '',
};
mock(fileTree);
});
@@ -27,8 +27,7 @@ export default function getSnapshotSummary(
globalConfig: Config.GlobalConfig,
updateCommand: string,
): Array<string> {
const summary = [];
summary.push(SNAPSHOT_SUMMARY('Snapshot Summary'));
const summary = [SNAPSHOT_SUMMARY('Snapshot Summary')];
if (snapshots.added) {
summary.push(
`${SNAPSHOT_ADDED(
-2
View File
@@ -1859,7 +1859,6 @@ export default class Runtime {
return this._moduleImplementation;
}
// eslint-disable-next-line unicorn/consistent-function-scoping
const createRequire = (modulePath: string | URL) => {
const filename =
typeof modulePath === 'string'
@@ -2261,7 +2260,6 @@ export default class Runtime {
this.restoreAllMocks();
return jestObject;
};
// eslint-disable-next-line unicorn/consistent-function-scoping
const _getFakeTimers = () => {
if (
this.isTornDown ||
+1 -2
View File
@@ -89,8 +89,7 @@ const dedentMarkup = (input: Array<string>, output: Array<string>): boolean => {
}
let isText = false;
const stack: Array<number> = [];
stack.push(getIndentationLength(line));
const stack = [getIndentationLength(line)];
while (stack.length > 0 && output.length < input.length) {
line = input[output.length];
@@ -53,6 +53,7 @@ it('handles cyclic dependencies', () => {
const cyclic: Cyclic = {a: 42};
// eslint-disable-next-line unicorn/no-immediate-mutation
cyclic.subcycle = {};
cyclic.subcycle.baz = cyclic;
cyclic.bar = cyclic;
+4 -7
View File
@@ -9,20 +9,17 @@ import {KEYS} from '../constants';
import type {ScrollOptions} from '../types';
export default class Prompt {
private _entering: boolean;
private _value: string;
// Copied from `enter` to satisfy TS
private _entering = true;
private _value = '';
private _onChange: () => void;
private _onSuccess: (value: string) => void;
private _onCancel: (value: string) => void;
private _offset: number;
private _promptLength: number;
private _selection: string | null;
private _selection: string | null = null;
constructor() {
// Copied from `enter` to satisfy TS
this._entering = true;
this._value = '';
this._selection = null;
this._offset = -1;
this._promptLength = 0;
@@ -165,17 +165,17 @@ test('a number', 123);
test('a date', new Date(10e11));
test('an empty object', {});
test('an object with properties', {prop1: 'value1', prop2: 'value2'});
const objectWithPropsAndSymbols = {prop: 'value1'};
objectWithPropsAndSymbols[Symbol('symbol1')] = 'value2';
objectWithPropsAndSymbols[Symbol('symbol2')] = 'value3';
const objectWithPropsAndSymbols = {
prop: 'value1',
[Symbol('symbol1')]: 'value2',
[Symbol('symbol2')]: 'value3',
};
test('an object with properties and symbols', objectWithPropsAndSymbols);
test('an object with sorted properties', {a: 2, b: 1});
test('regular expressions from constructors', new RegExp('regexp'));
test('regular expressions from literals', /regexp/gi);
test('an empty set', new Set());
const setWithValues = new Set();
setWithValues.add('value1');
setWithValues.add('value2');
const setWithValues = new Set(['value1', 'value2']);
test('a set with values', setWithValues);
test('a string', 'string');
test('a symbol', Symbol('symbol'));
+3 -4
View File
@@ -198,8 +198,8 @@ function printBasicValue(
}
/**
* Handles more complex objects ( such as objects with circular references.
* maps and sets etc )
* Handles more complex objects (such as objects with circular references,
* maps and sets etc.)
*/
function printComplexValue(
val: any,
@@ -212,8 +212,7 @@ function printComplexValue(
if (refs.includes(val)) {
return '[Circular]';
}
refs = [...refs];
refs.push(val);
refs = [...refs, val];
const hitMaxDepth = ++depth > config.maxDepth;
const min = config.min;
+603 -536
View File
File diff suppressed because it is too large Load Diff