diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..0fee632 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,27 @@ +module.exports = { + env: { + node: true, + }, + // Specify the parser for TypeScript + parser: "@typescript-eslint/parser", + parserOptions: { + ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features + sourceType: "module", // Allows for the use of imports + }, + // existing ESLint configuration + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended", // Adds the Prettier plugin + ], + plugins: ['@typescript-eslint', 'prettier'], + rules: { + "prettier/prettier": "error", // Displays Prettier errors as ESLint errors + prefer_const: "warn", // prefers using "const" for variables that are not reassigned + no_var: "error", // disallows the use of "var", must use "let" or "const" only + + // TS rules + "@typescript-eslint/no-explicit-any": "warn", // Warns when using "any" type + "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], // warns against any used variables except those prefixed with "_" + }, +}; diff --git a/package.json b/package.json index 2bd06fb..b65212e 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,20 @@ { + "license": "AGPL-3.0-or-later", "devDependencies": { + "@eslint/js": "^9.13.0", "@types/uuid": "^9.0.8", + "@typescript-eslint/eslint-plugin": "^8.11.0", + "@typescript-eslint/parser": "^8.11.0", + "eslint": "^9.13.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.2.1", + "globals": "^15.11.0", + "husky": "^9.1.6", + "lint-staged": "^15.2.10", + "prettier": "^3.3.3", "ts-node": "^10.9.2", - "typescript": "^5.4.2" + "typescript": "^5.4.2", + "typescript-eslint": "^8.11.0" }, "dependencies": { "@typegoose/typegoose": "^12.2.0", @@ -11,5 +23,21 @@ "stripe": "^14.21.0", "typeorm": "^0.3.20", "uuid": "^9.0.1" + }, + "scripts": { + "prepare": "husky", + "lint": "eslint . --ext .js,.jsx,.ts,.tsx", + "lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix", + "format": "prettier --write .", + "test": "" + }, + "lint-staged": { + "*.{js,jsx,ts,tsx}": [ + "eslint --fix", + "prettier --write" + ], + "*.{json,css,scss,md}": [ + "prettier --write" + ] } }