Skip to content

Commit

Permalink
fix(build): add ESLint-TS rules to enforce type imports and exports (
Browse files Browse the repository at this point in the history
…#1432)

* chore(build): add ESLint-TS rules to enforce `type` imports and exports
  • Loading branch information
ghiscoding committed Mar 19, 2024
1 parent 30be835 commit cce4693
Show file tree
Hide file tree
Showing 44 changed files with 119 additions and 84 deletions.
5 changes: 5 additions & 0 deletions .eslintrc
@@ -1,5 +1,8 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["./tsconfig.base.json"]
},
"settings": {
"node": {
"tryExtensions": [".js", ".json", ".node", ".ts", ".d.ts"],
Expand Down Expand Up @@ -36,6 +39,8 @@
"extendDefaults": true
}
],
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/aggregators/avgAggregator.ts
@@ -1,6 +1,6 @@
import { isNumber } from '@slickgrid-universal/utils';

import { SlickGroupTotals } from '../core/slickCore';
import type { SlickGroupTotals } from '../core/slickCore';
import type { Aggregator } from './../interfaces/aggregator.interface';

export class AvgAggregator implements Aggregator {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/aggregators/cloneAggregator.ts
@@ -1,4 +1,4 @@
import { SlickGroupTotals } from '../core/slickCore';
import type { SlickGroupTotals } from '../core/slickCore';
import type { Aggregator } from './../interfaces/aggregator.interface';

export class CloneAggregator implements Aggregator {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/aggregators/countAggregator.ts
@@ -1,7 +1,7 @@
import { isNumber } from '@slickgrid-universal/utils';

import type { Aggregator } from './../interfaces/aggregator.interface';
import { SlickGroupTotals } from '../core/slickCore';
import type { SlickGroupTotals } from '../core/slickCore';

export class CountAggregator implements Aggregator {
private _isInitialized = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/aggregators/distinctAggregator.ts
@@ -1,4 +1,4 @@
import { SlickGroupTotals } from '../core/slickCore';
import type { SlickGroupTotals } from '../core/slickCore';
import type { Aggregator } from './../interfaces/aggregator.interface';

export class DistinctAggregator implements Aggregator {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/aggregators/maxAggregator.ts
@@ -1,7 +1,7 @@
import { isNumber } from '@slickgrid-universal/utils';

import type { Aggregator } from './../interfaces/aggregator.interface';
import { SlickGroupTotals } from '../core/slickCore';
import type { SlickGroupTotals } from '../core/slickCore';

export class MaxAggregator implements Aggregator {
private _isInitialized = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/aggregators/minAggregator.ts
@@ -1,6 +1,6 @@
import { isNumber } from '@slickgrid-universal/utils';

import { SlickGroupTotals } from '../core/slickCore';
import type { SlickGroupTotals } from '../core/slickCore';
import type { Aggregator } from './../interfaces/aggregator.interface';

export class MinAggregator implements Aggregator {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/aggregators/sumAggregator.ts
@@ -1,6 +1,6 @@
import { isNumber } from '@slickgrid-universal/utils';

import { SlickGroupTotals } from '../core/slickCore';
import type { SlickGroupTotals } from '../core/slickCore';
import type { Aggregator } from './../interfaces/aggregator.interface';

export class SumAggregator implements Aggregator {
Expand Down
@@ -1,4 +1,4 @@
import { AutocompleteItem } from 'autocompleter';
import type { AutocompleteItem } from 'autocompleter';

import type { AutocompleterOption } from '../interfaces/index';

Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/core/slickCore.ts
Expand Up @@ -7,7 +7,7 @@
* @module Core
* @namespace Slick
*/
import { MergeTypes } from '../enums/index';
import type { MergeTypes } from '../enums/index';
import type { CSSStyleDeclarationWritable, EditController } from '../interfaces';

export type Handler<ArgType = any> = (e: SlickEventData<ArgType>, args: ArgType) => void;
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/core/slickDataview.ts
Expand Up @@ -18,14 +18,14 @@ import type {
OnSetItemsCalledEventArgs,
PagingInfo
} from '../interfaces';
import { CssStyleHash, CustomDataView } from '../interfaces/gridOption.interface';
import type { CssStyleHash, CustomDataView } from '../interfaces/gridOption.interface';
import {
type BasePubSub,
SlickEvent,
SlickEventData,
SlickGroup,
SlickGroupTotals,
SlickNonDataItem,
type SlickNonDataItem,
} from './slickCore';
import type { SlickGrid } from './slickGrid';

Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/core/slickGrid.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-cond-assign */
import Sortable, { SortableEvent } from 'sortablejs';
import Sortable, { type SortableEvent } from 'sortablejs';
import DOMPurify from 'isomorphic-dompurify';
import { BindingEventService } from '@slickgrid-universal/binding';
import {
Expand Down Expand Up @@ -27,7 +27,7 @@ import {
Utils,
} from './slickCore';
import { Draggable, MouseWheel, Resizable } from './slickInteractions';
import { SelectionModel } from '../enums/index';
import type { SelectionModel } from '../enums/index';
import type {
CellViewportRange,
Column,
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/editors/selectEditor.ts
@@ -1,6 +1,6 @@
import { emptyElement, setDeepValue } from '@slickgrid-universal/utils';
import { dequal } from 'dequal/lite';
import { multipleSelect, MultipleSelectInstance, MultipleSelectOption, OptionRowData } from 'multiple-select-vanilla';
import { multipleSelect, type MultipleSelectInstance, type MultipleSelectOption, type OptionRowData } from 'multiple-select-vanilla';

import { Constants } from '../constants';
import { FieldType } from './../enums/index';
Expand Down
@@ -1,7 +1,7 @@
import { createDomElement, getHtmlStringOutput, stripTags } from '@slickgrid-universal/utils';

import type { Column, ExcelCopyBufferOption, ExternalCopyClipCommand, OnEventArgs } from '../interfaces/index';
import { SlickEvent, SlickEventData, SlickEventHandler, type SlickGrid, SlickRange, SlickDataView, Utils as SlickUtils } from '../core/index';
import { SlickEvent, SlickEventData, SlickEventHandler, type SlickGrid, SlickRange, type SlickDataView, Utils as SlickUtils } from '../core/index';

// using external SlickGrid JS libraries
const CLEAR_COPY_SELECTION_DELAY = 2000;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/slickCellRangeSelector.ts
Expand Up @@ -10,7 +10,7 @@ import type {
OnScrollEventArgs,
} from '../interfaces/index';
import { SlickCellRangeDecorator } from './index';
import { SlickEvent, SlickEventData, SlickEventHandler, type SlickGrid, SlickRange, Utils as SlickUtils } from '../core/index';
import { SlickEvent, type SlickEventData, SlickEventHandler, type SlickGrid, SlickRange, Utils as SlickUtils } from '../core/index';

export class SlickCellRangeSelector {
pluginName: 'CellRangeSelector' = 'CellRangeSelector' as const;
Expand Down
Expand Up @@ -5,7 +5,7 @@ import { createDomElement, emptyElement } from '@slickgrid-universal/utils';
import { type SlickDataView, type SlickEventData, SlickEventHandler, type SlickGrid } from '../core/index';
import type { CheckboxSelectorOption, Column, DOMMouseOrTouchEvent, GridOption, OnHeaderClickEventArgs, OnKeyDownEventArgs, SelectableOverrideCallback } from '../interfaces/index';
import { SlickRowSelectionModel } from './slickRowSelectionModel';
import { SelectionModel } from '../enums/index';
import type { SelectionModel } from '../enums/index';

export interface RowLookup { [row: number]: boolean; }

Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/extensions/slickRowBasedEdit.ts
@@ -1,4 +1,4 @@
import { BasePubSubService } from '@slickgrid-universal/event-pub-sub';
import { type BasePubSubService } from '@slickgrid-universal/event-pub-sub';
import { createDomElement } from '@slickgrid-universal/utils';

import type {
Expand All @@ -11,9 +11,9 @@ import type {
OnSetOptionsEventArgs,
RowBasedEditOptions,
} from '../interfaces/index';
import { SlickEventData, SlickEventHandler, SlickGlobalEditorLock, type SlickGrid } from '../core/index';
import { GridService } from '../services';
import { ExtensionUtility } from './extensionUtility';
import { type SlickEventData, SlickEventHandler, SlickGlobalEditorLock, type SlickGrid } from '../core/index';
import type { GridService } from '../services';
import type { ExtensionUtility } from './extensionUtility';

export const ROW_BASED_EDIT_ROW_HIGHLIGHT_CLASS = 'slick-rbe-editmode';
export const ROW_BASED_EDIT_UNSAVED_CELL = 'slick-rbe-unsaved-cell';
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/filters/selectFilter.ts
@@ -1,4 +1,4 @@
import { multipleSelect, MultipleSelectInstance, MultipleSelectOption, OptionRowData } from 'multiple-select-vanilla';
import { multipleSelect, type MultipleSelectInstance, type MultipleSelectOption, type OptionRowData } from 'multiple-select-vanilla';
import { emptyElement, isPrimitiveValue } from '@slickgrid-universal/utils';

import { Constants } from '../constants';
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/formatters/treeParseTotalsFormatter.ts
@@ -1,5 +1,5 @@
import { Constants } from '../constants';
import { Formatter, GridOption, GroupTotalsFormatter } from '../interfaces/index';
import type { Formatter, GridOption, GroupTotalsFormatter } from '../interfaces/index';

export const treeParseTotalsFormatter: Formatter = (row, cell, value, columnDef, dataContext, grid) => {
const gridOptions = grid.getOptions() as GridOption;
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/index.ts
Expand Up @@ -8,10 +8,10 @@ export * from '@slickgrid-universal/utils';
export {
// export nearly everything except the EventPubSubService because we want to force users to import from '@slickgrid-universal/event-pub-sub
// also export BasePubSubService as alias to avoid breaking users who might already use PubSubService from common
BasePubSubService as PubSubService,
type BasePubSubService as PubSubService,
EventNamingStyle,
EventSubscription,
PubSubEvent
type EventSubscription,
type PubSubEvent
} from '@slickgrid-universal/event-pub-sub';

// Public classes.
Expand Down Expand Up @@ -45,4 +45,4 @@ export { Utilities };
export { SlickgridConfig } from './slickgrid-config';

// re-export MultipleSelectOption to avoid breaking previous code implementation
export { MultipleSelectOption } from 'multiple-select-vanilla';
export type { MultipleSelectOption } from 'multiple-select-vanilla';
2 changes: 1 addition & 1 deletion packages/common/src/interfaces/headerMenu.interface.ts
Expand Up @@ -5,7 +5,7 @@ import type {
MenuCommandItem,
MenuCommandItemCallbackArgs,
} from './index';
import { SlickGrid, type SlickEventData } from '../core/index';
import type { SlickGrid, SlickEventData } from '../core/index';

export interface HeaderMenuCommandItemCallbackArgs {
/** Column definition */
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/interfaces/interactions.interface.ts
Expand Up @@ -2,7 +2,7 @@
// --
// Slick Interactions

import { DragPosition } from './drag.interface';
import type { DragPosition } from './drag.interface';

export interface InteractionBase {
destroy: () => void;
Expand Down
@@ -1,6 +1,6 @@
import { SlickRowBasedEdit } from '../extensions';
import { Column } from './column.interface';
import { OnEventArgs } from './onEventArgs.interface';
import type { SlickRowBasedEdit } from '../extensions';
import type { Column } from './column.interface';
import type { OnEventArgs } from './onEventArgs.interface';

export interface RowBasedEditOptions {
/** the display name of the added actions column */
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/services/domUtilities.ts
@@ -1,5 +1,5 @@
import { createDomElement } from '@slickgrid-universal/utils';
import { OptionRowData } from 'multiple-select-vanilla';
import type { OptionRowData } from 'multiple-select-vanilla';
import DOMPurify from 'isomorphic-dompurify';

import type { SearchTerm } from '../enums/index';
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/services/extension.service.ts
@@ -1,11 +1,11 @@
import { BasePubSubService } from '@slickgrid-universal/event-pub-sub';
import { type BasePubSubService } from '@slickgrid-universal/event-pub-sub';

import type { Column, ExtensionModel, GridOption, SlickRowDetailView, } from '../interfaces/index';
import { type ColumnReorderFunction, type ExtensionList, ExtensionName, type InferExtensionByName, type SlickControlList, type SlickPluginList } from '../enums/index';
import type { SharedService } from './shared.service';
import type { TranslaterService } from './translater.service';
import {
ExtensionUtility,
type ExtensionUtility,
SlickAutoTooltip,
SlickCellExcelCopyManager,
SlickCellMenu,
Expand All @@ -14,7 +14,7 @@ import {
SlickContextMenu,
SlickDraggableGrouping,
SlickGridMenu,
SlickGroupItemMetadataProvider,
type SlickGroupItemMetadataProvider,
SlickHeaderButtons,
SlickHeaderMenu,
SlickRowBasedEdit,
Expand All @@ -24,7 +24,7 @@ import {
import type { FilterService } from './filter.service';
import type { SortService } from './sort.service';
import type { TreeDataService } from './treeData.service';
import { GridService } from './grid.service';
import type { GridService } from './grid.service';

interface ExtensionWithColumnIndexPosition {
name: ExtensionName;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/services/filter.service.ts
@@ -1,4 +1,4 @@
import { BasePubSubService } from '@slickgrid-universal/event-pub-sub';
import { type BasePubSubService } from '@slickgrid-universal/event-pub-sub';
import { deepCopy, extend, stripTags } from '@slickgrid-universal/utils';
import { dequal } from 'dequal/lite';

Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/services/sort.service.ts
Expand Up @@ -15,7 +15,7 @@ import { getDescendantProperty, flattenToParentChildArray } from './utilities';
import { sortByFieldType } from '../sortComparers/sortUtilities';
import type { SharedService } from './shared.service';
import type { RxJsFacade, Subject } from './rxjsFacade';
import { type SlickDataView, SlickEventData, SlickEventHandler, type SlickGrid } from '../core/index';
import { type SlickDataView, type SlickEventData, SlickEventHandler, type SlickGrid } from '../core/index';

export class SortService {
protected _currentLocalSorters: CurrentSorter[] = [];
Expand Down
@@ -1,4 +1,13 @@
import { Column, CompositeEditorOption, Editors, ElementPosition, GridOption, type SlickDataView, SlickEvent, type SlickGrid } from '@slickgrid-universal/common';
import {
type Column,
type CompositeEditorOption,
Editors,
type ElementPosition,
type GridOption,
type SlickDataView,
SlickEvent,
type SlickGrid
} from '@slickgrid-universal/common';

import { SlickCompositeEditor } from './compositeEditor.factory';

Expand Down
@@ -1,14 +1,14 @@
import 'jest-extended';
import {
Column,
CompositeEditorOpenDetailOption,
Editor,
type Column,
type CompositeEditorOpenDetailOption,
type Editor,
Editors,
GridOption,
GridService,
type GridOption,
type GridService,
type SlickDataView,
SlickEvent,
SlickRowSelectionModel,
type SlickRowSelectionModel,
type SlickGrid,
} from '@slickgrid-universal/common';

Expand Down
Expand Up @@ -10,7 +10,7 @@ import type {
TranslaterService,
} from '@slickgrid-universal/common';
import { Constants, createDomElement, SlickEventHandler, } from '@slickgrid-universal/common';
import { BasePubSubService } from '@slickgrid-universal/event-pub-sub';
import { type BasePubSubService } from '@slickgrid-universal/event-pub-sub';
import { BindingHelper } from '@slickgrid-universal/binding';

export class SlickFooterComponent {
Expand Down
2 changes: 1 addition & 1 deletion packages/custom-footer-component/src/slick-footer.spec.ts
@@ -1,5 +1,5 @@
import 'jest-extended';
import { CustomFooterOption, GridOption, SlickEvent, type SlickGrid } from '@slickgrid-universal/common';
import { type CustomFooterOption, type GridOption, SlickEvent, type SlickGrid } from '@slickgrid-universal/common';
import { EventPubSubService } from '@slickgrid-universal/event-pub-sub';

import { SlickFooterComponent } from './slick-footer.component';
Expand Down
18 changes: 9 additions & 9 deletions packages/excel-export/src/excelExport.service.spec.ts
Expand Up @@ -6,20 +6,20 @@ jest.mock('excel-builder-vanilla', () => ({
}));

import 'jest-extended';
import { BasePubSubService } from '@slickgrid-universal/event-pub-sub';
import type { BasePubSubService } from '@slickgrid-universal/event-pub-sub';
import {
Column,
ExcelExportOption,
type Column,
type ExcelExportOption,
FieldType,
FileType,
Formatter,
type Formatter,
Formatters,
GridOption,
GroupTotalsFormatter,
type GridOption,
type GroupTotalsFormatter,
GroupTotalFormatters,
ItemMetadata,
SlickDataView,
SlickGrid,
type ItemMetadata,
type SlickDataView,
type SlickGrid,
SortComparers,
SortDirectionNumber,
} from '@slickgrid-universal/common';
Expand Down
4 changes: 2 additions & 2 deletions packages/excel-export/src/excelExport.service.ts
Expand Up @@ -4,7 +4,7 @@ import {
type ExcelMetadata,
type StyleSheet,
Workbook,
Worksheet,
type Worksheet,
} from 'excel-builder-vanilla';
import type {
Column,
Expand Down Expand Up @@ -36,7 +36,7 @@ import {
import { addWhiteSpaces, deepCopy, getHtmlStringOutput, stripTags, titleCase } from '@slickgrid-universal/utils';

import {
ExcelFormatter,
type ExcelFormatter,
getGroupTotalValue,
getExcelFormatFromGridFormatter,
useCellFormatByFieldType,
Expand Down

0 comments on commit cce4693

Please sign in to comment.