Skip to content

Commit

Permalink
refactor: add rule and remove dangling underscores (microsoft#3496)
Browse files Browse the repository at this point in the history
* add rule and remove dangling underscores

* update elliptic and test

Co-authored-by: Andy Brown <asbrown002@gmail.com>
  • Loading branch information
beyackle and a-b-r-o-w-n authored Jun 25, 2020
1 parent f342a50 commit 5b8ba63
Show file tree
Hide file tree
Showing 21 changed files with 1,018 additions and 768 deletions.
10 changes: 10 additions & 0 deletions Composer/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ module.exports = {
yoda: 'error',
'no-bitwise': 'error',
// eqeqeq: 'error',
'no-underscore-dangle': [
'error',
{
// add special window.__foo__ names as exceptions here
allow: ['__nonce__', '__IS_ELECTRON__'],
// allow this._name so custom getters and setters can be written gracefully
allowAfterThis: true,
enforceInMethodNames: true,
},
],

// plugin: import
'import/first': 'error',
Expand Down
3 changes: 3 additions & 0 deletions Composer/cypress/integration/NotificationPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ context('Notification Page', () => {
it('can show dialog expression error ', () => {
cy.visitPage('Design');

// click the logo to clear any stray tooltips from page navigation
cy.findByAltText('Composer Logo').click();

cy.findByTestId('ProjectTree').within(() => {
cy.findByText('WelcomeUser').click();
});
Expand Down
5 changes: 3 additions & 2 deletions Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"serialize-javascript": "^3.1.0",
"lodash": "^4.17.12",
"set-value": "^3.0.2",
"kind-of": "^6.0.3"
"kind-of": "^6.0.3",
"elliptic": "^6.5.3"
},
"engines": {
"node": ">=12"
Expand Down Expand Up @@ -119,4 +120,4 @@
"dependencies": {
"cross-env": "^6.0.3"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type SortState = {
descending: boolean;
};

const _renderIcon = (file: File) => {
const renderIcon = (file: File) => {
const iconName = getFileIconName(file);
if (iconName === FileTypes.FOLDER) {
return <Icon iconName="OpenFolderHorizontal" style={{ fontSize: '16px' }} />;
Expand All @@ -60,7 +60,7 @@ const _renderIcon = (file: File) => {
return <img alt={`${iconName} file icon`} className={detailListClass.fileIconImg} src={url} />;
};

const _renderNameColumn = (onFileChosen: (file: File) => void) => (file: File) => {
const renderNameColumn = (onFileChosen: (file: File) => void) => (file: File) => {
const iconName = getFileIconName(file);
return (
<div data-is-focusable css={tableCell}>
Expand Down Expand Up @@ -105,7 +105,7 @@ export const FileSelector: React.FC<FileSelectorProps> = (props) => {
fieldName: 'name',
minWidth: 16,
maxWidth: 16,
onRender: _renderIcon,
onRender: renderIcon,
},
{
key: 'name',
Expand All @@ -118,7 +118,7 @@ export const FileSelector: React.FC<FileSelectorProps> = (props) => {
sortAscendingAriaLabel: formatMessage('Sorted A to Z'),
sortDescendingAriaLabel: formatMessage('Sorted Z to A'),
data: 'string',
onRender: _renderNameColumn(onFileChosen),
onRender: renderNameColumn(onFileChosen),
isPadded: true,
},
{
Expand Down
6 changes: 3 additions & 3 deletions Composer/packages/client/src/components/ErrorPopup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ErrorPopupProps = {
export const ErrorPopup = (props: ErrorPopupProps) => {
const [hidden, setHidden] = useState(props.error ? false : true);

const _closeDialog = () => {
const closeDialog = () => {
setHidden(true);
props.onDismiss();
};
Expand All @@ -35,11 +35,11 @@ export const ErrorPopup = (props: ErrorPopupProps) => {
isBlocking: false,
styles: { main: { maxWidth: 450 } },
}}
onDismiss={_closeDialog}
onDismiss={closeDialog}
>
<div css={consoleStyle}>{props.error}</div>
<DialogFooter>
<PrimaryButton text="Ok" onClick={_closeDialog} />
<PrimaryButton text="Ok" onClick={closeDialog} />
</DialogFooter>
</Dialog>
);
Expand Down
2 changes: 2 additions & 0 deletions Composer/packages/client/src/pages/design/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ const DesignPage: React.FC<RouteComponentProps<{ dialogId: string; projectId: st
onBreadcrumbItemClick: handleBreadcrumbItemClick,
promptTab: getTabFromFragment(),
});
/* eslint-disable no-underscore-dangle */
// @ts-ignore
globalHistory._onTransitionComplete();
/* eslint-enable */
} else {
//leave design page should clear the history
clearUndoHistory();
Expand Down
5 changes: 3 additions & 2 deletions Composer/packages/client/src/pages/home/ExampleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const resolveIcon = (exampleId: string): string => {
export const ExampleList: React.FC<ExampleListProps> = (props) => {
const { onClick, examples } = props;

function _onRenderCell(item?: ProjectTemplate): React.ReactNode {
function onRenderCell(item?: ProjectTemplate): React.ReactNode {
if (!item) {
return;
}
Expand All @@ -46,6 +46,7 @@ export const ExampleList: React.FC<ExampleListProps> = (props) => {
data-is-focusable
aria-label={item.name + '; ' + item.description}
css={exampleListCell}
role="button"
tabIndex={0}
onClick={() => onClick(item.id)}
onKeyDown={(ev) => {
Expand All @@ -66,7 +67,7 @@ export const ExampleList: React.FC<ExampleListProps> = (props) => {
return (
<div css={exampleListContainer} data-is-scrollable="true">
<ScrollablePane scrollbarVisibility={ScrollbarVisibility.auto}>
<List items={examples} onRenderCell={_onRenderCell} />
<List items={examples} onRenderCell={onRenderCell} />
</ScrollablePane>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const CodeEditor: React.FC<CodeEditorProps> = (props) => {
[file, projectId]
);

const _onChange = useCallback(
const onChange = useCallback(
(value) => {
if (!file) return;
if (inlineMode) {
Expand Down Expand Up @@ -142,7 +142,7 @@ const CodeEditor: React.FC<CodeEditorProps> = (props) => {
}}
lgOption={lgOption}
value={content}
onChange={_onChange}
onChange={onChange}
onChangeSettings={handleSettingsChange}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const CodeEditor: React.FC<CodeEditorProps> = (props) => {
[file, projectId]
);

const _onChange = useCallback(
const onChange = useCallback(
(value) => {
setContent(value);
if (!file) return;
Expand Down Expand Up @@ -134,7 +134,7 @@ const CodeEditor: React.FC<CodeEditorProps> = (props) => {
}}
luOption={luOption}
value={content}
onChange={_onChange}
onChange={onChange}
onChangeSettings={handleSettingsChange}
/>
);
Expand Down
34 changes: 17 additions & 17 deletions Composer/packages/client/src/pages/publish/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,29 +159,29 @@ const Publish: React.FC<PublishPageProps> = (props) => {

useEffect(() => {
if (settings.publishTargets && settings.publishTargets.length > 0) {
const _selected = settings.publishTargets.find((item) => item.name === selectedTargetName);
setSelectedTarget(_selected);
const selected = settings.publishTargets.find((item) => item.name === selectedTargetName);
setSelectedTarget(selected);
// load publish histories
if (selectedTargetName === 'all') {
for (const target of settings.publishTargets) {
actions.getPublishHistory(projectId, target);
}
} else if (_selected) {
actions.getPublishHistory(projectId, _selected);
} else if (selected) {
actions.getPublishHistory(projectId, selected);
}
}
}, [projectId, selectedTargetName]);

// once history is loaded, display it
useEffect(() => {
if (settings.publishTargets && selectedTargetName === 'all') {
let _histories: any[] = [];
const _groups: any[] = [];
let histories: any[] = [];
const groups: any[] = [];
let startIndex = 0;
for (const target of settings.publishTargets) {
if (publishHistory[target.name]) {
_histories = _histories.concat(publishHistory[target.name]);
_groups.push({
histories = histories.concat(publishHistory[target.name]);
groups.push({
key: target.name,
name: target.name,
startIndex: startIndex,
Expand All @@ -191,8 +191,8 @@ const Publish: React.FC<PublishPageProps> = (props) => {
startIndex += publishHistory[target.name].length;
}
}
setGroups(_groups);
setThisPublishHistory(_histories);
setGroups(groups);
setThisPublishHistory(histories);
} else if (selectedTargetName && publishHistory[selectedTargetName]) {
setThisPublishHistory(publishHistory[selectedTargetName]);
setGroups([
Expand Down Expand Up @@ -221,14 +221,14 @@ const Publish: React.FC<PublishPageProps> = (props) => {

const savePublishTarget = useCallback(
async (name: string, type: string, configuration: string) => {
const _target = (settings.publishTargets || []).concat([
const target = (settings.publishTargets || []).concat([
{
name,
type,
configuration,
},
]);
await actions.setSettings(projectId, { ...settings, publishTargets: _target });
await actions.setSettings(projectId, { ...settings, publishTargets: target });
onSelectTarget(name);
},
[settings.publishTargets, projectId, botName]
Expand All @@ -240,15 +240,15 @@ const Publish: React.FC<PublishPageProps> = (props) => {
return;
}

const _targets = settings.publishTargets ? [...settings.publishTargets] : [];
const targets = settings.publishTargets ? [...settings.publishTargets] : [];

_targets[editTarget.index] = {
targets[editTarget.index] = {
name,
type,
configuration,
};

await actions.setSettings(projectId, { ...settings, publishTargets: _targets });
await actions.setSettings(projectId, { ...settings, publishTargets: targets });

onSelectTarget(name);
},
Expand Down Expand Up @@ -339,8 +339,8 @@ const Publish: React.FC<PublishPageProps> = (props) => {

if (result) {
if (settings.publishTargets && settings.publishTargets.length > index) {
const _target = settings.publishTargets.slice(0, index).concat(settings.publishTargets.slice(index + 1));
await actions.setSettings(projectId, { ...settings, publishTargets: _target });
const target = settings.publishTargets.slice(0, index).concat(settings.publishTargets.slice(index + 1));
await actions.setSettings(projectId, { ...settings, publishTargets: target });
// redirect to all profiles
setSelectedTarget(undefined);
onSelectTarget('all');
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/src/store/action/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const setError: ActionCreator = ({ dispatch }, error) => {
});
};

const _setMessage = debounce((dispatch, message: string) => {
const setMessageHelper = debounce((dispatch, message: string) => {
dispatch({
type: ActionTypes.SET_MESSAGE,
payload: message,
Expand All @@ -31,5 +31,5 @@ const _setMessage = debounce((dispatch, message: string) => {
}, 500);

export const setMessage: ActionCreator = ({ dispatch }, message) => {
_setMessage(dispatch, message);
setMessageHelper(dispatch, message);
};
Loading

0 comments on commit 5b8ba63

Please sign in to comment.