diff --git a/package.json b/package.json index 1cf2387cfa..7c91a2d583 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "fallow": "fallow", "fallow:dead-code": "fallow dead-code --production", "fallow:dupes": "fallow dupes", - "fallow:health": "fallow health", + "fallow:health": "fallow health --coverage test/vitest-coverage", "fallow:fix:preview": "fallow fix --dry-run --production", "fallow:fix": "fallow fix --production", "lint": "oxlint .", diff --git a/packages/common/src/extensions/slickCellExcelCopyManager.ts b/packages/common/src/extensions/slickCellExcelCopyManager.ts index 13e8fbf3c4..2a022c52a2 100644 --- a/packages/common/src/extensions/slickCellExcelCopyManager.ts +++ b/packages/common/src/extensions/slickCellExcelCopyManager.ts @@ -1,6 +1,8 @@ import { BindingEventService } from '@slickgrid-universal/binding'; import { isPrimitiveOrHTML, stripTags } from '@slickgrid-universal/utils'; -import { SlickEventHandler, SlickGlobalEditorLock, type SlickDataView, type SlickGrid } from '../core/index.js'; +import { SlickEventHandler, SlickGlobalEditorLock } from '../core/slickCore.js'; +import type { SlickDataView } from '../core/slickDataview.js'; +import type { SlickGrid } from '../core/slickGrid.js'; import type { Column, EditCommand, @@ -10,7 +12,8 @@ import type { FormatterResultWithText, GridOption, } from '../interfaces/index.js'; -import { SlickCellExternalCopyManager, SlickHybridSelectionModel } from './index.js'; +import { SlickCellExternalCopyManager } from './slickCellExternalCopyManager.js'; +import { SlickHybridSelectionModel } from './slickHybridSelectionModel.js'; /* This manager enables users to copy/paste data from/to an external Spreadsheet application diff --git a/packages/common/src/extensions/slickGroupItemMetadataProvider.ts b/packages/common/src/extensions/slickGroupItemMetadataProvider.ts index fe69718121..fc1367f159 100644 --- a/packages/common/src/extensions/slickGroupItemMetadataProvider.ts +++ b/packages/common/src/extensions/slickGroupItemMetadataProvider.ts @@ -1,12 +1,8 @@ import { createDomElement, extend, isHtml } from '@slickgrid-universal/utils'; -import { - applyHtmlToElement, - SlickEventHandler, - SlickGroup, - type SlickDataView, - type SlickEventData, - type SlickGrid, -} from '../core/index.js'; +import { SlickEventHandler, SlickGroup, type SlickEventData } from '../core/slickCore.js'; +import type { SlickDataView } from '../core/slickDataview.js'; +import type { SlickGrid } from '../core/slickGrid.js'; +import { applyHtmlToElement } from '../core/utils.js'; import type { Column, GridOption, diff --git a/packages/common/src/filter-conditions/dateFilterCondition.ts b/packages/common/src/filter-conditions/dateFilterCondition.ts index 0306b1e3d5..afe30f20a4 100644 --- a/packages/common/src/filter-conditions/dateFilterCondition.ts +++ b/packages/common/src/filter-conditions/dateFilterCondition.ts @@ -1,7 +1,7 @@ import { dayStart } from '@formkit/tempo'; import { type FieldType, type SearchTerm } from '../enums/index.js'; import type { FilterConditionOption } from '../interfaces/index.js'; -import { mapTempoDateFormatWithFieldType, tryParseDate } from '../services/index.js'; +import { mapTempoDateFormatWithFieldType, tryParseDate } from '../services/dateUtils.js'; import { testFilterCondition } from './filterUtilities.js'; /** diff --git a/packages/common/src/sortComparers/__tests__/sortUtilities.spec.ts b/packages/common/src/sortComparers/__tests__/sortUtilities.spec.ts index 4b9ed8b3d4..25b483b7d7 100644 --- a/packages/common/src/sortComparers/__tests__/sortUtilities.spec.ts +++ b/packages/common/src/sortComparers/__tests__/sortUtilities.spec.ts @@ -1,43 +1,46 @@ import { describe, expect, it, vi } from 'vitest'; import { SortDirectionNumber } from '../../enums/index.js'; import type { Column } from '../../interfaces/index.js'; -import { SortComparers } from '../sortComparers.index.js'; +import * as booleanModule from '../booleanSortComparer.js'; +import * as numericModule from '../numericSortComparer.js'; +import * as objectStringModule from '../objectStringSortComparer.js'; import { sortByFieldType } from '../sortUtilities.js'; +import * as stringModule from '../stringSortComparer.js'; describe('sortUtilities', () => { - it('should call the SortComparers.boolean when FieldType is boolean', () => { - const spy = vi.spyOn(SortComparers, 'boolean'); + it('should call the booleanSortComparer when FieldType is boolean', () => { + const spy = vi.spyOn(booleanModule, 'booleanSortComparer'); sortByFieldType('boolean', 0, 4, SortDirectionNumber.asc, { id: 'field1', field: 'field1' }); expect(spy).toHaveBeenCalledWith(0, 4, SortDirectionNumber.asc, { id: 'field1', field: 'field1' }, undefined); }); - it('should call the SortComparers.numeric when FieldType is number', () => { - const spy = vi.spyOn(SortComparers, 'numeric'); + it('should call the numericSortComparer when FieldType is number', () => { + const spy = vi.spyOn(numericModule, 'numericSortComparer'); sortByFieldType('number', 0, 4, SortDirectionNumber.asc, { id: 'field1', field: 'field1' }); expect(spy).toHaveBeenCalledWith(0, 4, SortDirectionNumber.asc, { id: 'field1', field: 'field1' }, undefined); }); - it('should call the SortComparers.numeric when FieldType is integer', () => { - const spy = vi.spyOn(SortComparers, 'numeric'); + it('should call the numericSortComparer when FieldType is integer', () => { + const spy = vi.spyOn(numericModule, 'numericSortComparer'); sortByFieldType('integer', 0, 4, SortDirectionNumber.asc, { id: 'field1', field: 'field1' }); expect(spy).toHaveBeenCalledWith(0, 4, SortDirectionNumber.asc, { id: 'field1', field: 'field1' }, undefined); }); - it('should call the SortComparers.numeric when FieldType is float', () => { - const spy = vi.spyOn(SortComparers, 'numeric'); + it('should call the numericSortComparer when FieldType is float', () => { + const spy = vi.spyOn(numericModule, 'numericSortComparer'); sortByFieldType('float', 0, 4, SortDirectionNumber.asc, { id: 'field1', field: 'field1' }); expect(spy).toHaveBeenCalledWith(0, 4, SortDirectionNumber.asc, { id: 'field1', field: 'field1' }, undefined); }); - it('should call the SortComparers.string when FieldType is a string (which is also the default)', () => { + it('should call the stringSortComparer when FieldType is a string (which is also the default)', () => { const string1 = 'John'; const string2 = 'Jane'; - const spy = vi.spyOn(SortComparers, 'string'); + const spy = vi.spyOn(stringModule, 'stringSortComparer'); sortByFieldType('string', string1, string2, SortDirectionNumber.asc, { id: 'field1', field: 'field1' }); expect(spy).toHaveBeenCalledWith(string1, string2, SortDirectionNumber.asc, { id: 'field1', field: 'field1' }, undefined); }); - it('should call the SortComparers.date when FieldType is any date types', () => { + it('should call the date comparer when FieldType is any date types', () => { const result1 = sortByFieldType('dateIso', '2020-01-01', '2020-02-01', SortDirectionNumber.asc, { id: 'field1', field: 'field1' }); expect(result1).toBeLessThan(0); @@ -45,11 +48,11 @@ describe('sortUtilities', () => { expect(result2).toBeGreaterThan(0); }); - it('should call the SortComparers.objectString when FieldType is objectString', () => { + it('should call the objectStringSortComparer when FieldType is objectString', () => { const object1 = { firstName: 'John', lastName: 'Z' }; const object2 = { firstName: 'Jane', lastName: 'Doe' }; const mockColumn = { id: 'field1', field: 'field1', dataKey: 'firstName' } as Column; - const spy = vi.spyOn(SortComparers, 'objectString'); + const spy = vi.spyOn(objectStringModule, 'objectStringSortComparer'); sortByFieldType('object', object1, object2, SortDirectionNumber.asc, mockColumn); expect(spy).toHaveBeenCalledWith(object1, object2, SortDirectionNumber.asc, mockColumn, undefined); }); diff --git a/packages/common/src/sortComparers/sortUtilities.ts b/packages/common/src/sortComparers/sortUtilities.ts index 5d6eedcfda..cf05844366 100644 --- a/packages/common/src/sortComparers/sortUtilities.ts +++ b/packages/common/src/sortComparers/sortUtilities.ts @@ -1,8 +1,11 @@ import { type FieldType, type SortDirectionNumber } from '../enums/index.js'; import type { Column, GridOption } from '../interfaces/index.js'; import { isColumnDateType } from '../services/utilities.js'; +import { booleanSortComparer } from './booleanSortComparer.js'; import { getAssociatedDateSortComparer } from './dateUtilities.js'; -import { SortComparers } from './index.js'; +import { numericSortComparer } from './numericSortComparer.js'; +import { objectStringSortComparer } from './objectStringSortComparer.js'; +import { stringSortComparer } from './stringSortComparer.js'; export function sortByFieldType( fieldType: FieldType, @@ -20,22 +23,22 @@ export function sortByFieldType( } else { switch (fieldType) { case 'boolean': - sortResult = SortComparers.boolean(value1, value2, sortDirection, sortColumn, gridOptions); + sortResult = booleanSortComparer(value1, value2, sortDirection, sortColumn, gridOptions); break; case 'float': case 'integer': case 'number': - sortResult = SortComparers.numeric(value1, value2, sortDirection, sortColumn, gridOptions); + sortResult = numericSortComparer(value1, value2, sortDirection, sortColumn, gridOptions); break; case 'object': - sortResult = SortComparers.objectString(value1, value2, sortDirection, sortColumn, gridOptions); + sortResult = objectStringSortComparer(value1, value2, sortDirection, sortColumn, gridOptions); break; case 'string': case 'text': case 'password': case 'readonly': default: - sortResult = SortComparers.string(value1, value2, sortDirection, sortColumn, gridOptions); + sortResult = stringSortComparer(value1, value2, sortDirection, sortColumn, gridOptions); break; } }