diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 15a75b0e..00000000 --- a/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -node_modules -dist -README.md -COPYING -src/webrtc -scripts/ -assets \ No newline at end of file diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 40eac134..00000000 --- a/.eslintrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint"], - "root": true, - "rules": { - "no-mixed-spaces-and-tabs": "off", - "@typescript-eslint/no-inferrable-types": "off", // Required by typeorm - "@typescript-eslint/no-var-requires": "off" // Sometimes requred by typeorm to resolve circular deps - }, - "env": { - "node": true - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..a4209123 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,45 @@ +import typescriptEslint from "@typescript-eslint/eslint-plugin"; +import globals from "globals"; +import tsParser from "@typescript-eslint/parser"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [{ + ignores: [ + "**/node_modules", + "**/dist", + "**/README.md", + "**/COPYING", + "src/webrtc", + "**/scripts/", + "**/assets", + ], +}, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), { + plugins: { + "@typescript-eslint": typescriptEslint, + }, + + languageOptions: { + globals: { + ...globals.node, + }, + + parser: tsParser, + }, + + rules: { + "no-mixed-spaces-and-tabs": "off", + "@typescript-eslint/no-inferrable-types": "off", // Required by typeorm + "@typescript-eslint/no-var-requires": "off", // Sometimes requred by typeorm to resolve circular deps + }, +}]; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9d91c0e6..7ea21c4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,6 +53,8 @@ "ws": "^8.18.0" }, "devDependencies": { + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.14.0", "@types/amqplib": "^0.10.5", "@types/bcrypt": "^5.0.2", "@types/body-parser": "^1.19.5", @@ -76,6 +78,7 @@ "@typescript-eslint/parser": "^8.12.2", "eslint": "^9.13.0", "express": "^4.21.1", + "globals": "^15.12.0", "husky": "^9.1.6", "prettier": "^3.3.3", "pretty-quick": "^4.0.0", @@ -1202,7 +1205,6 @@ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", "dev": true, - "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", @@ -1249,6 +1251,18 @@ "concat-map": "0.0.1" } }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -1270,11 +1284,10 @@ } }, "node_modules/@eslint/js": { - "version": "9.13.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.13.0.tgz", - "integrity": "sha512-IFLyoY4d72Z5y/6o/BazFBezupzI/taV8sGumxTAVw3lXG9A6md1Dc34T9s1FoD/an9pJH8RHbAxsaEbBed9lA==", + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", + "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", "dev": true, - "license": "MIT", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } @@ -5878,6 +5891,15 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint/node_modules/@eslint/js": { + "version": "9.13.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.13.0.tgz", + "integrity": "sha512-IFLyoY4d72Z5y/6o/BazFBezupzI/taV8sGumxTAVw3lXG9A6md1Dc34T9s1FoD/an9pJH8RHbAxsaEbBed9lA==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/eslint/node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -6735,11 +6757,10 @@ } }, "node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "version": "15.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.12.0.tgz", + "integrity": "sha512-1+gLErljJFhbOVyaetcwJiJ4+eLe45S2E7P5UiZ9xGfeq3ATQf5DOv9G7MH3gGbKQLkzmNh2DxfZwLdw+j6oTQ==", "dev": true, - "license": "MIT", "engines": { "node": ">=18" }, diff --git a/package.json b/package.json index b87dc6fc..c2f3536d 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,8 @@ }, "homepage": "https://spacebar.chat", "devDependencies": { + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.14.0", "@types/amqplib": "^0.10.5", "@types/bcrypt": "^5.0.2", "@types/body-parser": "^1.19.5", @@ -61,6 +63,7 @@ "@typescript-eslint/parser": "^8.12.2", "eslint": "^9.13.0", "express": "^4.21.1", + "globals": "^15.12.0", "husky": "^9.1.6", "prettier": "^3.3.3", "pretty-quick": "^4.0.0",