Files
OpenFrontIO/eslint.config.js
T
evanpelle 13b350513f Improve alliance UX, prevent hung alliance requests (#1868)
This PR does two things:

1. Allows you to send an alliance request to approve an existing
request, ex:
* player A sends req to player B
* now player B can send an ally request to player A, which accepts the
request from player A.

This way even if you lose or don't see the alliance notification, you
can still accept the alliance.

2. Have AllianceRequestExecution reject the request if not accepted or
rejected. There is a bug where sometimes the EventDisplay does not
trigger the delete() function, resulting in hung alliance requests. I
couldn't figure out why the delete() function is sometimes not called,
but I think it's better design to have core/ itself handle abandoned
alliance requests, this was UI bugs can't break the game state.

- [ ] I have added screenshots for all UI updates
- [ ] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [ ] I have added relevant tests to the test directory
- [ ] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

regression is found:

evan
2025-08-24 16:38:52 -04:00

186 lines
6.3 KiB
JavaScript

import eslintConfigPrettier from "eslint-config-prettier/flat";
import eslintPluginLocal from "./eslint-plugin-local/plugin.js";
import { fileURLToPath } from "node:url";
import globals from "globals";
import { includeIgnoreFile } from "@eslint/compat";
import jest from "eslint-plugin-jest";
import path from "node:path";
import pluginJs from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin";
import tseslint from "typescript-eslint";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, ".gitignore");
/** @type {import('eslint').Linter.Config[]} */
export default [
includeIgnoreFile(gitignorePath),
{ ignores: ["src/server/gatekeeper/**"] },
{ files: ["**/*.{js,mjs,cjs,ts}"] },
{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: [
"__mocks__/fileMock.js",
"eslint-plugin-local/plugin.js",
"eslint-plugin-local/rules/no-z-array.js",
"eslint.config.js",
"jest.config.ts",
"postcss.config.js",
"tailwind.config.js",
"webpack.config.js",
],
},
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
// Disable rules that would fail. The failures should be fixed, and the entries here removed.
"@typescript-eslint/no-unused-expressions": "off", // https://github.com/openfrontio/OpenFrontIO/issues/1790
"no-case-declarations": "off", // https://github.com/openfrontio/OpenFrontIO/issues/1791
},
},
{
plugins: {
"@stylistic": stylistic,
},
rules: {
// Enable rules
"@stylistic/quotes": ["error", "double", { avoidEscape: true }],
"@stylistic/indent": ["error", 2],
"@stylistic/semi": "error",
"@stylistic/space-infix-ops": "error",
"@stylistic/type-annotation-spacing": [
"error",
{
after: true,
before: true,
overrides: {
colon: {
before: false,
},
},
},
],
"@stylistic/eol-last": "error",
"@typescript-eslint/consistent-type-definitions": [
"error",
"type",
],
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-mixed-enums": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/prefer-as-const": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-literal-enum-member": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/prefer-readonly": "error",
"eqeqeq": "error",
"indent": "off", // @stylistic/indent
"sort-keys": "error",
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/no-unsafe-assignment": "error",
"@typescript-eslint/no-unsafe-member-access": "error",
// "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], // TODO: Enable this rule, https://github.com/openfrontio/OpenFrontIO/issues/1784
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/prefer-for-of": "error",
"array-bracket-newline": ["error", "consistent"],
"array-bracket-spacing": ["error", "never"],
"array-element-newline": ["error", "consistent"],
"arrow-parens": ["error", "always"],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": ["error", { before: false, after: true }],
"func-call-spacing": ["error", "never"],
"function-call-argument-newline": ["error", "consistent"],
"max-depth": ["error", { max: 5 }],
"max-len": ["error", { code: 120 }],
"max-lines": ["error", { max: 677, skipBlankLines: true, skipComments: true }],
"max-lines-per-function": ["error", { max: 561 }],
"no-loss-of-precision": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": ["error", { max: 1, maxEOF: 0 }],
"no-trailing-spaces": "error",
"object-curly-newline": ["error", { multiline: true, consistent: true }],
"object-curly-spacing": ["error", "always"],
"object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
"object-shorthand": ["error", "always"],
"no-undef": "error",
"no-unused-vars": "off", // @typescript-eslint/no-unused-vars
"prefer-destructuring": ["error", {
array: false,
object: true,
}],
"quote-props": ["error", "consistent-as-needed"],
"sort-imports": "error",
"space-before-blocks": ["error", "always"],
"space-before-function-paren": ["error", {
anonymous: "always",
named: "never",
asyncArrow: "always",
}],
"space-infix-ops": "off",
},
},
{
files: [
"**/*.config.{js,ts,jsx,tsx}",
"**/*.test.{js,ts,jsx,tsx}",
"tests/**/*.{js,ts,jsx,tsx}",
"eslint-plugin-local/**/*.{js,ts,jsx,tsx}",
],
rules: {
// Disabled rules for tests, configs
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"max-len": "off",
"sort-keys": "off",
},
},
{
languageOptions: {
globals: {
...globals.jest,
},
},
files: [
"**/*.test.{js,ts,jsx,tsx}",
"tests/**/*.{js,ts,jsx,tsx}",
],
plugins: ["jest"],
...jest.configs["flat/style"],
},
{
files: [
"src/client/**/*.{js,ts,jsx,tsx}",
],
rules: {
// Disabled rules for frontend
"sort-keys": "off",
},
},
{
plugins: {
local: eslintPluginLocal,
},
rules: {
"local/no-z-array": "error",
},
},
];