diff --git a/.eslintrc b/.eslintrc index 718dee6933..190b9bce58 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,7 +8,7 @@ ], "root": true, "rules": { - "id-length": ["error", { "min": 2, "properties": "never", "exceptions": ["b", "i", "_"] }], + "id-length": ["error", { "min": 2, "properties": "never", "exceptions": ["b", "_"] }], "react/jsx-fragments": [ "error", "element" diff --git a/src/components/Alert/AlertActions.tsx b/src/components/Alert/AlertActions.tsx index a90d87a270..5702ff63af 100644 --- a/src/components/Alert/AlertActions.tsx +++ b/src/components/Alert/AlertActions.tsx @@ -18,8 +18,8 @@ export const AlertActions = ({items, children, className}: AlertActionsProps) => wrap alignItems={layout === 'horizontal' ? 'center' : 'flex-start'} > - {items?.map(({handler, text}, i) => ( - + {items?.map(({handler, text}, index) => ( + {text} )) || children} diff --git a/src/components/Breadcrumbs/Breadcrumbs.tsx b/src/components/Breadcrumbs/Breadcrumbs.tsx index c7e216f0f8..601fbc852d 100644 --- a/src/components/Breadcrumbs/Breadcrumbs.tsx +++ b/src/components/Breadcrumbs/Breadcrumbs.tsx @@ -238,8 +238,8 @@ export class Breadcrumbs extends Re ]; const itemsWidths = items.map( - (elem, i) => - elem.scrollWidth + (i === items.length - 1 ? GAP_WIDTH : GAP_WIDTH * 2), + (elem, index) => + elem.scrollWidth + (index === items.length - 1 ? GAP_WIDTH : GAP_WIDTH * 2), ); const dividersWidths = dividers.map((elem) => elem.offsetWidth); const buttonsWidth = itemsWidths.reduce((total, width, index, widths) => { diff --git a/src/components/List/List.tsx b/src/components/List/List.tsx index b69f8a7539..665c474f3e 100644 --- a/src/components/List/List.tsx +++ b/src/components/List/List.tsx @@ -81,6 +81,7 @@ export class List extends React.Component, ListState { - if (i === 0) { + points.forEach((point, index) => { + if (index === 0) { marks[point] = {label: point, style: CLEAR_MARK_STYLE}; - } else if (i === lastIndex) { + } else if (index === lastIndex) { marks[point] = {label: point, style: CLEAR_MARK_STYLE}; } else { marks[point] = point; diff --git a/src/components/Table/hoc/withTableSelection/withTableSelection.tsx b/src/components/Table/hoc/withTableSelection/withTableSelection.tsx index cfa4c89b30..102cd85d84 100644 --- a/src/components/Table/hoc/withTableSelection/withTableSelection.tsx +++ b/src/components/Table/hoc/withTableSelection/withTableSelection.tsx @@ -132,9 +132,10 @@ export function withTableSelection( const begin = Math.min(this.lastCheckedIndex, index); const end = Math.max(this.lastCheckedIndex, index); - const dataIds = data.map((item, i) => Table.getRowId(this.props, item, i)); + const dataIds = data.map((item, index) => Table.getRowId(this.props, item, index)); const diffIds = dataIds.filter( - (_id, i) => begin <= i && i <= end && !this.isDisabled(data[i], i), + (_id, index) => + begin <= index && index <= end && !this.isDisabled(data[index], index), ); onSelectionChange( diff --git a/src/components/Table/hoc/withTableSorting/withTableSorting.tsx b/src/components/Table/hoc/withTableSorting/withTableSorting.tsx index b51e1a87c6..09c49ad058 100644 --- a/src/components/Table/hoc/withTableSorting/withTableSorting.tsx +++ b/src/components/Table/hoc/withTableSorting/withTableSorting.tsx @@ -84,6 +84,7 @@ export function withTableSorting( } return data.slice().sort((itemA, itemB) => { + // eslint-disable-next-line id-length let i = 0; while (i < sortState.length) { const state = sortState[i++]; diff --git a/src/components/useList/hooks/useListKeydown.tsx b/src/components/useList/hooks/useListKeydown.tsx index 802b0f4b42..c0adc403c2 100644 --- a/src/components/useList/hooks/useListKeydown.tsx +++ b/src/components/useList/hooks/useListKeydown.tsx @@ -40,7 +40,7 @@ export const useListKeydown = ({ (event: KeyboardEvent, step: number, defaultItemIndex = 0) => { event.preventDefault(); - const maybeIndex = visibleFlattenIds.findIndex((i) => i === activeItemId); + const maybeIndex = visibleFlattenIds.findIndex((id) => id === activeItemId); const nextIndex = findNextIndex({ list: visibleFlattenIds, diff --git a/src/components/useList/utils/findNextIndex.ts b/src/components/useList/utils/findNextIndex.ts index c00a429b50..f3279581ac 100644 --- a/src/components/useList/utils/findNextIndex.ts +++ b/src/components/useList/utils/findNextIndex.ts @@ -9,6 +9,7 @@ export const findNextIndex = ({list, index, step, disabledItems = {}}: FindNextI const dataLength = list.length; let currentIndex = (index + dataLength) % dataLength; + // eslint-disable-next-line id-length for (let i = 0; i < dataLength; i += 1) { if (list[currentIndex] && !disabledItems[currentIndex]) { return currentIndex; diff --git a/src/demo/DocsExample/DocsExample.tsx b/src/demo/DocsExample/DocsExample.tsx index 194db91899..cb1146245e 100644 --- a/src/demo/DocsExample/DocsExample.tsx +++ b/src/demo/DocsExample/DocsExample.tsx @@ -25,8 +25,8 @@ export function DocsExample({ }: DocsExampleProps) { return (
- {React.Children.map(children, (elem, i) => ( -
+ {React.Children.map(children, (elem, index) => ( +
{elem}
))} diff --git a/src/demo/ShowcaseGrid/getPropsCombinations.tsx b/src/demo/ShowcaseGrid/getPropsCombinations.tsx index 3e0dab5eae..304fbf78f1 100644 --- a/src/demo/ShowcaseGrid/getPropsCombinations.tsx +++ b/src/demo/ShowcaseGrid/getPropsCombinations.tsx @@ -43,6 +43,7 @@ export function getPropsCombinations({ }; }); + // eslint-disable-next-line id-length for (let i = 1; i < propNames.length; i++) { const newCombination = cache.reduce>>( (result, combination) => { diff --git a/src/demo/colors/ColorTable.tsx b/src/demo/colors/ColorTable.tsx index b31e434883..ee6837128b 100644 --- a/src/demo/colors/ColorTable.tsx +++ b/src/demo/colors/ColorTable.tsx @@ -15,6 +15,7 @@ export interface ColorTableProps { const b = cn('color-table'); const steps: number[] = []; +// eslint-disable-next-line id-length for (let i = 50; i <= 1000; i += 50) { steps.push(i); } diff --git a/src/stories/Branding/BrandingConfugurator/BrandingConfigurator.tsx b/src/stories/Branding/BrandingConfugurator/BrandingConfigurator.tsx index 9c6ee96eb8..842d40bc0a 100644 --- a/src/stories/Branding/BrandingConfugurator/BrandingConfigurator.tsx +++ b/src/stories/Branding/BrandingConfugurator/BrandingConfigurator.tsx @@ -121,8 +121,8 @@ export function BrandingConfigurator({theme}: BrandingConfiguratorProps) {
- {paletteColors.map((color, i) => ( -
+ {paletteColors.map((color, index) => ( +
))}
diff --git a/src/stories/Branding/PaletteGenerator/PaletteGenerator.tsx b/src/stories/Branding/PaletteGenerator/PaletteGenerator.tsx index c70a9a8d65..f4cecd14d3 100644 --- a/src/stories/Branding/PaletteGenerator/PaletteGenerator.tsx +++ b/src/stories/Branding/PaletteGenerator/PaletteGenerator.tsx @@ -59,11 +59,11 @@ export function PaletteGenerator({theme}: BrandingConfiguratorProps) { const palette = React.useMemo(() => { return Object.entries(colorsMap).reduce( (res, [key, {a, c}]) => { - const i = Number(key); + const parsedKey = Number(key); const solidColor = chroma .mix(color, c > 0 ? highContrastBase : lowContrastBase, 1 - a, 'rgb') .css(); - const alphaColor = i > 500 ? '' : chroma(color).alpha(a).css(); + const alphaColor = parsedKey > 500 ? '' : chroma(color).alpha(a).css(); res[key] = [solidColor, alphaColor]; @@ -192,10 +192,10 @@ export function PaletteGenerator({theme}: BrandingConfiguratorProps) {
Palette
- {Object.entries(palette).map(([i, colors]) => { + {Object.entries(palette).map(([index, colors]) => { return ( - -
{i}
+ +
{index}