mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
eslint: enable extra rules
no-implicit-coercion, no-extra-boolean-cast, no-invalid-this, logical-assignment-operators, no-unmodified-loop-condition
This commit is contained in:
1 parent
5ac9d930b2
commit
7f51df236a
34 files changed
+100
-96
No files matched your search
@@ -16,7 +16,7 @@ export default async function readYamlCases(cfg: Record<string, any> = {}, check
|
||||
if (!cfg.checker.includes('.')) {
|
||||
config.checker = findFileSync(`@hydrooj/hydrojudge/vendor/testlib/checkers/${cfg.checker}.cpp`, false);
|
||||
}
|
||||
if (!config.checker) config.checker = checkFile(cfg.checker, 'Cannot find checker {0}.');
|
||||
config.checker ||= checkFile(cfg.checker, 'Cannot find checker {0}.');
|
||||
}
|
||||
if (cfg.interactor) config.interactor = checkFile(cfg.interactor, 'Cannot find interactor {0}.');
|
||||
if (cfg.validator) config.validator = checkFile(cfg.validator, 'Cannot find validator {0}.');
|
||||
|
||||
@@ -28,23 +28,21 @@ String.random = function random(digit = 32, dict = defaultDict) {
|
||||
return str;
|
||||
};
|
||||
|
||||
if (!String.prototype.format) {
|
||||
String.prototype.format = function formatStr(...args) {
|
||||
let result = this;
|
||||
if (args.length) {
|
||||
if (args.length === 1 && typeof args[0] === 'object') {
|
||||
const t = args[0];
|
||||
for (const key in t) {
|
||||
if (!key.startsWith('_') && t[key] !== undefined) {
|
||||
const reg = new RegExp(`(\\{${key}\\})`, 'g');
|
||||
result = result.replace(reg, t[key]);
|
||||
}
|
||||
String.prototype.format ||= function formatStr(...args) {
|
||||
let result = this;
|
||||
if (args.length) {
|
||||
if (args.length === 1 && typeof args[0] === 'object') {
|
||||
const t = args[0];
|
||||
for (const key in t) {
|
||||
if (!key.startsWith('_') && t[key] !== undefined) {
|
||||
const reg = new RegExp(`(\\{${key}\\})`, 'g');
|
||||
result = result.replace(reg, t[key]);
|
||||
}
|
||||
} else return this.formatFromArray(args);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
}
|
||||
} else return this.formatFromArray(args);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
String.prototype.formatFromArray = function formatStr(args) {
|
||||
let result = this;
|
||||
|
||||
@@ -34,13 +34,13 @@ export function parseLang(config: string): Record<string, LangConfig> {
|
||||
}
|
||||
for (const key in file) {
|
||||
const entry = file[key];
|
||||
entry.highlight = entry.highlight || key;
|
||||
entry.monaco = entry.monaco || entry.highlight;
|
||||
entry.time_limit_rate = entry.time_limit_rate || 1;
|
||||
entry.code_file = entry.code_file || `foo.${key}`;
|
||||
entry.execute = entry.execute || '/w/foo';
|
||||
entry.highlight ||= key;
|
||||
entry.monaco ||= entry.highlight;
|
||||
entry.time_limit_rate ||= 1;
|
||||
entry.code_file ||= `foo.${key}`;
|
||||
entry.execute ||= '/w/foo';
|
||||
entry.key = key;
|
||||
entry.hidden = entry.hidden || false;
|
||||
entry.hidden ||= false;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
Reference in new issue
Block a user