1
mirror of https://github.com/thepeacockproject/Peacock synced 2024-11-22 22:12:45 +01:00

refactor: migrate to eslint flat config

This commit is contained in:
Reece Dunham 2024-06-11 16:49:14 -04:00
parent 0df8e782c5
commit e0f9e9212b
9 changed files with 496 additions and 508 deletions

View File

@ -1,11 +0,0 @@
packaging
*.d.ts
build
.eslintrc.js
chunk*.js
chunk*.mjs
webui/dist
*.plugin.js
*Plugin.js
packaging/livesplit-node-client/build
tests/testData/scripts

View File

@ -1,101 +0,0 @@
/*
* The Peacock Project - a HITMAN server replacement.
* Copyright (C) 2021-2024 The Peacock Project Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module.exports = {
env: {
node: true,
es2021: true,
},
plugins: [
"@typescript-eslint",
"promise",
"react-hooks",
"@peacockproject",
],
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "es2022",
sourceType: "module",
project: [
// server full
"./tsconfig.json",
// plugins
"./plugins/tsconfig.json",
// web UI
"./webui/tsconfig.json",
// tests
"./tests/tsconfig.json",
],
},
rules: {
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/require-await": "warn",
"@typescript-eslint/prefer-ts-expect-error": "error",
"no-nested-ternary": "warn",
eqeqeq: "error",
"no-duplicate-imports": "warn",
"promise/always-return": "error",
"promise/no-return-wrap": "error",
"promise/param-names": "error",
"promise/catch-or-return": "error",
"promise/no-native": "off",
"promise/no-nesting": "warn",
"promise/no-promise-in-callback": "warn",
"promise/no-callback-in-promise": "warn",
"promise/avoid-new": "off",
"promise/no-new-statics": "error",
"promise/no-return-in-finally": "warn",
"promise/valid-params": "warn",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"@peacockproject/import-components": "error",
"padding-line-between-statements": [
"error",
{
blankLine: "always",
prev: "block-like",
next: "*",
},
{
blankLine: "always",
prev: "*",
next: "block-like",
},
{
blankLine: "never",
prev: "block-like",
next: "case",
},
{
blankLine: "never",
prev: "case",
next: "block-like",
},
],
"spaced-comment": [
"error",
"always",
{ markers: ["*", "@__NOINLINE__"] },
],
},
reportUnusedDisableDirectives: true,
}

View File

@ -264,7 +264,6 @@ export class HitsCategoryService {
)
break
default:
// eslint-disable-next-line no-extra-semi
;(isPeacock ? contracts : nEscalations).push(id)
}
}

View File

@ -218,7 +218,7 @@ multiplayerRouter.post(
(req: RequestWithJwt, res) => {
const match = activeMatches.get(req.body.matchId)
if (!(match && match.Players.includes(req.jwt.unique_name))) {
if (!match?.Players.includes(req.jwt.unique_name)) {
res.status(404).end()
return
}

129
eslint.config.cjs Normal file
View File

@ -0,0 +1,129 @@
const typescriptEslint = require("@typescript-eslint/eslint-plugin")
const promise = require("eslint-plugin-promise")
const reactHooks = require("eslint-plugin-react-hooks")
const peacockproject = require("@peacockproject/eslint-plugin")
const { fixupPluginRules } = require("@eslint/compat")
const globals = require("globals")
const tsParser = require("@typescript-eslint/parser")
const js = require("@eslint/js")
const { FlatCompat } = require("@eslint/eslintrc")
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})
module.exports = [
{
ignores: [
"packaging",
"**/*.d.ts",
".yarn",
"build",
"**/chunk*.js",
"**/chunk*.mjs",
"webui/dist",
"**/*.plugin.js",
"**/*Plugin.js",
"tests/testData/scripts",
"eslint.config.cjs",
"resources",
],
},
...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
),
{
plugins: {
"@typescript-eslint": typescriptEslint,
promise,
"react-hooks": fixupPluginRules(reactHooks),
"@peacockproject": peacockproject,
},
linterOptions: {
reportUnusedDisableDirectives: true,
},
languageOptions: {
globals: {
...globals.node,
},
parser: tsParser,
ecmaVersion: 22,
sourceType: "module",
parserOptions: {
project: [
"./tsconfig.json",
"./plugins/tsconfig.json",
"./webui/tsconfig.json",
"./tests/tsconfig.json",
],
},
},
rules: {
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/require-await": "warn",
"@typescript-eslint/prefer-ts-expect-error": "error",
"no-nested-ternary": "warn",
eqeqeq: "error",
"no-duplicate-imports": "warn",
"promise/always-return": "error",
"promise/no-return-wrap": "error",
"promise/param-names": "error",
"promise/catch-or-return": "error",
"promise/no-native": "off",
"promise/no-nesting": "warn",
"promise/no-promise-in-callback": "warn",
"promise/no-callback-in-promise": "warn",
"promise/avoid-new": "off",
"promise/no-new-statics": "error",
"promise/no-return-in-finally": "warn",
"promise/valid-params": "warn",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"@peacockproject/import-components": "error",
"padding-line-between-statements": [
"error",
{
blankLine: "always",
prev: "block-like",
next: "*",
},
{
blankLine: "always",
prev: "*",
next: "block-like",
},
{
blankLine: "never",
prev: "block-like",
next: "case",
},
{
blankLine: "never",
prev: "case",
next: "block-like",
},
],
"spaced-comment": [
"error",
"always",
{
markers: ["*", "@__NOINLINE__"],
},
],
},
},
]

