Skip to content

Commit 9f56a50

Browse files
committed
style: setup prettier and eslint
1 parent c4c8ecc commit 9f56a50

26 files changed

+994
-854
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

.eslintrc.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @type {import("eslint").Linter.Config}
3+
*/
4+
const config = {
5+
env: {
6+
node: true,
7+
},
8+
root: true,
9+
parser: "@typescript-eslint/parser",
10+
plugins: ["@typescript-eslint"],
11+
extends: [
12+
"eslint:recommended",
13+
"plugin:@typescript-eslint/eslint-recommended",
14+
"plugin:@typescript-eslint/recommended",
15+
"prettier",
16+
],
17+
rules: {
18+
"@typescript-eslint/no-explicit-any": "error",
19+
"@typescript-eslint/no-empty-interface": "error",
20+
"@typescript-eslint/no-non-null-assertion": "warn",
21+
"@typescript-eslint/no-unused-vars": [
22+
"warn",
23+
// { args: "none", argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
24+
],
25+
"no-console": ["warn"],
26+
},
27+
};
28+
module.exports = config;

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ tsconfig.lsif.json
1010
*.db
1111
.vscode/
1212
.env
13-
.pnpm-debug.log
13+
.pnpm-debug.log
14+
.eslintcache

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
pnpm format && pnpm lint

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 4,
4+
"semi": true,
5+
"singleQuote": false
6+
}

package.json

