diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..76add87 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..39d4adc --- /dev/null +++ b/.eslintrc @@ -0,0 +1,15 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint", "no-loops", "prettier"], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "prettier" + ], + "rules": { + "no-console": 1, + "no-loops/no-loops": 2 + } +} diff --git a/.eslintrc.json b/.eslintrc.json index 57791b5..39d4adc 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,7 @@ { "root": true, "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint", "prettier"], + "plugins": ["@typescript-eslint", "no-loops", "prettier"], "extends": [ "eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", @@ -9,10 +9,7 @@ "prettier" ], "rules": { - "@typescript-eslint/ban-ts-comment": 0, - "@typescript-eslint/no-var-requires": 0, - "@typescript-eslint/no-explicit-any": 0, - "no-async-promise-executor": 0, - "prettier/prettier": "error" + "no-console": 1, + "no-loops/no-loops": 2 } } diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 0000000..31354ec --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..36af219 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx lint-staged diff --git a/package.json b/package.json index ca1435c..ad6a9ff 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,11 @@ "description": "Earn credits while chatting! And more", "main": "src/index.ts", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "nodemon | pino-pretty -i pid,hostname -t yyyy-mm-dd HH:MM:s" + "test": "jest", + "start": "nodemon | pino-pretty -i pid,hostname -t yyyy-mm-dd HH:MM:s", + "prettier-format": "prettier \"src/**/*.ts\" --write", + "lint": "eslint . --ext .ts", + "prepare": "husky install" }, "keywords": [ "zyner", @@ -61,7 +64,14 @@ "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", + "eslint-plugin-no-loops": "^0.3.0", "eslint-plugin-prettier": "^4.0.0", + "husky": "^7.0.4", + "jest": "^27.5.1", + "lint-staged": "^12.3.7", "prettier": "^2.6.0" + }, + "lint-staged": { + "*.ts": "eslint --cache --fix" } } diff --git a/tsconfig.json b/tsconfig.json index 722bd83..39fe93e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { - "target": "es2019", - "lib": ["dom", "dom.iterable", "esnext"], + "target": "ES6", "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, @@ -9,8 +8,7 @@ "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, - "module": "commonjs", - "resolveJsonModule": true, + "moduleResolution": "node", "isolatedModules": true, "outDir": "./build", "baseUrl": "./src", @@ -31,4 +29,4 @@ }, "include": ["./src"], "exclude": ["./node_modules", "./test"] -} \ No newline at end of file +}