Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: add eslint-plugin-import and extensions to import paths #376

Merged
merged 9 commits into from
Jun 27, 2022
1,777 changes: 1,114 additions & 663 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/configurations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You can override/use your own files to meet project requirements.

## TypeScript support

Below configurations are used with TypeScript (Element Framework v5).
Below configurations are used with TypeScript (Element Framework v6).

### .eslintrc

Expand Down
13 changes: 7 additions & 6 deletions packages/configurations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"keywords": [
"Element Framework",
"v5",
"v6",
"configurations",
"eslint",
"tsconfig",
Expand All @@ -22,13 +22,14 @@
"author": "Refinitiv",
"license": "Apache-2.0",
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"@typescript-eslint/eslint-plugin": "^5.29.0",
"@typescript-eslint/parser": "^5.29.0",
"eslint": "^8.18.0",
"eslint-plugin-html": "^6.2.0",
"typescript": "^4.6.2"
"eslint-plugin-import": "^2.26.0",
"typescript": "~4.6.4"
},
"publishConfig": {
"access": "public"
}
}
}
46 changes: 24 additions & 22 deletions packages/configurations/typescript.eslint-config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
module.exports = {
extends: [
"./eslint-config.js"
],
"overrides": [
extends: ['./eslint-config.js'],
overrides: [
{
files: ["*.ts", "*.tsx"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'eslint-plugin-import'],
extends: [
"./eslint-config.js",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
'./eslint-config.js',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
"parserOptions": {
"extraFileExtensions": [".html"]
parserOptions: {
extraFileExtensions: ['.html'],
},
rules: {
'import/extensions': ['error', 'always'],
'@typescript-eslint/unbound-method': 0,
'valid-jsdoc': [
2,
{
requireReturnType: false,
requireParamType: false,
},
],
},
"rules": {
"@typescript-eslint/unbound-method": 0,
"valid-jsdoc": [2, {
"requireReturnType": false,
"requireParamType": false
}]
}
}
]
},
],
};
12 changes: 8 additions & 4 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ export { DeprecationNotice } from './notices/DeprecationNotice.js';
* Export events
*/
export { TapEvent } from './events/TapEvent.js';
export type { FocusedChangedEvent } from './types/events';
import type { FocusedChangedEvent } from './types/events';
export type { FocusedChangedEvent };

/**
* Export common interfaces
*/
export type { MultiValue } from './interfaces/MultiValue';
export type { StyleMap } from './interfaces/StyleMap';
export type { StyleInfo } from './interfaces/StyleInfo';
wsuwt marked this conversation as resolved.
Show resolved Hide resolved
import type { MultiValue } from './interfaces/MultiValue';
export type { MultiValue };
import type { StyleMap } from './interfaces/StyleMap';
export type { StyleMap };
import type { StyleInfo } from './interfaces/StyleInfo';
export type { StyleInfo };

/**
* Export useful utils
Expand Down
2 changes: 1 addition & 1 deletion packages/demo-block/src/demo-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ themeLabel.style.textTransform = 'uppercase';
themeLabel.innerHTML = removePrefixName(currentTheme);

const versionTag = document.createElement('span');
versionTag.innerHTML = 'V5';
versionTag.innerHTML = 'V6';
versionTag.style.marginLeft = '8px';
versionTag.style.color = '#334BFF';
themeLabel.appendChild(versionTag);
Expand Down
2 changes: 1 addition & 1 deletion packages/elements/src/autosuggest/helpers/renderer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { uuid } from '@refinitiv-ui/utils/uuid.js';
import { updateElementContent } from './utils.js';
import { AutosuggestQuery, AutosuggestRenderer, Suggestion, AutosuggestItem } from './types';
import type { AutosuggestQuery, AutosuggestRenderer, Suggestion, AutosuggestItem } from './types';

/**
* Build item element from data object
Expand Down
2 changes: 1 addition & 1 deletion packages/elements/src/autosuggest/helpers/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Item } from '../../item';
import { AutosuggestHighlightable, AutosuggestItem } from './types';
import type { AutosuggestHighlightable, AutosuggestItem } from './types';

/**
* Check whether item can be highlighted
Expand Down
16 changes: 14 additions & 2 deletions packages/elements/src/autosuggest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
TranslateDirective,
TranslatePropertyKey
} from '@refinitiv-ui/translate';
import { TapEvent } from '../events';
import type { TapEvent } from '../events';
import type {
AutosuggestTargetElement,
AutosuggestHighlightable,
Expand All @@ -39,6 +39,17 @@ import '../loader/index.js';
import '../item/index.js';
import '@refinitiv-ui/phrasebook/locale/en/autosuggest.js';

import type {
ItemHighlightEvent,
AddAttachTargetEventsEvent,
RemoveAttachTargetEventsEvent,
ItemSelectEvent,
SuggestionsFetchRequestedEvent,
SuggestionsClearRequestedEvent,
SuggestionsQueryEvent,
SuggestionsChangedEvent
} from './helpers/types';

export type {
AutosuggestTargetElement,
AutosuggestHighlightable,
Expand All @@ -55,7 +66,8 @@ export type {
SuggestionsClearRequestedEvent,
SuggestionsQueryEvent,
SuggestionsChangedEvent
} from './helpers/types';
};

export { updateElementContent } from './helpers/utils.js';
export {
itemHighlightable,
Expand Down
2 changes: 1 addition & 1 deletion packages/elements/src/calendar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import {
YEAR_VIEW,
MONTH_VIEW
} from './constants.js';
import {
import type {
Cell,
Row,
Comparator,
Expand Down
8 changes: 5 additions & 3 deletions packages/elements/src/combo-box/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ import { CollectionComposer, DataItem } from '@refinitiv-ui/utils/collection.js'
import { AnimationTaskRunner, TimeoutTaskRunner } from '@refinitiv-ui/utils/async.js';
import { registerOverflowTooltip } from '../tooltip/index.js';
import { isElementOverflown } from '@refinitiv-ui/utils/element.js';
import { ItemData } from '../item';
import { ComboBoxData, ComboBoxFilter } from './helpers/types';
import type { List } from '../list/index.js';
import { ComboBoxRenderer } from './helpers/renderer.js';
import { defaultFilter } from './helpers/filter.js';
import { CustomKeyboardEvent } from './helpers/keyboard-event.js';
import '../icon/index.js';
import '../overlay/index.js';
import '../list/index.js';
import '../counter/index.js';

import type { ItemData } from '../item';
import type { ComboBoxData, ComboBoxFilter } from './helpers/types';
import type { List } from '../list';

import { translate, TranslateDirective } from '@refinitiv-ui/translate';
import '@refinitiv-ui/phrasebook/locale/en/combo-box.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/elements/src/datetime-field/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
TranslatePropertyKey
} from '@refinitiv-ui/translate';
import { Direction } from './constants.js';
import {
import type {
NavigationKeys,
DateTimeFormatPart,
InputSelection
Expand Down
2 changes: 1 addition & 1 deletion packages/elements/src/datetime-field/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DateTimeFormatPart, DateTimeFormatPartTypes, InputSelection } from './types';
import { Direction } from './constants.js';
import type { DateTimeFormatPart, DateTimeFormatPartTypes, InputSelection } from './types';

const IterablePartTypes: DateTimeFormatPartTypes[] = ['year', 'day', 'month', 'hour', 'minute', 'second', 'weekday', 'dayPeriod', 'fractionalSecond'];

Expand Down
4 changes: 2 additions & 2 deletions packages/elements/src/heatmap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import '../tooltip/index.js';

import { Track } from './helpers/track.js';
import { blend, brighten, darken, isLight, interpolate } from './helpers/color.js';
import type { HeatmapCell, HeatmapConfig, HeatmapTooltipCallback, HeatmapRenderCallback } from './helpers/types';
import { getResponsiveFontSize, getMaximumTextWidth, MIN_FONT_SIZE } from './helpers/text.js';

const MAX_CELL_WIDTH_RATIO = 0.85;
const DEFAULT_CANVAS_RATIO = 0.75; // ratio — 4:3

export type { HeatmapCell, HeatmapXAxis, HeatmapYAxis, HeatmapConfig, HeatmapTooltipCallback, HeatmapRenderCallback, HeatmapCustomisableProperties } from './helpers/types';
import type { HeatmapXAxis, HeatmapCell, HeatmapConfig, HeatmapYAxis, HeatmapCustomisableProperties, HeatmapTooltipCallback, HeatmapRenderCallback } from './helpers/types';
export type { HeatmapXAxis, HeatmapCell, HeatmapConfig, HeatmapYAxis, HeatmapCustomisableProperties, HeatmapTooltipCallback, HeatmapRenderCallback };

/**
* A graphical representation of data where the individual
Expand Down
2 changes: 1 addition & 1 deletion packages/elements/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { VERSION } from './version.js';
export * from './events';
export * from './events.js';
export * from '@refinitiv-ui/core';
12 changes: 7 additions & 5 deletions packages/elements/src/item/helpers/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DataItem } from '@refinitiv-ui/utils/collection.js';

export type ItemType = 'text' | 'header' | 'divider';
type ItemType = 'text' | 'header' | 'divider';

interface CommonItem extends DataItem {
/**
Expand All @@ -27,7 +27,7 @@ interface CommonLabelItem extends CommonItem {
/**
* Maps to a text/generic type ef-item
*/
export interface ItemText extends CommonLabelItem {
interface ItemText extends CommonLabelItem {
type?: 'text';
/**
* Value of the item
Expand All @@ -46,18 +46,20 @@ export interface ItemText extends CommonLabelItem {
/**
* Maps to `ef-item[type=header]`
*/
export interface ItemHeader extends CommonLabelItem {
interface ItemHeader extends CommonLabelItem {
type: 'header';
}

/**
* Maps to `ef-item[type=divider]`
*/
export interface ItemDivider extends CommonItem {
interface ItemDivider extends CommonItem {
type: 'divider';
}

/**
* Used to construct a collection of items
*/
export type ItemData = ItemText | ItemHeader | ItemDivider;
type ItemData = ItemText | ItemHeader | ItemDivider;

export type { ItemType, ItemText, ItemHeader, ItemDivider, ItemData };
4 changes: 2 additions & 2 deletions packages/elements/src/item/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
import { property } from '@refinitiv-ui/core/decorators/property.js';
import { query } from '@refinitiv-ui/core/decorators/query.js';
import { VERSION } from '../version.js';
import type { ItemType } from './helpers/types';
import '../icon/index.js';
import '../checkbox/index.js';

export * from './helpers/types';
import type { ItemType, ItemText, ItemHeader, ItemDivider, ItemData } from './helpers/types';
export type { ItemType, ItemText, ItemHeader, ItemDivider, ItemData };

const isAllWhitespaceTextNode = (node: Node): boolean =>
node.nodeType === document.TEXT_NODE
Expand Down
7 changes: 7 additions & 0 deletions packages/elements/src/overlay-menu/helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum Navigation {
FIRST = 'First',
LAST = 'Last',
NEXT = 'Next',
PREVIOUS = 'Previous',
}

8 changes: 0 additions & 8 deletions packages/elements/src/overlay-menu/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,3 @@ export type NestedMenu = {
};

export type OverlayMenuData = ItemData[] | CollectionComposer<ItemData>;

export enum Navigation {
FIRST = 'First',
LAST = 'Last',
NEXT = 'Next',
PREVIOUS = 'Previous',
}

3 changes: 2 additions & 1 deletion packages/elements/src/overlay-menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import '../item/index.js';
import { Item, ItemData } from '../item/index.js';
import { Overlay, OverlayPosition, OverlayPositionTarget } from '../overlay/index.js';
import { applyLock } from '../overlay/managers/interaction-lock-manager.js';
import { OverlayMenuData, Navigation } from './helpers/types';
import { OpenedMenusManager } from './managers/menu-manager.js';
import { Navigation } from './helpers/constants.js';
import type { OverlayMenuData } from './helpers/types';

export type { OverlayMenuData };

Expand Down
7 changes: 6 additions & 1 deletion packages/elements/src/overlay/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
export type {
import type {
Position as OverlayPosition,
PositionTarget as OverlayPositionTarget,
TransitionStyle as OverlayTransitionStyle
} from './helpers/types';
export type {
OverlayPosition,
OverlayPositionTarget,
OverlayTransitionStyle
};

export {
Overlay
Expand Down
2 changes: 1 addition & 1 deletion packages/elements/src/time-picker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
import { property } from '@refinitiv-ui/core/decorators/property.js';
import { state } from '@refinitiv-ui/core/decorators/state.js';
import { query } from '@refinitiv-ui/core/decorators/query.js';
import { ValueChangedEvent, FocusedChangedEvent } from '../events';
import type { ValueChangedEvent, FocusedChangedEvent } from '../events';
import { VERSION } from '../version.js';
import {
isValidTime,
Expand Down
4 changes: 3 additions & 1 deletion packages/elements/src/tree/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './elements/tree.js';
export * from './elements/tree-item.js';
export { TreeRenderer } from './helpers/renderer.js';
export type { TreeData, TreeDataItem } from './helpers/types';

import type { TreeData, TreeDataItem } from './helpers/types';
export type { TreeData, TreeDataItem };
10 changes: 9 additions & 1 deletion packages/i18n/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
export type {
import type {
TranslateOptions,
TranslateMessage,
TranslateParams,
UnicodeExtensions,
MessageFormats,
MessageOptions
} from './types';
export type {
TranslateOptions,
TranslateMessage,
TranslateParams,
UnicodeExtensions,
MessageFormats,
MessageOptions
};

export {
LangObserverCallback,
Expand Down
5 changes: 4 additions & 1 deletion packages/phrasebook/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export type {
import type {
Translations
} from './types';
export type {
Translations
};

export {
Phrasebook,
Expand Down
Loading