Skip to content

Commit b2e0724

Browse files
committed
chore: installed and configured @eslint and @prettier
1 parent 890f906 commit b2e0724

File tree

9 files changed

+259
-227
lines changed

9 files changed

+259
-227
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.next
2+
/.git
3+
node_modules

.eslintrc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"extends": "next/core-web-vitals"
2+
"extends": [
3+
"next/core-web-vitals",
4+
"standard",
5+
"plugin:tailwindcss/recommended",
6+
"prettier"
7+
],
8+
"ignorePatterns": ["/components/ui/*"]
39
}

.prettierignore

Whitespace-only changes.

.prettierrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "http://json.schemastore.org/prettierrc",
3+
"arrowParens": "avoid",
4+
"bracketSpacing": true,
5+
"jsxBracketSameLine": false,
6+
"jsxSingleQuote": false,
7+
"printWidth": 100,
8+
"proseWrap": "always",
9+
"quoteProps": "as-needed",
10+
"semi": true,
11+
"singleQuote": false,
12+
"tabWidth": 2,
13+
"trailingComma": "es5",
14+
"useTabs": false,
15+
"endOfLine": "auto"
16+
}

.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true,
4+
"editor.codeActionsOnSave": {
5+
"source.fixAll.eslint": "always",
6+
"source.addMissingImports": "always"
7+
},
8+
"[typescriptreact]": {
9+
"editor.defaultFormatter": "esbenp.prettier-vscode"
10+
}
11+
}

lib/canvas.ts

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ export const handleCanvasMouseDown = ({
7070
canvas.isDrawingMode = false;
7171

7272
// if target is the selected shape or active selection, set isDrawing to false
73-
if (
74-
target &&
75-
(target.type === selectedShapeRef.current ||
76-
target.type === "activeSelection")
77-
) {
73+
if (target && (target.type === selectedShapeRef.current || target.type === "activeSelection")) {
7874
isDrawing.current = false;
7975

8076
// set active object to target
@@ -89,10 +85,7 @@ export const handleCanvasMouseDown = ({
8985
isDrawing.current = true;
9086

9187
// create custom fabric object/shape and set it to shapeRef
92-
shapeRef.current = createSpecificShape(
93-
selectedShapeRef.current,
94-
pointer as any
95-
);
88+
shapeRef.current = createSpecificShape(selectedShapeRef.current, pointer as any);
9689

9790
// if shapeRef is not null, add it to canvas
9891
if (shapeRef.current) {
@@ -215,10 +208,7 @@ export const handleCanvasObjectModified = ({
215208
};
216209

217210
// update shape in storage when path is created when in freeform mode
218-
export const handlePathCreated = ({
219-
options,
220-
syncShapeInStorage,
221-
}: CanvasPathCreated) => {
211+
export const handlePathCreated = ({ options, syncShapeInStorage }: CanvasPathCreated) => {
222212
// get path object
223213
const path = options.path;
224214
if (!path) return;
@@ -233,11 +223,7 @@ export const handlePathCreated = ({
233223
};
234224

235225
// check how object is moving on canvas and restrict it to canvas boundaries
236-
export const handleCanvasObjectMoving = ({
237-
options,
238-
}: {
239-
options: fabric.IEvent;
240-
}) => {
226+
export const handleCanvasObjectMoving = ({ options }: { options: fabric.IEvent }) => {
241227
// get target object which is moving
242228
const target = options.target as fabric.Object;
243229

@@ -251,21 +237,15 @@ export const handleCanvasObjectMoving = ({
251237
if (target && target.left) {
252238
target.left = Math.max(
253239
0,
254-
Math.min(
255-
target.left,
256-
(canvas.width || 0) - (target.getScaledWidth() || target.width || 0)
257-
)
240+
Math.min(target.left, (canvas.width || 0) - (target.getScaledWidth() || target.width || 0))
258241
);
259242
}
260243

261244
// restrict object to canvas boundaries (vertical)
262245
if (target && target.top) {
263246
target.top = Math.max(
264247
0,
265-
Math.min(
266-
target.top,
267-
(canvas.height || 0) - (target.getScaledHeight() || target.height || 0)
268-
)
248+
Math.min(target.top, (canvas.height || 0) - (target.getScaledHeight() || target.height || 0))
269249
);
270250
}
271251
};
@@ -327,19 +307,15 @@ export const handleCanvasObjectScaling = ({
327307
? selectedElement?.height! * selectedElement?.scaleY
328308
: selectedElement?.height;
329309

330-
setElementAttributes((prev) => ({
310+
setElementAttributes(prev => ({
331311
...prev,
332312
width: scaledWidth?.toFixed(0).toString() || "",
333313
height: scaledHeight?.toFixed(0).toString() || "",
334314
}));
335315
};
336316

337317
// render canvas objects coming from storage on canvas
338-
export const renderCanvas = ({
339-
fabricRef,
340-
canvasObjects,
341-
activeObjectRef,
342-
}: RenderCanvas) => {
318+
export const renderCanvas = ({ fabricRef, canvasObjects, activeObjectRef }: RenderCanvas) => {
343319
// clear canvas
344320
fabricRef.current?.clear();
345321

@@ -357,7 +333,7 @@ export const renderCanvas = ({
357333
fabric.util.enlivenObjects(
358334
[objectData],
359335
(enlivenedObjects: fabric.Object[]) => {
360-
enlivenedObjects.forEach((enlivenedObj) => {
336+
enlivenedObjects.forEach(enlivenedObj => {
361337
// if element is active, keep it in active state so that it can be edited further
362338
if (activeObjectRef.current?.objectId === objectId) {
363339
fabricRef.current?.setActiveObject(enlivenedObj);

lib/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import jsPDF from "jspdf";
1+
import JsPDF from "jspdf";
22
import { twMerge } from "tailwind-merge";
33
import { type ClassValue, clsx } from "clsx";
44
import { COLORS } from "@/app/api/liveblocks/auth";
@@ -40,8 +40,7 @@ export function cn(...inputs: ClassValue[]) {
4040
}
4141

4242
export function generateRandomName(): string {
43-
const randomAdjective =
44-
adjectives[Math.floor(Math.random() * adjectives.length)];
43+
const randomAdjective = adjectives[Math.floor(Math.random() * adjectives.length)];
4544
const randomAnimal = animals[Math.floor(Math.random() * animals.length)];
4645

4746
return `${randomAdjective} ${randomAnimal}`;
@@ -120,7 +119,7 @@ export const exportToPdf = (fileName: string = DEFAULT_PDF_FILE_NAME) => {
120119
if (!canvas) return;
121120

122121
// use jspdf
123-
const doc = new jsPDF({
122+
const doc = new JsPDF({
124123
orientation: "landscape",
125124
unit: "px",
126125
format: [canvas.width, canvas.height],

0 commit comments

Comments
 (0)