Skip to content

Commit

Permalink
Add linting to GitHub CI process
Browse files Browse the repository at this point in the history
  • Loading branch information
low-earth-orbit committed Sep 8, 2024
1 parent 4f6a468 commit ba3100f
Show file tree
Hide file tree
Showing 14 changed files with 342 additions and 110 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/eslint.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: ESLint & Prettier

on:
push:
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["main"]

jobs:
lint:
name: Run eslint scanning
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
# actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint

- name: Run Prettier
run: npm run format

- name: TypeScript check
run: npm run tsc
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ Then, open [http://localhost:3000](http://localhost:3000) in your browser to acc

## Contribute

Contributions are welcome! More details will be provided soon.
Contributions are welcome! More details will be provided soon.
8 changes: 4 additions & 4 deletions components/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function Canvas() {
const dispatch = useDispatch();
const [stageSize, setStageSize] = useState<StageSizeType>();
const { canvasObjects, selectedObjectId } = useSelector(
(state: RootState) => state.canvas
(state: RootState) => state.canvas,
);

const [selectedTool, setSelectedTool] = useState<ToolType>("pen");
Expand Down Expand Up @@ -188,14 +188,14 @@ export default function Canvas() {
updateCanvasObject({
id: selectedObjectId,
updates: { [property]: value },
})
}),
);
}
}

function updateSelectedObject(
newAttrs: Partial<CanvasObjectType>,
selectedObjectId: string
selectedObjectId: string,
) {
dispatch(updateCanvasObject({ id: selectedObjectId, updates: newAttrs }));
}
Expand Down Expand Up @@ -352,7 +352,7 @@ export default function Canvas() {

// Dispatch the update with the new object
dispatch(
updateCanvasObject({ id: lastObject.id, updates: updatedObject })
updateCanvasObject({ id: lastObject.id, updates: updatedObject }),
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function Toolbar({
const dispatch = useDispatch();

const { undoStack, redoStack } = useSelector(
(state: RootState) => state.canvas
(state: RootState) => state.canvas,
);

// color picker
Expand All @@ -72,7 +72,7 @@ function Toolbar({
const isColorPickerAnchorElOpen = Boolean(colorPickerAnchorEl);

const handleClickColorPickerButton = (
event: React.MouseEvent<HTMLButtonElement>
event: React.MouseEvent<HTMLButtonElement>,
) => {
setColorPickerAnchorEl(event.currentTarget);
};
Expand All @@ -88,7 +88,7 @@ function Toolbar({
const isShapesAnchorElOpen = Boolean(shapesAnchorEl);

const handleClickShapesButton = (
event: React.MouseEvent<HTMLButtonElement>
event: React.MouseEvent<HTMLButtonElement>,
) => {
setShapesAnchorEl(event.currentTarget);
};
Expand All @@ -104,7 +104,7 @@ function Toolbar({
const isLineWeightSliderAnchorElOpen = Boolean(lineWeightAnchorEl);

const handleClickLineWeightButton = (
event: React.MouseEvent<HTMLButtonElement>
event: React.MouseEvent<HTMLButtonElement>,
) => {
setLineWeightAnchorEl(event.currentTarget);
};
Expand Down
2 changes: 1 addition & 1 deletion components/shapes/OvalShape.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ export default function OvalShape({
)}
</>
);
}
}
7 changes: 6 additions & 1 deletion components/shapes/RectangleShape.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ type Props = {
onChange: (newAttrs: Partial<CanvasObjectType>) => void;
};

export default function RectangleShape({ shapeProps, isSelected, onSelect, onChange }: Props) {
export default function RectangleShape({
shapeProps,
isSelected,
onSelect,
onChange,
}: Props) {
const groupRef = useRef<Konva.Group>(null);
const trRef = useRef<Konva.Transformer>(null);

Expand Down
2 changes: 1 addition & 1 deletion components/shapes/ShapesLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type ShapesLayerProps = {
newObject: CanvasObjectType | null;
onChange: (
newAttrs: Partial<CanvasObjectType>,
selectedObjectId: string
selectedObjectId: string,
) => void;
setColor: (newColor: string) => void;
setWidth: (newWidth: number) => void;
Expand Down
2 changes: 1 addition & 1 deletion components/shapes/shapeUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const getStrokeWidth = (
strokeWidth: number | undefined,
width: number | undefined,
height: number | undefined
height: number | undefined,
) => {
if (width && height) {
const minStrokeWidth = Math.max(Math.min(width, height) / 2, 1);
Expand Down
2 changes: 1 addition & 1 deletion components/textFields/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,4 @@ export default function TextField({
)}
</>
);
}
}
2 changes: 1 addition & 1 deletion components/textFields/TextFieldsLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Props = {
setSelectedObjectId: (id: string) => void;
onChange: (
newAttrs: Partial<CanvasObjectType>,
selectedObjectId: string
selectedObjectId: string,
) => void;
};

Expand Down
Loading

0 comments on commit ba3100f

Please sign in to comment.