Skip to content

Commit

Permalink
chore(linting): enable radix rule (#11098)
Browse files Browse the repository at this point in the history
**Related Issue:** N/A

## Summary

Enables the [radix](https://eslint.org/docs/latest/rules/radix) rule to
ban unnecessary usage of `radix` when using `parseInt`:

> On the other hand, if the code is targeting only ES5-compliant
environments passing the radix 10 may be redundant. In such a case you
might want to disallow using such a radix.
  • Loading branch information
jcfranco authored Jan 1, 2025
1 parent 87da0b1 commit a11a496
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions packages/calcite-components/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export default [
],
},
],
"radix": ["error", "as-needed"],

"@esri/calcite-components/no-dynamic-createelement": "warn",
"@esri/calcite-components/strict-boolean-attributes": "error",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,8 @@ describe("calcite-dialog", () => {
let computedStyle = await container.getComputedStyle();
const initialBlockSize = computedStyle.blockSize;
const initialInlineSize = computedStyle.inlineSize;
const initialHeight = parseInt(initialBlockSize, 10);
const initialWidth = parseInt(initialInlineSize, 10);
const initialHeight = parseInt(initialBlockSize);
const initialWidth = parseInt(initialInlineSize);

await dispatchDialogKeydown({ page, key: "ArrowUp", shiftKey: true });

Expand Down
8 changes: 4 additions & 4 deletions packages/calcite-components/src/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,12 @@ export class Dialog
modifiers: [
interact.modifiers.restrictSize({
min: {
width: isPixelValue(minInlineSize) ? parseInt(minInlineSize, 10) : 0,
height: isPixelValue(minBlockSize) ? parseInt(minBlockSize, 10) : 0,
width: isPixelValue(minInlineSize) ? parseInt(minInlineSize) : 0,
height: isPixelValue(minBlockSize) ? parseInt(minBlockSize) : 0,
},
max: {
width: isPixelValue(maxInlineSize) ? parseInt(maxInlineSize, 10) : window.innerWidth,
height: isPixelValue(maxBlockSize) ? parseInt(maxBlockSize, 10) : window.innerHeight,
width: isPixelValue(maxInlineSize) ? parseInt(maxInlineSize) : window.innerWidth,
height: isPixelValue(maxBlockSize) ? parseInt(maxBlockSize) : window.innerHeight,
},
}),
interact.modifiers.restrict({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export class Pagination extends LitElement implements LoadableComponent {

private handlePageClick(event: Event) {
const target = event.target as HTMLButtonElement;
this.startItem = parseInt(target.value, 10);
this.startItem = parseInt(target.value);
this.emitUpdate();
}

Expand Down
4 changes: 2 additions & 2 deletions packages/calcite-components/src/components/sheet/sheet.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ describe("calcite-sheet properties", () => {

let computedStyle = await container.getComputedStyle();
const initialInlineSize = computedStyle.inlineSize;
const initialWidth = parseInt(initialInlineSize, 10);
const initialWidth = parseInt(initialInlineSize);

const resizeHandle = await page.find(`calcite-sheet >>> .${CSS.resizeHandle}`);
await resizeHandle.focus();
Expand Down Expand Up @@ -710,7 +710,7 @@ describe("calcite-sheet properties", () => {
await page.waitForChanges();
computedStyle = await container.getComputedStyle();
const initialBlockSize = computedStyle.blockSize;
const initialHeight = parseInt(initialBlockSize, 10);
const initialHeight = parseInt(initialBlockSize);

await page.keyboard.down("ArrowDown");
await page.keyboard.up("ArrowDown");
Expand Down
12 changes: 6 additions & 6 deletions packages/calcite-components/src/components/sheet/sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@ export class Sheet
window.getComputedStyle(contentEl);

const values: ResizeValues = {
inlineSize: isPixelValue(inlineSize) ? parseInt(inlineSize, 10) : 0,
blockSize: isPixelValue(blockSize) ? parseInt(blockSize, 10) : 0,
minInlineSize: isPixelValue(minInlineSize) ? parseInt(minInlineSize, 10) : 0,
minBlockSize: isPixelValue(minBlockSize) ? parseInt(minBlockSize, 10) : 0,
maxInlineSize: isPixelValue(maxInlineSize) ? parseInt(maxInlineSize, 10) : window.innerWidth,
maxBlockSize: isPixelValue(maxBlockSize) ? parseInt(maxBlockSize, 10) : window.innerHeight,
inlineSize: isPixelValue(inlineSize) ? parseInt(inlineSize) : 0,
blockSize: isPixelValue(blockSize) ? parseInt(blockSize) : 0,
minInlineSize: isPixelValue(minInlineSize) ? parseInt(minInlineSize) : 0,
minBlockSize: isPixelValue(minBlockSize) ? parseInt(minBlockSize) : 0,
maxInlineSize: isPixelValue(maxInlineSize) ? parseInt(maxInlineSize) : window.innerWidth,
maxBlockSize: isPixelValue(maxBlockSize) ? parseInt(maxBlockSize) : window.innerHeight,
};

this.resizeValues = values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ export class ShellPanel extends LitElement {
}

private updateWidths(computedStyle: CSSStyleDeclaration): void {
const max = parseInt(computedStyle.getPropertyValue("max-width"), 10);
const min = parseInt(computedStyle.getPropertyValue("min-width"), 10);
const valueNow = parseInt(computedStyle.getPropertyValue("width"), 10);
const max = parseInt(computedStyle.getPropertyValue("max-width"));
const min = parseInt(computedStyle.getPropertyValue("min-width"));
const valueNow = parseInt(computedStyle.getPropertyValue("width"));

if (typeof valueNow === "number" && !isNaN(valueNow)) {
this.initialContentWidth = valueNow;
Expand All @@ -311,9 +311,9 @@ export class ShellPanel extends LitElement {
}

private updateHeights(computedStyle: CSSStyleDeclaration): void {
const max = parseInt(computedStyle.getPropertyValue("max-height"), 10);
const min = parseInt(computedStyle.getPropertyValue("min-height"), 10);
const valueNow = parseInt(computedStyle.getPropertyValue("height"), 10);
const max = parseInt(computedStyle.getPropertyValue("max-height"));
const min = parseInt(computedStyle.getPropertyValue("min-height"));
const valueNow = parseInt(computedStyle.getPropertyValue("height"));

if (typeof valueNow === "number" && !isNaN(valueNow)) {
this.initialContentHeight = valueNow;
Expand Down

0 comments on commit a11a496

Please sign in to comment.