Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lint #4

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/js/core/mixin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要關掉這個規則
把 class 換成一般的物件就好

class MixinManager {
static mixins = new Map();
static cache = new Map();
Expand Down
16 changes: 0 additions & 16 deletions src/js/core/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,6 @@ class Logger {
debug: colors.blue,
};

const formatMessage = (message, ...args) => {
if (args.length === 0) {
return typeof message === 'string' ? message : util.inspect(message, { depth: null });
}

if (typeof message === 'string') {
return util.format(message, ...args.map((arg) =>
typeof arg === 'object' ? util.inspect(arg, { depth: null }) : arg,
));
}

return [message, ...args].map((arg) =>
typeof arg === 'object' ? util.inspect(arg, { depth: null }) : arg,
).join(' ');
};

const consoleFormat = winston.format.printf((info) => {
const date = new Date();
const timestamp = `${this.formatTwoDigits(date.getHours())}:${this.formatTwoDigits(date.getMinutes())}:${this.formatTwoDigits(date.getSeconds())}`;
Expand Down
12 changes: 6 additions & 6 deletions src/js/index/core/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,26 +171,26 @@ class AudioManager {
}

handleEewEnd(ans) {
delete this.ttsCache[ans.data.id];
Reflect.deleteProperty(this.ttsCache, ans.data.id);
}

handleRtsPga2(ans) {
handleRtsPga2() {
this.audioQueues.pga.add(TREM.constant.AUDIO.PGA2, this.priorityRules.pga);
}

handleRtsPga1(ans) {
handleRtsPga1() {
this.audioQueues.pga.add(TREM.constant.AUDIO.PGA1, this.priorityRules.pga);
}

handleRtsShindo2(ans) {
handleRtsShindo2() {
this.audioQueues.shindo.add(TREM.constant.AUDIO.SHINDO2, this.priorityRules.shindo);
}

handleRtsShindo1(ans) {
handleRtsShindo1() {
this.audioQueues.shindo.add(TREM.constant.AUDIO.SHINDO1, this.priorityRules.shindo);
}

handleRtsShindo0(ans) {
handleRtsShindo0() {
this.audioQueues.shindo.add(TREM.constant.AUDIO.SHINDO0);
}

Expand Down
2 changes: 1 addition & 1 deletion src/js/index/core/eew.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ TREM.variable.events.on('EewUpdate', (ans) => {
});
TREM.variable.events.on('EewEnd', (ans) => {
removeEewLayersAndSources(ans.data.id);
delete eew_cache[ans.data.id];
Reflect.deleteProperty(eew_cache, ans.data.id);
show_eew(true);
});

Expand Down
2 changes: 1 addition & 1 deletion src/js/index/core/estimate.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class EewAreaManager {
TREM.variable.events.on('EewRelease', (ans) => this.updateEewArea(ans));
TREM.variable.events.on('EewUpdate', (ans) => this.updateEewArea(ans));
TREM.variable.events.on('EewEnd', (ans) => {
delete TREM.variable.cache.eewIntensityArea[ans.data.id];
Reflect.deleteProperty(TREM.variable.cache.eewIntensityArea, ans.data.id);
this.drawEewArea(true);
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/js/index/core/focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class FocusManager {
TREM.variable.events.on('EewRelease', () => this.focus());
TREM.variable.events.on('EewUpdate', () => this.focus());
TREM.variable.events.on('EewEnd', () => this.focus());
TREM.variable.events.on('MapLoad', (map) => this.onMapLoad(map));
TREM.variable.events.on('MapLoad', () => this.onMapLoad());
}

onMapLoad(map) {
onMapLoad() {
TREM.variable.map.on('mousedown', () => {
this.isMouseDown = true;
});
Expand Down
2 changes: 1 addition & 1 deletion src/js/index/core/intensity.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function IntensityData(newData = []) {
Object.keys(TREM.variable.cache.intensity_last).forEach((id) => {
const item = TREM.variable.cache.intensity_last[id];
if (currentTime - item.last_time > 600000) {
delete TREM.variable.cache.intensity_last[id];
Reflect.deleteProperty(TREM.variable.cache.intensity_last, id);
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/js/index/core/rts.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ TREM.variable.events.on('DataRts', (ans) => {
}
}
else {
delete level_list[id];
Reflect.deleteProperty(level_list, id);
}

if (alert && ans.data.station[id].alert) {
Expand Down Expand Up @@ -406,7 +406,7 @@ function updateIntensityHistory(newData, time) {
const cutoff = time - 30000;
Object.keys(TREM.variable.cache.int_cache_list).forEach((code) => {
if (TREM.variable.cache.int_cache_list[code].lastUpdate < cutoff) {
delete TREM.variable.cache.int_cache_list[code];
Reflect.deleteProperty(TREM.variable.cache.int_cache_list, code);
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/js/index/core/tts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Speech = require('speak-tts');

const speech = new Speech.default();

speech.init().then((data) => {
speech.init().then(() => {
speech.setLanguage('zh-TW');
TREM.variable.speech = speech;
logger.info('Speech ready!');
Expand Down
10 changes: 5 additions & 5 deletions src/js/index/data/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ const TREM = require('../constant');
const now = require('../utils/ntp');

const http = require('./http');
const file = require('./file');
// const file = require('./file');

let last_fetch_time = 0;

TREM.variable.events.on('MapLoad', (map) => {
TREM.variable.events.on('MapLoad', () => {
setInterval(async () => {
const local_now = Date.now();
if (TREM.variable.play_mode == 3) {
// replay (file)
const data = null;
// const data = null;
}
else if (TREM.variable.play_mode == 1) {
// realtime (websocket)
const data = null;
// const data = null;
}
else {
// http (realtime/replay)
Expand Down Expand Up @@ -123,7 +123,7 @@ function EEWData(newData = []) {
Object.keys(TREM.variable.cache.eew_last).forEach((id) => {
const item = TREM.variable.cache.eew_last[id];
if (currentTime - item.last_time > 600000) {
delete TREM.variable.cache.eew_last[id];
Reflect.deleteProperty(TREM.variable.cache.eew_last, id);
}
});

Expand Down
1 change: 1 addition & 0 deletions src/js/index/require.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const isDev = process.defaultApp
let TREM;

if (isDev) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是確定全域變數的話在 eslint.config.mjs 的 global 裡面設定,不要單獨關規則

TREM = require('../js/index/constant');
}

Expand Down
3 changes: 3 additions & 0 deletions src/js/setting/drop_down.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const Station_Wrapper = document.querySelector('.realtime-station');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是確定全域變數的話在 eslint.config.mjs 的 global 裡面設定,不要單獨關規則

const Station_Location = Station_Wrapper.querySelector('.location');
const Station_Select_Wrapper = Station_Wrapper.querySelector('.select-wrapper');
const Station_Local_Items = Station_Select_Wrapper.querySelector('.local');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是確定全域變數的話在 eslint.config.mjs 的 global 裡面設定,不要單獨關規則

const Station_Select = Station_Select_Wrapper.querySelector('.current-station');
const Station_Items = Station_Select_Wrapper.querySelector('.station');

Expand Down Expand Up @@ -32,6 +34,7 @@ Location.onclick = function () {
LocationSelWrapper.classList.toggle('select-show-big');
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是確定全域變數的話在 eslint.config.mjs 的 global 裡面設定,不要單獨關規則

const addLocationSelectEvent = (
localItemsContainer,
cityItemsContainer,
Expand Down
1 change: 1 addition & 0 deletions src/js/setting/require.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是確定全域變數的話在 eslint.config.mjs 的 global 裡面設定,不要單獨關規則

let TREM = JSON.parse(localStorage.getItem('constant'));

const logger = require('../js/core/utils/logger');
Expand Down
Loading