View File

@ -35,13 +35,13 @@
},
"dependencies": {
"@peacockproject/statemachine-parser": "^5.9.3",
"@yarnpkg/fslib": "^3.0.1",
"@yarnpkg/libzip": "^3.0.0",
"axios": "^1.6.8",
"@yarnpkg/fslib": "^3.1.0",
"@yarnpkg/libzip": "^3.1.0",
"axios": "^1.7.2",
"body-parser": "*",
"clipanion": "^4.0.0-rc.3",
"commander": "^11.1.0",
"deepmerge-ts": "^5.1.0",
"commander": "^12.1.0",
"deepmerge-ts": "^7.0.3",
"esbuild-wasm": "^0.20.2",
"express": "patch:express@npm%3A4.18.2#~/.yarn/patches/express-npm-4.18.2-bb15ff679a.patch",
"jest-diff": "^29.7.0",
@ -49,44 +49,48 @@
"json5": "^2.2.3",
"jsonwebtoken": "^9.0.2",
"md5-file": "^5.0.0",
"msgpackr": "^1.10.1",
"nanoid": "^5.0.6",
"msgpackr": "^1.10.2",
"nanoid": "^5.0.7",
"parseurl": "^1.3.3",
"picocolors": "patch:picocolors@npm%3A1.0.0#~/.yarn/patches/picocolors-npm-1.0.0-d81e0b1927.patch",
"progress": "^2.0.3",
"prompts": "^2.4.2",
"random": "^4.1.0",
"semver": "^7.6.0",
"semver": "^7.6.2",
"send": "0.18.0",
"serve-static": "^1.15.0",
"tapable": "^2.2.1"
},
"devDependencies": {
"@eslint/compat": "^1.0.3",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.4.0",
"@peacockproject/eslint-plugin": "workspace:*",
"@rdil/parallel-prettier": "^3.0.0",
"@types/express": "^4.17.20",
"@types/jsonwebtoken": "^9.0.6",
"@types/node": "^20",
"@types/parseurl": "^1.3.2",
"@types/progress": "^2.0.6",
"@types/parseurl": "^1.3.3",
"@types/progress": "^2.0.7",
"@types/prompts": "^2.4.7",
"@types/semver": "^7",
"@types/send": "^0.17.3",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"esbuild": "^0.20.2",
"esbuild-register": "^3.5.0",
"eslint": "^8.56.0",
"eslint": "^9.4.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-promise": "^6.2.0",
"eslint-plugin-react-hooks": "^4.6.2",
"fast-glob": "^3.3.2",
"globals": "^15.4.0",
"json-keys-sort": "^2.1.0",
"ms": "^2.1.3",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"terser": "^5.30.2",
"typescript": "5.4.3",
"prettier": "^3.3.2",
"rimraf": "^5.0.7",
"terser": "^5.31.1",
"typescript": "5.4.5",
"winston": "^3.13.0",
"winston-daily-rotate-file": "^5.0.0"
},

View File

@ -2,6 +2,6 @@
"name": "@peacockproject/eslint-plugin",
"private": true,
"peerDependencies": {
"eslint": "8.x"
"eslint": "9.x"
}
}

View File

@ -5,14 +5,14 @@
"type": "module",
"dependencies": {
"@radix-ui/react-alert-dialog": "^1.0.5",
"axios": "^1.6.8",
"clsx": "^2.1.0",
"immer": "^10.0.4",
"axios": "^1.7.2",
"clsx": "^2.1.1",
"immer": "^10.1.1",
"infima": "0.2.0-alpha.38",
"json-keys-sort": "^2.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.23.1",
"swr": "^2.2.5"
},
"scripts": {
@ -23,11 +23,11 @@
"typecheck-ws": "tsc"
},
"devDependencies": {
"@types/react": "^18.2.74",
"@types/react-dom": "^18.2.23",
"rollup-plugin-license": "^3.3.1",
"typescript": "5.4.3",
"vite": "^5.2.7"
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"rollup-plugin-license": "^3.4.0",
"typescript": "5.4.5",
"vite": "^5.2.13"
},
"peerDependencies": {
"rollup": "*"

694
yarn.lock

File diff suppressed because it is too large Load Diff