Skip to content

Commit

Permalink
style: setup prettier and eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
frixaco committed May 26, 2022
1 parent c4c8ecc commit 9f56a50
Show file tree
Hide file tree
Showing 26 changed files with 994 additions and 854 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
28 changes: 28 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @type {import("eslint").Linter.Config}
*/
const config = {
env: {
node: true,
},
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
rules: {
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
// { args: "none", argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
"no-console": ["warn"],
},
};
module.exports = config;
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ tsconfig.lsif.json
*.db
.vscode/
.env
.pnpm-debug.log
.pnpm-debug.log
.eslintcache
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm format && pnpm lint
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": true,
"singleQuote": false
}
153 changes: 79 additions & 74 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,78 +1,83 @@
{
"name": "codesync",
"displayName": "Codesync",
"publisher": "frixaco",
"description": "Synchronize your code changes across your devices",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "https://github.com/frixaco/codesync.git"
},
"engines": {
"vscode": "^1.63.0"
},
"categories": [
"Other"
],
"main": "./dist/main.js",
"activationEvents": [
"onView:codesync.webview",
"onCommand:codesync.applyChanges",
"onCommand:codesync.sendChanges"
],
"contributes": {
"viewsContainers": {
"activitybar": [
{
"id": "codesync-sidepanel-view",
"title": "Codesync",
"icon": "assets/logo.svg"
}
]
"name": "codesync",
"displayName": "Codesync",
"publisher": "frixaco",
"description": "Synchronize your code changes across your devices",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "https://github.com/frixaco/codesync.git"
},
"views": {
"codesync-sidepanel-view": [
{
"type": "webview",
"id": "codesync.webview",
"name": "Codesync"
}
]
"engines": {
"vscode": "^1.63.0"
},
"commands": [
{
"command": "codesync.applyChanges",
"title": "CodeSync: Apply changes from other device(s)"
},
{
"command": "codesync.sendChanges",
"title": "CodeSync: Send changes to other device(s)"
}
]
},
"scripts": {
"vscode:prepublish": "npm run esbuild-base -- --minify",
"build:base": "rm -rf dist/ && esbuild ./src/extension.ts --bundle --outfile=dist/main.js --external:vscode --format=cjs --platform=node",
"build": "npm run build:base -- --sourcemap",
"dev": "npm run build:base -- --sourcemap --watch",
"test-compile": "tsc -p ./",
"package": "npx vsce package"
},
"devDependencies": {
"@types/glob": "^7.2.0",
"@types/mocha": "^9.0.0",
"@types/node": "14.x",
"@types/vscode": "^1.63.0",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"@vscode/test-electron": "^2.0.3",
"esbuild": "^0.14.34",
"eslint": "^8.6.0",
"glob": "^7.2.0",
"mocha": "^9.1.3",
"typescript": "^4.6.3"
},
"dependencies": {
"axios": "^0.26.1"
}
"categories": [
"Other"
],
"main": "./dist/main.js",
"activationEvents": [
"onView:codesync.webview",
"onCommand:codesync.applyChanges",
"onCommand:codesync.sendChanges"
],
"contributes": {
"viewsContainers": {
"activitybar": [
{
"id": "codesync-sidepanel-view",
"title": "Codesync",
"icon": "assets/logo.svg"
}
]
},
"views": {
"codesync-sidepanel-view": [
{
"type": "webview",
"id": "codesync.webview",
"name": "Codesync"
}
]
},
"commands": [
{
"command": "codesync.applyChanges",
"title": "CodeSync: Apply changes from other device(s)"
},
{
"command": "codesync.sendChanges",
"title": "CodeSync: Send changes to other device(s)"
}
]
},
"scripts": {
"vscode:prepublish": "npm run esbuild-base -- --minify",
"build:base": "rm -rf dist/ && esbuild ./src/extension.ts --bundle --outfile=dist/main.js --external:vscode --format=cjs --platform=node",
"build": "npm run build:base -- --sourcemap",
"dev": "npm run build:base -- --sourcemap --watch",
"test-compile": "tsc -p ./",
"package": "npx vsce package",
"lint": "eslint . --fix --cache --ext .ts,.tsx",
"format": "prettier --write \"**/*.{ts,tsx}\"",
"prepare": "husky install"
},
"devDependencies": {
"@types/glob": "^7.2.0",
"@types/mocha": "^9.0.0",
"@types/node": "14.x",
"@types/vscode": "^1.63.0",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"@vscode/test-electron": "^2.0.3",
"eslint-config-prettier": "^8.5.0",
"esbuild": "^0.14.34",
"eslint": "^8.14.0",
"glob": "^7.2.0",
"husky": "^8.0.1",
"mocha": "^9.1.3",
"typescript": "^4.6.4"
},
"dependencies": {
"axios": "^0.26.1"
}
}
27 changes: 23 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions server/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import { PrismaClient } from "@prisma/client";

const db = new PrismaClient();

/**
* Exclude keys from user
*
* ts```
* const user = await prisma.user.findUnique({ where: 1 })
* const userWithoutPassword = exclude(user, 'password')
* ```
*/
/**
* Exclude keys from user
*
* ts```
* const user = await prisma.user.findUnique({ where: 1 })
* const userWithoutPassword = exclude(user, 'password')
* ```
*/
export function exclude<User, Key extends keyof User>(
user: User,
...keys: Key[]
user: User,
...keys: Key[]
): Omit<User, Key> {
for (let key of keys) {
delete user[key]
}
return user
for (const key of keys) {
delete user[key];
}
return user;
}

export default db;
Loading

0 comments on commit 9f56a50

Please sign in to comment.