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

chore: update typescript, eslint and prettier #1686

Merged
merged 9 commits into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Composer/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
'@typescript-eslint/ban-ts-ignore': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-use-before-define': 'warn',

Expand Down
27 changes: 13 additions & 14 deletions Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,26 @@
"@cypress/webpack-preprocessor": "^4.1.1",
"@emotion/babel-preset-css-prop": "^10.0.17",
"@testing-library/cypress": "^5.0.2",
"@typescript-eslint/eslint-plugin": "2.6.0",
"@typescript-eslint/parser": "2.6.0",
"@typescript-eslint/eslint-plugin": "2.10.0",
"@typescript-eslint/parser": "2.10.0",
"babel-jest": "24.0.0",
"concurrently": "^4.1.0",
"coveralls": "^3.0.7",
"cypress": "^3.6.1",
"cypress-plugin-tab": "^1.0.1",
"eslint": "^5.15.1",
"eslint-config-prettier": "^4.1.0",
"eslint": "^6.7.2",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-cypress": "^2.7.0",
"eslint-plugin-emotion": "^10.0.14",
"eslint-plugin-format-message": "^6.2.3",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.1.3",
"eslint-plugin-lodash": "^6.0.0",
"eslint-plugin-notice": "^0.7.8",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "7.12.4",
"eslint-plugin-react-hooks": "^1.6.0",
"eslint-plugin-notice": "^0.8.9",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react-hooks": "^2.3.0",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-typescript": "^0.14.0",
"husky": "^1.3.1",
"jest": "24.0.0",
"jest-dom": "^3.1.3",
Expand All @@ -98,12 +97,12 @@
"mocha": "5.2.0",
"mocha-junit-reporter": "^1.22.0",
"mocha-multi-reporters": "^1.1.7",
"prettier": "^1.15.3",
"prettier": "^1.19.1",
"react-testing-library": "^6.0.2",
"rimraf": "^2.6.3",
"ts-loader": "^6.2.1",
"typescript": "3.6.4",
"wsrun": "^3.6.4"
"typescript": "3.7.2",
"wsrun": "^5.1.0"
},
"dependencies": {
"cross-env": "^6.0.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,21 @@ export const FileSelector: React.FC<FileSelectorProps> = props => {

const storageFiles = useMemo(() => {
if (!focusedStorageFolder.children) return [];
const files = focusedStorageFolder.children.reduce(
(result, file) => {
const check = typeof checkShowItem === 'function' ? checkShowItem : () => true;
if (check(file)) {
result.push({
name: file.name,
value: file.name,
fileType: file.type,
iconName: getFileIconName(file),
lastModified: file.lastModified,
fileSize: file.size ? formatBytes(file.size) : '',
filePath: file.path,
});
}
return result;
},
[] as any[]
);
const files = focusedStorageFolder.children.reduce((result, file) => {
const check = typeof checkShowItem === 'function' ? checkShowItem : () => true;
if (check(file)) {
result.push({
name: file.name,
value: file.name,
fileType: file.type,
iconName: getFileIconName(file),
lastModified: file.lastModified,
fileSize: file.size ? formatBytes(file.size) : '',
filePath: file.path,
});
}
return result;
}, [] as any[]);
// add parent folder
files.unshift({
name: '..',
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/Onboarding/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface OnboardingContext {
minimized: boolean;
hideModal: boolean;
stepSets: IStepSet[];
teachingBubble: IStep & { setLength: number } | null;
teachingBubble: (IStep & { setLength: number }) | null;
};
}

Expand Down
4 changes: 1 addition & 3 deletions Composer/packages/client/src/pages/about/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ export const About: React.FC<RouteComponentProps> = () => {
<div css={about.DiagnosticsInfoTextAlignLeft}>{formatMessage(`SDK runtime packages`)}</div>
<div css={about.DiagnosticsInfoTextAlignLeft}>
<Link
href={`https://botbuilder.myget.org/feed/botbuilder-v4-dotnet-daily/package/nuget/Microsoft.Bot.Builder.Dialogs.Adaptive/${
process.env.SDK_PACKAGE_VERSON
}`}
href={`https://botbuilder.myget.org/feed/botbuilder-v4-dotnet-daily/package/nuget/Microsoft.Bot.Builder.Dialogs.Adaptive/${process.env.SDK_PACKAGE_VERSON}`}
tabIndex={-1}
target={'_blank'}
style={{ marginLeft: '5px' }}
Expand Down
33 changes: 15 additions & 18 deletions Composer/packages/client/src/pages/design/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,24 +287,21 @@ function DesignPage(props) {
const breadcrumbItems = useMemo(() => {
const items =
dialogs.length > 0
? breadcrumb.reduce(
(result, item, index) => {
const { dialogId, selected, focused } = item;
const text = getbreadcrumbLabel(dialogs, dialogId, selected, focused);
if (text) {
result.push({
// @ts-ignore
index,
isRoot: !selected && !focused,
text,
...item,
onClick: handleBreadcrumbItemClick,
});
}
return result;
},
[] as IBreadcrumbItem[]
)
? breadcrumb.reduce((result, item, index) => {
const { dialogId, selected, focused } = item;
const text = getbreadcrumbLabel(dialogs, dialogId, selected, focused);
if (text) {
result.push({
// @ts-ignore
index,
isRoot: !selected && !focused,
text,
...item,
onClick: handleBreadcrumbItemClick,
});
}
return result;
}, [] as IBreadcrumbItem[])
: [];
return (
<Breadcrumb
Expand Down
41 changes: 19 additions & 22 deletions Composer/packages/client/src/pages/language-generation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,26 @@ const LGPage: React.FC<RouteComponentProps> = props => {
const lgFile = lgFiles.length ? lgFiles[0] : null;

const navLinks = useMemo<INavLinkGroup[]>(() => {
const subLinks = dialogs.reduce<INavLink>(
(result, file) => {
const item = {
id: file.id,
key: file.id,
name: file.displayName,
url: file.id,
const subLinks = dialogs.reduce<INavLink>((result, file) => {
const item = {
id: file.id,
key: file.id,
name: file.displayName,
url: file.id,
};

if (file.isRoot) {
result = {
...result,
...item,
isExpanded: true,
};

if (file.isRoot) {
result = {
...result,
...item,
isExpanded: true,
};
} else {
result.links = result.links || [];
result.links.push(item);
}
return result;
},
{} as INavLink
);
} else {
result.links = result.links || [];
result.links.push(item);
}
return result;
}, {} as INavLink);

return [
{
Expand Down
11 changes: 4 additions & 7 deletions Composer/packages/client/src/store/action/bindActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
import { Store, ActionHandlers, BoundActionHandlers } from '../types';

export default function bindActions(store: Store, actions: ActionHandlers) {
return Object.keys(actions).reduce(
(boundActions, actionName) => {
boundActions[actionName] = actions[actionName].bind(null, store);
return boundActions;
},
{} as BoundActionHandlers
);
return Object.keys(actions).reduce((boundActions, actionName) => {
boundActions[actionName] = actions[actionName].bind(null, store);
return boundActions;
}, {} as BoundActionHandlers);
}
8 changes: 4 additions & 4 deletions Composer/packages/client/src/store/reducer/createReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { ActionTypes } from './../../constants';

type CreateReducerFunc = (
handlers: {
[type in Exclude<ActionTypes, ActionTypes.UNDO | ActionTypes.REDO | ActionTypes.HISTORY_CLEAR>]: ReducerFunc
[type in Exclude<ActionTypes, ActionTypes.UNDO | ActionTypes.REDO | ActionTypes.HISTORY_CLEAR>]: ReducerFunc;
}
) => (state: State, action: ActionType) => State;

const createReducer: CreateReducerFunc = handlers => {
// ensure action created is defined in constants/index.js#ActionTypes
// when we switch to typescript, this is not need anymore.
Object.keys(handlers).forEach(type => {
if (ActionTypes.hasOwnProperty(type) === false) {
if (Object.prototype.hasOwnProperty.call(ActionTypes, type) === false) {
throw new Error(`action created is not defined in constants/index.js#ActionTypes`);
}
});
Expand All @@ -27,11 +27,11 @@ const createReducer: CreateReducerFunc = handlers => {
const { type, payload } = action as GenericActionType;

// ensure action dispatched is defined in constants/index.js#ActionTypes
if (ActionTypes.hasOwnProperty(type) === false) {
if (Object.prototype.hasOwnProperty.call(ActionTypes, type) === false) {
throw new Error(`action dispatched is not defined in constants/index.js#ActionTypes`);
}

if (handlers.hasOwnProperty(type)) {
if (Object.prototype.hasOwnProperty.call(handlers, type)) {
return producer(state, nextState => {
handlers[type](nextState, payload);
});
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/utils/lgUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function textFromTemplates(templates: Template[]): string {
let text = '';

templates.forEach(template => {
if (template.Name && (template.Body !== null && template.Body !== undefined)) {
if (template.Name && template.Body !== null && template.Body !== undefined) {
text += `# ${template.Name.trim()}`;
if (template.Parameters && template.Parameters.length > 0) {
text += '(' + template.Parameters.join(', ') + ')';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ interface EventMenuProps {
}

export const EventMenu: React.FC<EventMenuProps> = ({ label, onClick, ...rest }): JSX.Element => {
const eventMenuItems = createStepMenu(
[DialogGroup.EVENTS],
false,
(e, item): any => onClick(item ? item.$type : null)
const eventMenuItems = createStepMenu([DialogGroup.EVENTS], false, (e, item): any =>
onClick(item ? item.$type : null)
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,9 @@ export const ObiEditor: FC<ObiEditorProps> = ({
onSelect(selectionContext.selectedIds.length ? selectionContext.selectedIds : focusedId ? [focusedId] : []);
}, [focusedId, selectionContext]);

useEffect(
(): void => {
selection.setItems(nodeIndexGenerator.current.getItemList());
}
);
useEffect((): void => {
selection.setItems(nodeIndexGenerator.current.getItemList());
});

useEffect((): void => {
resetSelectionData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export function sequentialLayouter(nodes: GraphNode[], withHeadEdge = true, with
return new GraphLayout();
}

const box = calculateSequenceBoundary(nodes.map(x => x.boundary), withHeadEdge, withTrailingEdge);
const box = calculateSequenceBoundary(
nodes.map(x => x.boundary),
withHeadEdge,
withTrailingEdge
);

nodes.reduce((offsetY, node) => {
node.offset = { x: box.axisX - node.boundary.axisX, y: offsetY };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@ function parseSelector(path: string): null | string[] {
selectors.shift();
}

const normalizedSelectors = selectors.reduce(
(result, selector) => {
// e.g. actions[0]
const parseResult = /(\w+)\[(-\d+|\d+)\]/.exec(selector);
const normalizedSelectors = selectors.reduce((result, selector) => {
// e.g. actions[0]
const parseResult = /(\w+)\[(-\d+|\d+)\]/.exec(selector);

if (parseResult) {
const [, objSelector, arraySelector] = parseResult;
const arrayIndex = parseInt(arraySelector);
result.push(objSelector, arrayIndex);
} else {
result.push(selector);
}
if (parseResult) {
const [, objSelector, arraySelector] = parseResult;
const arrayIndex = parseInt(arraySelector);
result.push(objSelector, arrayIndex);
} else {
result.push(selector);
}

return result;
},
[] as any[]
);
return result;
}, [] as any[]);

return normalizedSelectors;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,20 @@ function parseSelector(path: string): null | string[] {
selectors.shift();
}

const normalizedSelectors = selectors.reduce(
(result, selector) => {
// e.g. actions[0]
const parseResult = /(\w+)\[(\d+)\]/.exec(selector);

if (parseResult) {
const [, objSelector, arraySelector] = parseResult;
const arrayIndex = parseInt(arraySelector);
result.push(objSelector, arrayIndex);
} else {
result.push(selector);
}

return result;
},
[] as any[]
);
const normalizedSelectors = selectors.reduce((result, selector) => {
// e.g. actions[0]
const parseResult = /(\w+)\[(\d+)\]/.exec(selector);

if (parseResult) {
const [, objSelector, arraySelector] = parseResult;
const arrayIndex = parseInt(arraySelector);
result.push(objSelector, arrayIndex);
} else {
result.push(selector);
}

return result;
}, [] as any[]);

return normalizedSelectors;
}
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/lib/code-editor/src/LgEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function LgEditor(props: LGLSPEditorProps) {
};
const editorDidMount = (editor: monacoEditor.editor.IStandaloneCodeEditor, monaco: typeof monacoEditor) => {
if (!window.monacoServiceInstance) {
window.monacoServiceInstance = MonacoServices.install(editor as (monacoCore.editor.IStandaloneCodeEditor | any));
window.monacoServiceInstance = MonacoServices.install(editor as monacoCore.editor.IStandaloneCodeEditor | any);
}

if (!window.monacoLGEditorInstance) {
Expand Down
Loading