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

[SIEM] Enable eslint prefer-template rule #53983

Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 1 addition & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,7 @@ module.exports = {
'prefer-promise-reject-errors': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
// This style will be turned on after most bugs are fixed
// 'prefer-template': 'warn',
'prefer-template': 'error',
'react/boolean-prop-naming': 'error',
'react/button-has-type': 'error',
'react/forbid-dom-props': 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ run(
// We can only care about SIEM code, we should not be penalyze for others
if (circularFound.filter(cf => cf.includes('siem')).length !== 0) {
throw createFailError(
'SIEM circular dependencies of imports has been found:' +
'\n - ' +
circularFound.join('\n - ')
`SIEM circular dependencies of imports has been found:\n - ${circularFound.join('\n - ')}`
);
} else {
log.success('No circular deps 👍');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { gutterTimeline } from '../../lib/helpers';

const offsetChrome = 49;

const disableSticky = 'screen and (max-width: ' + euiLightVars.euiBreakpoints.s + ')';
const disableSticky = `screen and (max-width: ${euiLightVars.euiBreakpoints.s})`;
const disableStickyMq = window.matchMedia(disableSticky);

const Wrapper = styled.aside<{ isSticky?: boolean }>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export const ColumnHeadersComponent = ({
position="relative"
// Passing the styles directly to the component because the width is being calculated and is recommended by Styled Components for performance: https://github.com/styled-components/styled-components/issues/134#issuecomment-312415291
style={{
flexBasis: header.width + 'px',
flexBasis: `${header.width}px`,
...dragProvided.draggableProps.style,
}}
>
Expand All @@ -186,7 +186,7 @@ export const ColumnHeadersComponent = ({
<DragEffects>
<DraggableFieldBadge
fieldId={header.id}
fieldWidth={header.width + 'px'}
fieldWidth={`${header.width}px`}
/>
</DragEffects>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const DataDrivenColumns = React.memo<Props>(
return (
<EventsTdGroupData data-test-subj="data-driven-columns">
{columnHeaders.map((header, index) => (
<EventsTd key={header.id} style={{ flexBasis: header.width + 'px' }}>
<EventsTd key={header.id} style={{ flexBasis: `${header.width}px` }}>
<EventsTdContent data-test-subj="cell-container">
{getColumnRenderer(header.id, columnRenderers, data).renderColumn({
columnName: header.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const Body = React.memo<BodyProps>(
<EventsTable
data-test-subj="events-table"
// Passing the styles directly to the component because the width is being calculated and is recommended by Styled Components for performance: https://github.com/styled-components/styled-components/issues/134#issuecomment-312415291
style={{ minWidth: columnWidths + 'px' }}
style={{ minWidth: `${columnWidths}px` }}
>
<ColumnHeaders
actionsColumnWidth={actionsColumnWidth}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const TimelineBodyGlobalStyle = createGlobalStyle`
export const TimelineBody = styled.div.attrs(({ className }) => ({
className: `siemTimeline__body ${className}`,
}))<{ bodyHeight: number }>`
height: ${({ bodyHeight }) => bodyHeight + 'px'};
height: ${({ bodyHeight }) => `${bodyHeight}px`};
overflow: auto;
scrollbar-width: thin;

Expand Down Expand Up @@ -89,7 +89,7 @@ export const EventsThGroupActions = styled.div.attrs(({ className }) => ({
className: `siemEventsTable__thGroupActions ${className}`,
}))<{ actionsColumnWidth: number; justifyContent: string }>`
display: flex;
flex: 0 0 ${({ actionsColumnWidth }) => actionsColumnWidth + 'px'};
flex: 0 0 ${({ actionsColumnWidth }) => `${actionsColumnWidth}px`};
justify-content: ${({ justifyContent }) => justifyContent};
min-width: 0;
`;
Expand Down Expand Up @@ -182,7 +182,7 @@ export const EventsTdGroupActions = styled.div.attrs(({ className }) => ({
}))<{ actionsColumnWidth: number }>`
display: flex;
justify-content: space-between;
flex: 0 0 ${({ actionsColumnWidth }) => actionsColumnWidth + 'px'};
flex: 0 0 ${({ actionsColumnWidth }) => `${actionsColumnWidth}px`};
min-width: 0;
`;
EventsTdGroupActions.displayName = 'EventsTdGroupActions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const allRulesNdJson = 'index.ts';
const walk = dir => {
const list = fs.readdirSync(dir);
return list.reduce((accum, file) => {
const fileWithDir = dir + '/' + file;
const fileWithDir = `${dir}/${file}`;
const stat = fs.statSync(fileWithDir);
if (stat && stat.isDirectory()) {
return [...accum, ...walk(fileWithDir)];
Expand Down