ui: update eslint rules

This commit is contained in:
undefined committed 2022-09-03 14:28:18 +08:00
1 parent 0e07c64cad
commit 5e8d2b1286
30 files changed
+73 -72

No files matched your search

@@ -56,8 +56,7 @@ export default class DOMAttachedObject {
static attachAll(container: Document | HTMLElement = document.body, ...args) {
if (process.env.NODE_ENV !== 'production') {
if (!this.DOMAttachSelector) {
// eslint-disable-next-line quotes
throw new Error(`'DOMAttachSelector' should be specified`);
throw new Error("'DOMAttachSelector' should be specified");
}
}
if (process.env.NODE_ENV !== 'production') {
@@ -77,8 +76,7 @@ export default class DOMAttachedObject {
const selector = this.DOMDetachSelector || this.DOMAttachSelector;
if (process.env.NODE_ENV !== 'production') {
if (!selector) {
// eslint-disable-next-line quotes
throw new Error(`'DOMDetachSelector' or 'DOMAttachSelector' should be specified`);
throw new Error("'DOMDetachSelector' or 'DOMAttachSelector' should be specified");
}
}
if (process.env.NODE_ENV !== 'production') {
@@ -102,8 +100,7 @@ export default class DOMAttachedObject {
static registerLifeCycleHooks(attach = true) {
if (process.env.NODE_ENV !== 'production') {
if (!this.DOMAttachSelector) {
// eslint-disable-next-line quotes
throw new Error(`'DOMAttachSelector' should be specified`);
throw new Error("'DOMAttachSelector' should be specified");
}
}
$(document).on('vjContentNew', (e) => this.attachAll(e.target));
@@ -109,9 +109,12 @@ const AutoComplete = forwardRef(function Impl<T>(props: AutoCompleteProps<T>, re
const inputRef = useRef<HTMLInputElement>();
const listRef = useRef<HTMLUListElement>();
if (props.cacheKey) superCache[props.cacheKey] ||= { query: {}, value: {} };
const queryCache = props.cacheKey ? superCache[props.cacheKey].query : useRef({}).current;
const valueCache = props.cacheKey ? superCache[props.cacheKey].value : useRef({}).current;
let [queryCache, valueCache] = [useRef({}).current, useRef({}).current];
if (props.cacheKey) {
superCache[props.cacheKey] ||= { query: {}, value: {} };
queryCache = superCache[props.cacheKey].query;
valueCache = superCache[props.cacheKey].value;
}
const queryList = async (query) => {
if (!query && !allowEmptyQuery) {
@@ -280,10 +280,8 @@ export default class Calendar {
for (; vIndex < vIndexMax; ++vIndex) {
if (_.every(_
.range(beginDay, endDay + 1)
.map((day) => !dayBitmap[day][vIndex]), // eslint-disable-line no-loop-func
)) { // eslint-disable-line function-paren-newline
break;
}
.map((day) => !dayBitmap[day][vIndex]), // eslint-disable-line
)) break;
}
// fill space
for (let i = beginDay; i <= endDay; ++i) {
@@ -21,7 +21,7 @@ function scrollToViewport() {
}
}
export default function reducer(state = null, action) {
export default function reducer(state = null, action: any = {}) {
switch (action.type) {
case 'DIALOGUES_SWITCH_TO': {
scrollToViewport();
@@ -1,6 +1,6 @@
import _ from 'lodash';
export default function reducer(state = {}, action) {
export default function reducer(state = {}, action = {}) {
switch (action.type) {
case 'DIALOGUES_LOAD_DIALOGUES_FULFILLED': {
const { messages } = action.payload;
@@ -1,6 +1,6 @@
import _ from 'lodash';
export default function reducer(state = {}, action) {
export default function reducer(state = {}, action = {}) {
switch (action.type) {
case 'DIALOGUES_LOAD_DIALOGUES_FULFILLED': {
const dialogues = action.payload.messages;
@@ -1,7 +1,7 @@
import _ from 'lodash';
import Notification from 'vj/components/notification';
export default function reducer(state = {}, action) {
export default function reducer(state = {}, action: any = {}) {
switch (action.type) {
case 'DIALOGUES_LOAD_DIALOGUES_FULFILLED': {
const dialogues = action.payload.messages;
+2 -2
View File
@@ -1,7 +1,7 @@
/* eslint-disable camelcase */
import en_GB from 'monaco-editor-nls/locale/en-gb.json';
function _format(message, args) {
function format(message, args) {
let result;
if (args.length === 0) {
result = message;
@@ -33,7 +33,7 @@ function find(path, message) {
}
export function localize(path, message, ...args) {
return _format(find(path.key || path, message), args);
return format(find(path.key || path, message), args);
}
export function setLocaleData(data) {
@@ -59,7 +59,7 @@ export function TestCaseEntry({ index, subindex }) {
output: useRef(),
};
for (const type of ['input', 'output']) {
useEffect(() => {
useEffect(() => { // eslint-disable-line
refs[type].current?.setSelectedItems(testcase[type] ? [testcase[type]] : []);
}, [testcase[type]]);
}
@@ -5,7 +5,7 @@ import { cloneDeep } from 'lodash';
type State = ProblemConfigFile & { __loaded: boolean };
export default function reducer(state = { type: 'default', __loaded: false } as State, action): State {
export default function reducer(state = { type: 'default', __loaded: false } as State, action: any = {}): State {
switch (action.type) {
case 'CONFIG_LOAD_FULFILLED': {
return { ...state, ...yaml.load(action.payload.config) as object, __loaded: true };
@@ -1,4 +1,4 @@
export default function reducer(state = [], action) {
export default function reducer(state = [], action: any = {}) {
switch (action.type) {
case 'CONFIG_LOAD_FULFILLED': {
return state.concat(action.payload.testdata);
@@ -4,7 +4,7 @@ if (UiContext.tdoc?._id && UiContext.tdoc.rule !== 'homework') cacheKey += `@${U
export default function reducer(state = {
lang: localStorage.getItem(`${cacheKey}#lang`) || UiContext.codeLang,
code: localStorage.getItem(cacheKey) || UiContext.codeTemplate,
}, action) {
}, action: any = {}) {
if (action.type === 'SCRATCHPAD_EDITOR_UPDATE_CODE') {
localStorage.setItem(cacheKey, action.payload);
return {
@@ -4,7 +4,7 @@ export default function reducer(state = {
input: '',
output: '',
rid: null,
}, action) {
}, action: any = {}) {
if (action.type === 'SCRATCHPAD_PRETEST_DATA_CHANGE') {
const { type, value } = action.payload;
return {
@@ -3,7 +3,7 @@ import _ from 'lodash';
export default function reducer(state = {
rows: [],
items: {},
}, action) {
}, action: any = {}) {
switch (action.type) {
case 'SCRATCHPAD_RECORDS_LOAD_SUBMISSIONS_FULFILLED': {
const { rdocs } = action.payload;
@@ -1,4 +1,4 @@
export default function reducer(state = {}, action) {
export default function reducer(state = {}, action: any = {}) {
if (action.type === 'SCRATCHPAD_STATE_UPDATE') {
const { key, value } = action.payload;
return {
@@ -21,7 +21,7 @@ export default function reducer(state = {
waitSec: 0,
isWaiting: false,
activePage: 'problem',
}, action) {
}, action: any = {}) {
switch (action.type) {
case 'SCRATCHPAD_UI_CHANGE_SIZE': {
const { uiElement, size } = action.payload;
+1 -1
View File
@@ -14,7 +14,7 @@ interface UploadOptions {
pjax?: boolean;
singleFileUploadCallback?: (file: File) => any;
}
export default async function uploadFiles(endpoint = '', files: File[] | FileList, options: UploadOptions = {}) {
export default async function uploadFiles(endpoint = '', files: File[] | FileList = [], options: UploadOptions = {}) {
const dialog = new Dialog({
$body: `
<div class="file-label" style="text-align: center; margin-bottom: 5px; color: gray; font-size: small;"></div>