Skip to content

Commit ac1c88b

Browse files
authored
Refactor: codefactor code smells (#2)
* Refactor: codefactor code smells * cleanup
1 parent f199d2c commit ac1c88b

File tree

6 files changed

+10
-18
lines changed

6 files changed

+10
-18
lines changed

src/App.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
import React from 'react';
2-
import logo from './logo.svg';
32
import './App.css';
4-
import {Card, DatePicker} from 'antd';
5-
import MyButton from './components/MyButton';
6-
import ProfileCard from './components/ProfileCard';
7-
import TicTacToe from './components/TicTacToe';
83
import Board from './components/TicTacToe/Board';
94

105
function App() {
11-
const [count, setCount] = React.useState(0);
6+
// const [count, setCount] = React.useState(0);
127

13-
function handleClick(){
14-
setCount(count+1);
15-
console.log(`Button clicked ${count} times`);
16-
}
8+
// function handleClick(){
9+
// setCount(count+1);
10+
// console.log(`Button clicked ${count} times`);
11+
// }
1712
return (
1813
<div className="App">
1914
{/* <h1>Welcome to my App!</h1>

src/components/MyButton/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Button} from 'antd';
2-
import { MouseEventHandler, useState } from 'react';
2+
import { MouseEventHandler } from 'react';
33

44
// function handleClick(count: number, setCount: Function){
55
// alert("Button Clicked");

src/components/ProfileCard/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function ProfileCard() {
2424
let title: JSX.Element | null;
2525
let image: JSX.Element | null;
2626
let productsList: JSX.Element[] = products.map((product) => <li key={product.id} style={{ color: product.isFruit ? 'red' : 'green' }}>{product.title}</li>);
27-
if (user.name.length != 0) {
27+
if (user.name.length !== 0) {
2828
title = <h1>{user.name}</h1>;
2929
image = <img
3030
className="avatar"
@@ -35,7 +35,7 @@ export default function ProfileCard() {
3535
}
3636
else {
3737
title = <h1>John Doe</h1>;
38-
image = <img src="https://www.shutterstock.com/shutterstock/photos/2061533240/display_1500/stock-photo-mountain-view-california-oct" />;
38+
image = <img src="https://www.shutterstock.com/shutterstock/photos/2061533240/display_1500/stock-photo-mountain-view-california-oct" alt="Profile" />;
3939
}
4040
return (
4141
<div>

src/components/TicTacToe/Board/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useState } from "react";
22
import Square from "../Square";
3-
import { nextTick } from "process";
43

54
export default function Board(){
65
const [squares, setSquares] = useState<Array<String | null>>(Array(9).fill(null));
@@ -22,7 +21,7 @@ export default function Board(){
2221
console.log("called");
2322
const [a, b, c] = lines[i];
2423

25-
if(squares[a] && squares[a] == squares[b] && squares[a] == squares[c]){
24+
if(squares[a] && squares[a] === squares[b] && squares[a] === squares[c]){
2625
return squares[a];
2726
}
2827

src/components/TicTacToe/Square/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Button } from 'antd';
2-
import { MouseEventHandler, useState } from 'react';
2+
import { MouseEventHandler } from 'react';
33

44
export default function Square({value, OnSquareClicked}: {value: String | null, OnSquareClicked: MouseEventHandler<HTMLButtonElement>}){
55

src/components/TicTacToe/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Square from "./Square";
2-
31
export default function TicTacToe() {
42
return (
53
<>

0 commit comments

Comments
 (0)