Skip to content

Commit

Permalink
[eslint] convert to @typescript-eslint/no-unused-expressions (#76471)
Browse files Browse the repository at this point in the history
* [eslint] convert to @typescript-eslint/no-unused-expressions

* fix lint errors

Co-authored-by: spalger <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
3 people committed Sep 4, 2020
1 parent 63a08b4 commit 9a8a028
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 16 deletions.
3 changes: 2 additions & 1 deletion packages/elastic-eslint-config-kibana/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ module.exports = {
'no-undef-init': 'error',
'no-unsafe-finally': 'error',
'no-unsanitized/property': 'error',
'no-unused-expressions': 'error',
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
'no-unused-labels': 'error',
'no-var': 'error',
'object-shorthand': 'error',
Expand Down
18 changes: 10 additions & 8 deletions test/functional/apps/visualize/_tsvb_markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await visualBuilder.markdownSwitchSubTab('markdown');
const rerenderedTable = await visualBuilder.getMarkdownTableVariables();
rerenderedTable.forEach((row) => {
// eslint-disable-next-line no-unused-expressions
variableName === 'label'
? expect(row.key).to.include.string(checkedValue)
: expect(row.key).to.not.include.string(checkedValue);
if (variableName === 'label') {
expect(row.key).to.include.string(checkedValue);
} else {
expect(row.key).to.not.include.string(checkedValue);
}
});
}

Expand Down Expand Up @@ -107,10 +108,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

table.forEach((row, index) => {
// exception: last index for variable is always: {{count.label}}
// eslint-disable-next-line no-unused-expressions
index === table.length - 1
? expect(row.key).to.not.include.string(VARIABLE)
: expect(row.key).to.include.string(VARIABLE);
if (index === table.length - 1) {
expect(row.key).to.not.include.string(VARIABLE);
} else {
expect(row.key).to.include.string(VARIABLE);
}
});

await cleanupMarkdownData(VARIABLE, VARIABLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { MockUrlParamsContextProvider } from '../../../context/UrlParamsContext/
// our current storybook setup has core-js-related problems when trying to import
// it.
// storiesOf('app/TransactionDurationAlertTrigger', module).add('example',
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
() => {
const params = {
threshold: 1500,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const LogEntryRow = memo(
]);

const handleOpenViewLogInContext = useCallback(() => {
openViewLogInContext?.(logEntry); // eslint-disable-line no-unused-expressions
openViewLogInContext?.(logEntry);
trackMetric({ metric: 'view_in_context__stream' });
}, [openViewLogInContext, logEntry, trackMetric]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export const LogEntryCategoriesResultsContent: React.FunctionComponent<LogEntryC

const showLoadDataErrorNotification = useCallback(
(error: Error) => {
// eslint-disable-next-line no-unused-expressions
services.notifications?.toasts.addError(error, {
title: loadDataErrorTitle,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export const LogEntryRateResultsContent: React.FunctionComponent = () => {
}),
};

// eslint-disable-next-line no-unused-expressions
navigateToApp?.('logs', { path: `/stream?${stringify(params)}` });
},
[queryTimeRange, navigateToApp]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,10 @@ const StatefulRowRenderersBrowserComponent: React.FC<StatefulRowRenderersBrowser
const hideFieldBrowser = useCallback(() => setShow(false), []);

const handleDisableAll = useCallback(() => {
// eslint-disable-next-line no-unused-expressions
tableRef?.current?.setSelection([]);
}, [tableRef]);

const handleEnableAll = useCallback(() => {
// eslint-disable-next-line no-unused-expressions
tableRef?.current?.setSelection(renderers);
}, [tableRef]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const RowRenderersBrowserComponent = React.forwardRef(
(item: RowRendererOption) => () => {
const newSelection = xor([item], notExcludedRowRenderers);
// @ts-expect-error
ref?.current?.setSelection(newSelection); // eslint-disable-line no-unused-expressions
ref?.current?.setSelection(newSelection);
},
[notExcludedRowRenderers, ref]
);
Expand Down

0 comments on commit 9a8a028

Please sign in to comment.