dateMenu: Fix lint errors prior to refactor

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2827>
This commit is contained in:
Evan Welsh 2023-07-07 13:12:49 -07:00
parent e7d290bbfb
commit 88eb04a42c

View File

@ -29,13 +29,25 @@ const EN_CHAR = '\u2013';
const ClocksIntegrationIface = loadInterfaceXML('org.gnome.Shell.ClocksIntegration'); const ClocksIntegrationIface = loadInterfaceXML('org.gnome.Shell.ClocksIntegration');
const ClocksProxy = Gio.DBusProxy.makeProxyWrapper(ClocksIntegrationIface); const ClocksProxy = Gio.DBusProxy.makeProxyWrapper(ClocksIntegrationIface);
/**
* @private
*
* @param {Date} date a Date
* @returns {boolean}
*/
function _isToday(date) { function _isToday(date) {
let now = new Date(); let now = new Date();
return now.getYear() == date.getYear() && return now.getFullYear() === date.getFullYear() &&
now.getMonth() == date.getMonth() && now.getMonth() === date.getMonth() &&
now.getDate() == date.getDate(); now.getDate() === date.getDate();
} }
/**
* @private
*
* @param {GLib.DateTime} datetime a GLib.DateTime
* @returns {Date}
*/
function _gDateTimeToDate(datetime) { function _gDateTimeToDate(datetime) {
return new Date(datetime.to_unix() * 1000 + datetime.get_microsecond() / 1000); return new Date(datetime.to_unix() * 1000 + datetime.get_microsecond() / 1000);
} }
@ -53,7 +65,7 @@ class TodayButton extends St.Button {
reactive: false, reactive: false,
}); });
let hbox = new St.BoxLayout({ vertical: true }); const hbox = new St.BoxLayout({vertical: true});
this.add_actor(hbox); this.add_actor(hbox);
this._dayLabel = new St.Label({ this._dayLabel = new St.Label({
@ -85,15 +97,15 @@ class TodayButton extends St.Button {
* "Tue 9:29 AM"). The string itself should become a full date, e.g., * "Tue 9:29 AM"). The string itself should become a full date, e.g.,
* "February 17 2015". * "February 17 2015".
*/ */
let dateFormat = Shell.util_translate_time_string(N_("%B %-d %Y")); const dateFormat = Shell.util_translate_time_string(N_('%B %-d %Y'));
this._dateLabel.set_text(date.toLocaleFormat(dateFormat)); this._dateLabel.set_text(date.toLocaleFormat(dateFormat));
/* Translators: This is the accessible name of the date button shown /* Translators: This is the accessible name of the date button shown
* below the time in the shell; it should combine the weekday and the * below the time in the shell; it should combine the weekday and the
* date, e.g. "Tuesday February 17 2015". * date, e.g. "Tuesday February 17 2015".
*/ */
dateFormat = Shell.util_translate_time_string(N_("%A %B %e %Y")); const dateAccessibleNameFormat = Shell.util_translate_time_string(N_('%A %B %e %Y'));
this.accessible_name = date.toLocaleFormat(dateFormat); this.accessible_name = date.toLocaleFormat(dateAccessibleNameFormat);
} }
}); });
@ -330,7 +342,7 @@ class WorldClocksSection extends St.Button {
this._locations = []; this._locations = [];
let layout = new Clutter.GridLayout({ orientation: Clutter.Orientation.VERTICAL }); const layout = new Clutter.GridLayout({orientation: Clutter.Orientation.VERTICAL});
this._grid = new St.Widget({ this._grid = new St.Widget({
style_class: 'world-clocks-grid', style_class: 'world-clocks-grid',
x_expand: true, x_expand: true,
@ -396,9 +408,9 @@ class WorldClocksSection extends St.Button {
}); });
let layout = this._grid.layout_manager; let layout = this._grid.layout_manager;
let title = this._locations.length == 0 const title = this._locations.length === 0
? _("Add world clocks…") ? _('Add world clocks…')
: _("World Clocks"); : _('World Clocks');
const header = new St.Label({ const header = new St.Label({
style_class: 'world-clocks-header', style_class: 'world-clocks-header',
x_align: Clutter.ActorAlign.START, x_align: Clutter.ActorAlign.START,
@ -422,7 +434,7 @@ class WorldClocksSection extends St.Button {
x_expand: true, x_expand: true,
}); });
let time = new St.Label({ style_class: 'world-clocks-time' }); const time = new St.Label({style_class: 'world-clocks-time'});
const tz = new St.Label({ const tz = new St.Label({
style_class: 'world-clocks-timezone', style_class: 'world-clocks-timezone',
@ -433,7 +445,7 @@ class WorldClocksSection extends St.Button {
time.clutter_text.ellipsize = Pango.EllipsizeMode.NONE; time.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
tz.clutter_text.ellipsize = Pango.EllipsizeMode.NONE; tz.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
if (this._grid.text_direction == Clutter.TextDirection.RTL) { if (this._grid.text_direction === Clutter.TextDirection.RTL) {
layout.attach(tz, 0, i + 1, 1, 1); layout.attach(tz, 0, i + 1, 1, 1);
layout.attach(time, 1, i + 1, 1, 1); layout.attach(time, 1, i + 1, 1, 1);
layout.attach(label, 2, i + 1, 1, 1); layout.attach(label, 2, i + 1, 1, 1);
@ -600,7 +612,7 @@ class WeatherSection extends St.Button {
if (datetime.difference(current) < GLib.TIME_SPAN_HOUR) if (datetime.difference(current) < GLib.TIME_SPAN_HOUR)
continue; // Enforce a minimum interval of 1h continue; // Enforce a minimum interval of 1h
if (infos.push(forecasts[i]) == MAX_FORECASTS) if (infos.push(forecasts[i]) === MAX_FORECASTS)
break; // Use a maximum of five forecasts break; // Use a maximum of five forecasts
current = datetime; current = datetime;
@ -612,7 +624,7 @@ class WeatherSection extends St.Button {
let layout = this._forecastGrid.layout_manager; let layout = this._forecastGrid.layout_manager;
let infos = this._getInfos(); let infos = this._getInfos();
if (this._forecastGrid.text_direction == Clutter.TextDirection.RTL) if (this._forecastGrid.text_direction === Clutter.TextDirection.RTL)
infos.reverse(); infos.reverse();
let col = 0; let col = 0;
@ -682,7 +694,7 @@ class WeatherSection extends St.Button {
this._titleLocation.text = this._findBestLocationName(info.location); this._titleLocation.text = this._findBestLocationName(info.location);
if (this._weatherClient.loading) { if (this._weatherClient.loading) {
this._setStatusLabel(_("Loading…")); this._setStatusLabel(_('Loading…'));
return; return;
} }
@ -692,9 +704,9 @@ class WeatherSection extends St.Button {
} }
if (info.network_error()) if (info.network_error())
this._setStatusLabel(_("Go online for weather information")); this._setStatusLabel(_('Go online for weather information'));
else else
this._setStatusLabel(_("Weather information is currently unavailable")); this._setStatusLabel(_('Weather information is currently unavailable'));
} }
_sync() { _sync() {
@ -787,7 +799,7 @@ class FreezableBinLayout extends Clutter.BinLayout {
} }
set frozen(v) { set frozen(v) {
if (this._frozen == v) if (this._frozen === v)
return; return;
this._frozen = v; this._frozen = v;