Skip to content

Commit 87dba60

Browse files
committed
eslint: Fixed ignore patterns to limit scope properly and autofixed most available
fix: Remaining linting issues fix: Reimplement FPFSS auth requests from backend ext
1 parent c0d64a7 commit 87dba60

20 files changed

+221
-2211
lines changed

eslint.config.mjs

Lines changed: 112 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,129 @@
11
// @ts-check
22

33
import eslint from '@eslint/js';
4-
import tseslint from 'typescript-eslint';
5-
import react from 'eslint-plugin-react';
64
import stylistic from '@stylistic/eslint-plugin';
7-
import globals from 'globals';
5+
import react from 'eslint-plugin-react';
86
import reactHooks from 'eslint-plugin-react-hooks';
7+
import globals from 'globals';
8+
import tseslint from 'typescript-eslint';
99

1010
export default tseslint.config(
1111
eslint.configs.recommended,
1212
...tseslint.configs.recommended,
1313
{
14-
ignores: ['**/*.js']
14+
ignores: ['dist/**', 'website/**', 'build/**', 'extern/**', 'extensions/**', './**.mjs', './**.js']
1515
},
1616
{
17-
files: ['**/*.{ts,tsx}'],
18-
plugins: {
19-
react,
20-
'@stylistic': stylistic,
21-
},
22-
settings: {
23-
react: {
24-
version: '17'
25-
}
26-
},
27-
languageOptions: {
28-
parserOptions: {
29-
ecmaFeatures: {
30-
jsx: true,
31-
},
32-
},
33-
globals: {
34-
...globals.browser,
17+
files: ['**/*.{ts,tsx}'],
18+
plugins: {
19+
react,
20+
'@stylistic': stylistic,
21+
},
22+
settings: {
23+
react: {
24+
version: '17'
25+
}
26+
},
27+
languageOptions: {
28+
parserOptions: {
29+
ecmaFeatures: {
30+
jsx: true,
3531
},
3632
},
37-
rules: {
38-
"@stylistic/object-curly-spacing": ["warn", "always"],
39-
"@typescript-eslint/adjacent-overload-signatures": "off",
40-
"@typescript-eslint/explicit-function-return-type": "off",
41-
"@typescript-eslint/explicit-module-boundary-types": "off",
42-
"@stylistic/indent": ["error", 2, {
43-
"MemberExpression": 0,
44-
"SwitchCase": 1
45-
}],
46-
"@typescript-eslint/no-empty-function": ["error", { "allow": ["arrowFunctions"] }],
47-
"@typescript-eslint/no-explicit-any": "off",
48-
"@typescript-eslint/no-invalid-void-type": ["error", { "allowInGenericTypeArguments": true }],
49-
"@typescript-eslint/no-namespace": "off",
50-
"@typescript-eslint/no-unused-vars": ["error", {
51-
"vars": "all",
52-
"caughtErrors": "none",
53-
"args": "none"
54-
}],
55-
"@typescript-eslint/no-use-before-define": "off",
56-
"@typescript-eslint/prefer-interface": "off",
57-
//"react/no-access-state-in-setstate": "error", (requires restructuring of "app.tsx")
58-
"react/no-direct-mutation-state": "error",
59-
"react/no-render-return-value": "error",
60-
"react/no-string-refs": "error",
61-
"react/no-unescaped-entities": ["error", {"forbid": [{
62-
"char": ">",
63-
"alternatives": [">"]
64-
}, {
65-
"char": "}",
66-
"alternatives": ["}"]
67-
}]}],
68-
"react/no-unused-prop-types": "error",
69-
"react/no-unused-state": "error",
70-
"curly": ["error", "all"],
71-
"eol-last": "error",
72-
"for-direction": "error",
73-
"getter-return": "error",
74-
"keyword-spacing": "error",
75-
"no-compare-neg-zero": "error",
76-
"no-cond-assign": "error",
77-
"no-constant-condition": ["error", { "checkLoops": false }],
78-
"no-control-regex": "off",
79-
"no-debugger": "error",
80-
"no-delete-var": "error",
81-
"no-dupe-args": "error",
82-
"no-dupe-keys": "error",
83-
"no-duplicate-case": "error",
84-
"no-empty": "error",
85-
"no-empty-character-class": "error",
86-
"no-empty-pattern": "error",
87-
"no-ex-assign": "error",
88-
"no-extra-boolean-cast": "error",
89-
"no-extra-semi": "error",
90-
"no-func-assign": "error",
91-
"no-global-assign": "error",
92-
"no-inner-declarations": "off",
93-
"no-invalid-regexp": "error",
94-
"no-irregular-whitespace": "error",
95-
"no-mixed-spaces-and-tabs": "error",
96-
"no-obj-calls": "error",
97-
"no-octal": "error",
98-
"no-prototype-builtins": "error",
99-
"no-redeclare": "off",
100-
"@typescript-eslint/no-redeclare": "error",
101-
"no-regex-spaces": "error",
102-
"no-self-assign": "error",
103-
"no-shadow-restricted-names": "error",
104-
"no-spaced-func": "error",
105-
"no-sparse-arrays": "error",
106-
"no-trailing-spaces": "error",
107-
"no-unexpected-multiline": "error",
108-
"no-unreachable": "error",
109-
"no-unsafe-finally": "error",
110-
"no-unsafe-negation": "error",
111-
"no-unused-labels": "error",
112-
"no-useless-catch": "error",
113-
"no-useless-escape": "error",
114-
"no-whitespace-before-property": "error",
115-
"no-with": "error",
116-
"quotes": ["error", "single"],
117-
//"require-atomic-updates": "error", (requires restructuring of "recursiveDirectory()")
118-
"semi": ["error", "always"],
119-
"space-before-blocks": "error",
120-
"space-unary-ops": "error",
121-
"spaced-comment": "error",
122-
"use-isnan": "error",
123-
"valid-typeof": "error",
124-
"wrap-iife": "error",
125-
"yoda": "error",
126-
}
33+
globals: {
34+
...globals.browser,
35+
},
36+
},
37+
rules: {
38+
"@stylistic/object-curly-spacing": ["warn", "always"],
39+
"@typescript-eslint/adjacent-overload-signatures": "off",
40+
"@typescript-eslint/explicit-function-return-type": "off",
41+
"@typescript-eslint/explicit-module-boundary-types": "off",
42+
"@stylistic/indent": ["error", 2, {
43+
"MemberExpression": 0,
44+
"SwitchCase": 1
45+
}],
46+
"@typescript-eslint/no-empty-function": ["error", { "allow": ["arrowFunctions"] }],
47+
"@typescript-eslint/no-explicit-any": "off",
48+
"@typescript-eslint/no-invalid-void-type": ["error", { "allowInGenericTypeArguments": true }],
49+
"@typescript-eslint/no-namespace": "off",
50+
"@typescript-eslint/no-unused-vars": ["error", {
51+
"vars": "all",
52+
"caughtErrors": "none",
53+
"args": "none"
54+
}],
55+
"@typescript-eslint/no-use-before-define": "off",
56+
"@typescript-eslint/prefer-interface": "off",
57+
//"react/no-access-state-in-setstate": "error", (requires restructuring of "app.tsx")
58+
"react/no-direct-mutation-state": "error",
59+
"react/no-render-return-value": "error",
60+
"react/no-string-refs": "error",
61+
"react/no-unescaped-entities": ["error", {"forbid": [{
62+
"char": ">",
63+
"alternatives": [">"]
64+
}, {
65+
"char": "}",
66+
"alternatives": ["}"]
67+
}]}],
68+
"react/no-unused-prop-types": "error",
69+
"react/no-unused-state": "error",
70+
"curly": ["error", "all"],
71+
"eol-last": "error",
72+
"for-direction": "error",
73+
"getter-return": "error",
74+
"keyword-spacing": "error",
75+
"no-compare-neg-zero": "error",
76+
"no-cond-assign": "error",
77+
"no-constant-condition": ["error", { "checkLoops": false }],
78+
"no-control-regex": "off",
79+
"no-debugger": "error",
80+
"no-delete-var": "error",
81+
"no-dupe-args": "error",
82+
"no-dupe-keys": "error",
83+
"no-duplicate-case": "error",
84+
"no-empty": "error",
85+
"no-empty-character-class": "error",
86+
"no-empty-pattern": "error",
87+
"no-ex-assign": "error",
88+
"no-extra-boolean-cast": "error",
89+
"no-extra-semi": "error",
90+
"no-func-assign": "error",
91+
"no-global-assign": "error",
92+
"no-inner-declarations": "off",
93+
"no-invalid-regexp": "error",
94+
"no-irregular-whitespace": "error",
95+
"no-mixed-spaces-and-tabs": "error",
96+
"no-obj-calls": "error",
97+
"no-octal": "error",
98+
"no-prototype-builtins": "error",
99+
"no-redeclare": "off",
100+
"@typescript-eslint/no-redeclare": "error",
101+
"no-regex-spaces": "error",
102+
"no-self-assign": "error",
103+
"no-shadow-restricted-names": "error",
104+
"no-spaced-func": "error",
105+
"no-sparse-arrays": "error",
106+
"no-trailing-spaces": "error",
107+
"no-unexpected-multiline": "error",
108+
"no-unreachable": "error",
109+
"no-unsafe-finally": "error",
110+
"no-unsafe-negation": "error",
111+
"no-unused-labels": "error",
112+
"no-useless-catch": "error",
113+
"no-useless-escape": "error",
114+
"no-whitespace-before-property": "error",
115+
"no-with": "error",
116+
"quotes": ["error", "single"],
117+
//"require-atomic-updates": "error", (requires restructuring of "recursiveDirectory()")
118+
"semi": ["error", "always"],
119+
"space-before-blocks": "error",
120+
"space-unary-ops": "error",
121+
"spaced-comment": "error",
122+
"use-isnan": "error",
123+
"valid-typeof": "error",
124+
"wrap-iife": "error",
125+
"yoda": "error",
126+
}
127127
},
128128
reactHooks.configs.flat['recommended-latest'],
129129
);

src/back/dns.ts

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,7 @@
1-
import * as https from 'node:https';
2-
import * as dns from 'node:dns';
3-
import * as dnsPacket from 'dns-packet';
41
import _axios from 'axios';
5-
import { Agent } from 'node:https';
6-
7-
let id = 0;
8-
9-
function getId(): number {
10-
id += 1;
11-
if (id >= 65535) {
12-
id = 0;
13-
}
14-
15-
return id;
16-
}
17-
18-
type DnsResult = {
19-
address: string;
20-
family: number;
21-
expiry: number;
22-
}
23-
24-
const dnsCache = new Map<string, DnsResult>;
25-
26-
const lookup = (
27-
hostname: string,
28-
options: dns.LookupOptions,
29-
callback: (err: NodeJS.ErrnoException | null, address: string | dns.LookupAddress[], family?: number
30-
) => void): void => {
31-
// Check DNS cache first
32-
const cachedResult = dnsCache.get(hostname);
33-
if (cachedResult && cachedResult.expiry > Date.now()) {
34-
callback(null, cachedResult.address, cachedResult.family);
35-
return;
36-
}
37-
38-
const buf = dnsPacket.encode({
39-
type: 'query',
40-
id: getId(),
41-
flags: dnsPacket.RECURSION_DESIRED,
42-
questions: [{
43-
type: 'A',
44-
name: hostname
45-
}]
46-
});
47-
48-
const reqOpts = {
49-
hostname: 'cloudflare-dns.com',
50-
port: 443,
51-
path: '/dns-query',
52-
method: 'POST',
53-
headers: {
54-
'Content-Type': 'application/dns-message',
55-
'Content-Length': Buffer.byteLength(buf)
56-
}
57-
}
58-
59-
const request = https.request(reqOpts, (response) => {
60-
response.on('data', (d) => {
61-
const result = dnsPacket.decode(d);
62-
if (result.answers && result.answers.length > 0) {
63-
const answer: any = result.answers[0];
64-
dnsCache.set(hostname, {
65-
address: answer.data,
66-
family: 4,
67-
expiry: Date.now() + (answer.ttl * 1000)
68-
});
69-
callback(null, answer.data, 4);
70-
} else {
71-
callback(new Error('No answers in DNS response'), '', 0);
72-
}
73-
})
74-
})
75-
76-
77-
request.on('error', (e) => {
78-
console.error(e);
79-
callback(e, '', 0);
80-
})
81-
request.write(buf)
82-
request.end()
83-
}
84-
85-
const agent = new Agent({
86-
lookup
87-
});
882

893
export const axios = _axios.create({
904
headers: {
915
'User-Agent': 'Flashpoint Launcher'
926
}
93-
})
7+
});

src/back/extensions/ApiEmitter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export class ApiEmitter<T> implements ApiEmitterFirable<T> {
7272
} else {
7373
log.error('Launcher', `API Event Error: ${e.message || e.toString()}`);
7474
}
75-
onError && onError(e, listener.name);
75+
if (onError) {
76+
onError(e, listener.name);
77+
}
7678
}
7779
}
7880
}

src/back/util/EventAggregator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AnyFunction, ArgumentTypesOf } from '@shared/interfaces';
22
import { shallowStrictEquals } from '@shared/Util';
33

44
/** A callable object that has the same argument types as T (and void as the return type). */
5-
interface CallableCopy<T extends AnyFunction> extends Function {
5+
interface CallableCopy<T extends AnyFunction> {
66
(...args: ArgumentTypesOf<T>): void;
77
}
88

0 commit comments

Comments
 (0)