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

Fix lgtm alerts #1169

Merged
merged 5 commits into from
Jun 29, 2021
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
84 changes: 42 additions & 42 deletions packages/common-components/src/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ interface IModalProps {
testId?: string
}

const Modal: React.FC<IModalProps> = ({
const Modal = ({
children,
className,
className = "",
closePosition = "right",
injectedClass,
active = false,
Expand All @@ -165,49 +165,49 @@ const Modal: React.FC<IModalProps> = ({

useOnClickOutside(ref, () => handleClose())

return active ? (
<article
if (!active) return null

return <article
className={clsx(
classes.root,
className,
setActive ? "closable" : "",
"active"
)}
onClick={onModalBodyClick}
>
<section
data-testid={`modal-container-${testId}`}
ref={ref}
style={
maxWidth && typeof maxWidth == "number"
? {
width: "100%",
maxWidth: maxWidth
}
: {}
}
className={clsx(
classes.root,
className && `${className}`,
setActive ? "closable" : "",
active ? "active" : "closed"
)}
onClick={onModalBodyClick}
>
<section
data-testid={`modal-container-${testId}`}
ref={ref}
style={
maxWidth && typeof maxWidth == "number"
? {
width: "100%",
maxWidth: maxWidth
}
: {}
}
className={clsx(
classes.inner,
classes.inner,
injectedClass?.inner,
typeof maxWidth != "number" ? maxWidth : ""
)}
>
{setActive && (
<div
onClick={() => handleClose()}
className={clsx(
classes.closeIcon,
injectedClass?.close,
`${closePosition}`
)}
>
<CloseSvg />
</div>
)}
{children}
</section>
</article>
) : null
)}
>
{setActive && (
<div
onClick={() => handleClose()}
className={clsx(
classes.closeIcon,
injectedClass?.close,
closePosition
)}
>
<CloseSvg />
</div>
)}
{children}
</section>
</article>
}

export default Modal
Expand Down
12 changes: 3 additions & 9 deletions packages/common-components/src/NumberInput/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ const useStyles = makeStyles(
"& input": {
fontSize: 16,
lineHeight: "24px",
padding: `${constants.generalUnit}px ${
constants.generalUnit * 1.5
}px`
padding: `${constants.generalUnit}px ${constants.generalUnit * 1.5}px`
},
"&.iconLeft input": {
paddingLeft:
Expand All @@ -227,9 +225,7 @@ const useStyles = makeStyles(
},
"&.medium": {
"& input": {
padding: `${constants.generalUnit * 0.625}px ${
constants.generalUnit * 1.5
}px`,
padding: `${constants.generalUnit * 0.625}px ${constants.generalUnit * 1.5}px`,
fontSize: 16,
lineHeight: "20px"
},
Expand Down Expand Up @@ -257,9 +253,7 @@ const useStyles = makeStyles(
},
"&.small": {
"& input": {
padding: `${constants.generalUnit / constants.generalUnit}px ${
constants.generalUnit
}px`
padding: `1px ${constants.generalUnit}px`
},
"&.iconLeft input": {
paddingLeft:
Expand Down
5 changes: 1 addition & 4 deletions packages/common-components/src/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const iconSize = {
const useStyles = makeStyles(
({ constants, palette, animation, overrides, typography }: ITheme) =>
createStyles({
// JSS in CSS goes here
root: {
...typography.body2,
display: "block",
Expand Down Expand Up @@ -100,9 +99,7 @@ const useStyles = makeStyles(
},
"&.small": {
"& input": {
padding: `${constants.generalUnit / constants.generalUnit}px ${
constants.generalUnit
}px`
padding: `1px ${constants.generalUnit}px`
}
}
},
Expand Down
4 changes: 1 addition & 3 deletions packages/common-components/src/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,7 @@ const useStyles = makeStyles(
},
"&.small": {
"& input": {
padding: `${constants.generalUnit / constants.generalUnit}px ${
constants.generalUnit
}px`
padding: `1px ${constants.generalUnit}px`
},
"&.iconLeft input": {
paddingLeft:
Expand Down
24 changes: 11 additions & 13 deletions packages/common-theme/src/utils/colorManipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,17 @@ export function decomposeColor(color: string): IColorObject {
}

// Converts a color object with type and values to a string.
export function recomposeColor(color: IColorObject) {
const { type } = color
const { values } = color

let valuesArray: (number | string)[] = values

if (type.indexOf("rgb") !== -1) {
// Only convert the first 3 values to int (i.e. not alpha)
valuesArray = values.map((n, i) => (i < 3 && n)) as ColorValues
} else if (type.indexOf("hsl") !== -1) {
valuesArray[1] = `${values[1]}%`
valuesArray[2] = `${values[2]}%`
}

export function recomposeColor({ type, values }: IColorObject) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a regression

Copy link
Collaborator Author

@Tbaut Tbaut Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check it out in details, valuesArray is actually never used.

edit: I'm fine to remove this function altogether, I don't think it's used either anyway.

// let valuesArray: (number | string)[] = values

// if (type.indexOf("rgb") !== -1) {
// // Only convert the first 3 values to int (i.e. not alpha)
// valuesArray = values.map((n, i) => (i < 3 && n)) as ColorValues
// } else if (type.indexOf("hsl") !== -1) {
// valuesArray[1] = `${values[1]}%`
// valuesArray[2] = `${values[2]}%`
// }

return `${type}(${values.join(", ")})`
}
Expand Down
5 changes: 3 additions & 2 deletions packages/files-ui/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import "./commands"
// the following gets rid of the exception "ResizeObserver loop limit exceeded"
// which someone on the internet says we can safely ignore
// source https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded
const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/
Cypress.on("uncaught:exception", (err) => {
/* returning false here prevents Cypress from failing the test */
if (resizeObserverLoopErrRe.test(err.message)) {
if (err.message.includes("ResizeObserver loop limit exceeded")) {
// returning false here prevents Cypress from
// failing the test
return false
}
})
Expand Down
8 changes: 3 additions & 5 deletions packages/files-ui/src/Contexts/ThresholdKeyContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -500,18 +500,16 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f
if (loginType === "web3") {

let addressToUse = address
let signer

if (!isReady || !provider) {
const connected = await checkIsReady()

if (!connected || !provider) throw new Error("Unable to connect to wallet.")
}

if(!signer){
signer = provider.getSigner()
if (!signer) throw new Error("Signer undefined")
}

const signer = provider.getSigner()
if (!signer) throw new Error("Signer undefined")

if(!addressToUse){
// checkIsReady above doesn't make sure that the address is defined
Expand Down