Lines changed: 79 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,83 @@
11
{
2-
"name": "codesync",
3-
"displayName": "Codesync",
4-
"publisher": "frixaco",
5-
"description": "Synchronize your code changes across your devices",
6-
"version": "0.0.1",
7-
"repository": {
8-
"type": "git",
9-
"url": "https://github.com/frixaco/codesync.git"
10-
},
11-
"engines": {
12-
"vscode": "^1.63.0"
13-
},
14-
"categories": [
15-
"Other"
16-
],
17-
"main": "./dist/main.js",
18-
"activationEvents": [
19-
"onView:codesync.webview",
20-
"onCommand:codesync.applyChanges",
21-
"onCommand:codesync.sendChanges"
22-
],
23-
"contributes": {
24-
"viewsContainers": {
25-
"activitybar": [
26-
{
27-
"id": "codesync-sidepanel-view",
28-
"title": "Codesync",
29-
"icon": "assets/logo.svg"
30-
}
31-
]
2+
"name": "codesync",
3+
"displayName": "Codesync",
4+
"publisher": "frixaco",
5+
"description": "Synchronize your code changes across your devices",
6+
"version": "0.0.1",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/frixaco/codesync.git"
3210
},
33-
"views": {
34-
"codesync-sidepanel-view": [
35-
{
36-
"type": "webview",
37-
"id": "codesync.webview",
38-
"name": "Codesync"
39-
}
40-
]
11+
"engines": {
12+
"vscode": "^1.63.0"
4113
},
42-
"commands": [
43-
{
44-
"command": "codesync.applyChanges",
45-
"title": "CodeSync: Apply changes from other device(s)"
46-
},
47-
{
48-
"command": "codesync.sendChanges",
49-
"title": "CodeSync: Send changes to other device(s)"
50-
}
51-
]
52-
},
53-
"scripts": {
54-
"vscode:prepublish": "npm run esbuild-base -- --minify",
55-
"build:base": "rm -rf dist/ && esbuild ./src/extension.ts --bundle --outfile=dist/main.js --external:vscode --format=cjs --platform=node",
56-
"build": "npm run build:base -- --sourcemap",
57-
"dev": "npm run build:base -- --sourcemap --watch",
58-
"test-compile": "tsc -p ./",
59-
"package": "npx vsce package"
60-
},
61-
"devDependencies": {
62-
"@types/glob": "^7.2.0",
63-
"@types/mocha": "^9.0.0",
64-
"@types/node": "14.x",
65-
"@types/vscode": "^1.63.0",
66-
"@typescript-eslint/eslint-plugin": "^5.9.1",
67-
"@typescript-eslint/parser": "^5.9.1",
68-
"@vscode/test-electron": "^2.0.3",
69-
"esbuild": "^0.14.34",
70-
"eslint": "^8.6.0",
71-
"glob": "^7.2.0",
72-
"mocha": "^9.1.3",
73-
"typescript": "^4.6.3"
74-
},
75-
"dependencies": {
76-
"axios": "^0.26.1"
77-
}
14+
"categories": [
15+
"Other"
16+
],
17+
"main": "./dist/main.js",
18+
"activationEvents": [
19+
"onView:codesync.webview",
20+
"onCommand:codesync.applyChanges",
21+
"onCommand:codesync.sendChanges"
22+
],
23+
"contributes": {
24+
"viewsContainers": {
25+
"activitybar": [
26+
{
27+
"id": "codesync-sidepanel-view",
28+
"title": "Codesync",
29+
"icon": "assets/logo.svg"
30+
}
31+
]
32+
},
33+
"views": {
34+
"codesync-sidepanel-view": [
35+
{
36+
"type": "webview",
37+
"id": "codesync.webview",
38+
"name": "Codesync"
39+
}
40+
]
41+
},
42+
"commands": [
43+
{
44+
"command": "codesync.applyChanges",
45+
"title": "CodeSync: Apply changes from other device(s)"
46+
},
47+
{
48+
"command": "codesync.sendChanges",
49+
"title": "CodeSync: Send changes to other device(s)"
50+
}
51+
]
52+
},
53+
"scripts": {
54+
"vscode:prepublish": "npm run esbuild-base -- --minify",
55+
"build:base": "rm -rf dist/ && esbuild ./src/extension.ts --bundle --outfile=dist/main.js --external:vscode --format=cjs --platform=node",
56+
"build": "npm run build:base -- --sourcemap",
57+
"dev": "npm run build:base -- --sourcemap --watch",
58+
"test-compile": "tsc -p ./",
59+
"package": "npx vsce package",
60+
"lint": "eslint . --fix --cache --ext .ts,.tsx",
61+
"format": "prettier --write \"**/*.{ts,tsx}\"",
62+
"prepare": "husky install"
63+
},
64+
"devDependencies": {
65+
"@types/glob": "^7.2.0",
66+
"@types/mocha": "^9.0.0",
67+
"@types/node": "14.x",
68+
"@types/vscode": "^1.63.0",
69+
"@typescript-eslint/eslint-plugin": "^5.21.0",
70+
"@typescript-eslint/parser": "^5.21.0",
71+
"@vscode/test-electron": "^2.0.3",
72+
"eslint-config-prettier": "^8.5.0",
73+
"esbuild": "^0.14.34",
74+
"eslint": "^8.14.0",
75+
"glob": "^7.2.0",
76+
"husky": "^8.0.1",
77+
"mocha": "^9.1.3",
78+
"typescript": "^4.6.4"
79+
},
80+
"dependencies": {
81+
"axios": "^0.26.1"
82+
}
7883
}

pnpm-lock.yaml

Lines changed: 23 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/db.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import { PrismaClient } from "@prisma/client";
22

33
const db = new PrismaClient();
44

5-
/**
6-
* Exclude keys from user
7-
*
8-
* ts```
9-
* const user = await prisma.user.findUnique({ where: 1 })
10-
* const userWithoutPassword = exclude(user, 'password')
11-
* ```
12-
*/
5+
/**
6+
* Exclude keys from user
7+
*
8+
* ts```
9+
* const user = await prisma.user.findUnique({ where: 1 })
10+
* const userWithoutPassword = exclude(user, 'password')
11+
* ```
12+
*/
1313
export function exclude<User, Key extends keyof User>(
14-
user: User,
15-
...keys: Key[]
14+
user: User,
15+
...keys: Key[]
1616
): Omit<User, Key> {
17-
for (let key of keys) {
18-
delete user[key]
19-
}
20-
return user
17+
for (const key of keys) {
18+
delete user[key];
19+
}
20+
return user;
2121
}
2222

2323
export default db;

0 commit comments

Comments
 (0)