diff --git a/lint/eslintrc-gjs.yml b/lint/eslintrc-gjs.yml index df148de..5d086c8 100644 --- a/lint/eslintrc-gjs.yml +++ b/lint/eslintrc-gjs.yml @@ -3,6 +3,8 @@ env: es6: true extends: 'eslint:recommended' +plugins: + - jsdoc rules: array-bracket-newline: - error @@ -60,6 +62,17 @@ rules: - 'CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child' # Allow dedenting chained member expressions MemberExpression: 'off' + jsdoc/check-alignment: error + jsdoc/check-param-names: error + jsdoc/check-tag-names: error + jsdoc/check-types: error + jsdoc/implements-on-classes: error + jsdoc/newline-after-description: error + jsdoc/require-jsdoc: error + jsdoc/require-param: error + jsdoc/require-param-description: error + jsdoc/require-param-name: error + jsdoc/require-param-type: error key-spacing: - error - beforeColon: false @@ -109,15 +122,15 @@ rules: no-prototype-builtins: 'off' no-restricted-properties: - error + - object: Lang + property: copyProperties + message: Use Object.assign() - object: Lang property: bind message: Use arrow notation or Function.prototype.bind() - object: Lang property: Class message: Use ES6 classes - - object: imports - property: mainloop - message: Use GLib main loops and timeouts no-restricted-syntax: - error - selector: >- @@ -133,6 +146,8 @@ rules: BlockStatement[body.length=1] CallExpression[arguments.length=0][callee.object.type="Super"][callee.property.name="_init"] message: _init() that only calls super._init() is unnecessary + - selector: BinaryExpression[operator="instanceof"][right.name="Array"] + message: Use Array.isArray() no-return-assign: error no-return-await: error no-self-compare: error @@ -169,6 +184,9 @@ rules: object-shorthand: error operator-assignment: error operator-linebreak: error + padded-blocks: + - error + - never # These may be a bit controversial, we can try them out and enable them later # prefer-const: error # prefer-destructuring: error @@ -209,9 +227,6 @@ rules: template-curly-spacing: error template-tag-spacing: error unicode-bom: error - valid-jsdoc: - - error - - requireReturn: false wrap-iife: - error - inside @@ -229,4 +244,4 @@ globals: print: readonly printerr: readonly parserOptions: - ecmaVersion: 2019 + ecmaVersion: 2020 diff --git a/package-lock.json b/package-lock.json index 8330a01..b80c769 100644 --- a/package-lock.json +++ b/package-lock.json @@ -660,6 +660,12 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "comment-parser": { + "version": "0.7.6", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-0.7.6.tgz", + "integrity": "sha512-GKNxVA7/iuTnAqGADlTWX4tkhzxZKXp5fLJqKTlQLHkE65XDUKutZ3BHaJC5IGcper2tT3QRD1xr4o3jNpgXXg==", + "dev": true + }, "common-path-prefix": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/common-path-prefix/-/common-path-prefix-3.0.0.tgz", @@ -1020,6 +1026,44 @@ } } }, + "eslint-plugin-jsdoc": { + "version": "30.7.8", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-30.7.8.tgz", + "integrity": "sha512-OWm2AYvXjCl7nRbpcw5xisfSVkpVAyp4lGqL9T+DeK4kaPm6ecnmTc/G5s1PtcRrwbaI8bIWGzwScqv5CdGyxA==", + "dev": true, + "requires": { + "comment-parser": "^0.7.6", + "debug": "^4.2.0", + "jsdoctypeparser": "^9.0.0", + "lodash": "^4.17.20", + "regextras": "^0.7.1", + "semver": "^7.3.2", + "spdx-expression-parse": "^3.0.1" + }, + "dependencies": { + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "lodash": { + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", + "dev": true + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true + } + } + }, "eslint-scope": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", @@ -1610,6 +1654,12 @@ "esprima": "^4.0.0" } }, + "jsdoctypeparser": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-9.0.0.tgz", + "integrity": "sha512-jrTA2jJIL6/DAEILBEh2/w9QxCuwmvNXIry39Ay/HVfhE3o2yVV0U44blYkqdHA/OKloJEqvJy0xU+GSdE2SIw==", + "dev": true + }, "json-buffer": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", @@ -1691,9 +1741,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", "dev": true }, "lodash.clonedeep": { @@ -2324,6 +2374,12 @@ "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", "dev": true }, + "regextras": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/regextras/-/regextras-0.7.1.tgz", + "integrity": "sha512-9YXf6xtW+qzQ+hcMQXx95MOvfqXFgsKDZodX3qZB0x2n5Z94ioetIITsBtvJbiOyxa/6s9AtyweBLCdPmPko/w==", + "dev": true + }, "registry-auth-token": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.1.1.tgz", diff --git a/package.json b/package.json index 31a76ae..d4144bc 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ }, "devDependencies": { "ava": "^3.8.2", - "eslint": "^7.5.0" + "eslint": "^7.5.0", + "eslint-plugin-jsdoc": "^30.7.8" } } diff --git a/src/compat.js b/src/compat.js index a1df2bc..0d04f4d 100644 --- a/src/compat.js +++ b/src/compat.js @@ -22,6 +22,11 @@ const Me = extensionUtils.getCurrentExtension(); const shellMinorVersion = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]); +/** + * Initialize translations for a given gettext domain. + * + * @param {string} domain Gettext domain. + */ function initTranslations(domain) { if (shellMinorVersion <= 30) return Me.imports.convenience.initTranslations(domain); @@ -30,6 +35,12 @@ function initTranslations(domain) { } +/** + * Get the Extension Manager initialization status. + * + * @returns {boolean} `true` if the Extension Manager is initialized, `false` + * otherwise. + */ function extensionManagerInitialized() { if (shellMinorVersion > 32) return imports.ui.main.extensionManager._initialized; @@ -38,6 +49,12 @@ function extensionManagerInitialized() { } +/** + * Get a specific extension from the Extension Manager. + * + * @param {string} uuid UUID of the extension. + * @returns {(object|null)} The desired extension or `null` if it doesn't exist. + */ function extensionManagerLookup(uuid) { try { if (shellMinorVersion > 32) @@ -50,6 +67,12 @@ function extensionManagerLookup(uuid) { } +/** + * Get GSettings for the given schema ID. + * + * @param {(string|null)} schema The GSettings schema ID. If not given, will use + * the extension's schema ID. + */ function getSettings(schema) { if (shellMinorVersion <= 30) return Me.imports.convenience.getSettings(schema); @@ -58,11 +81,17 @@ function getSettings(schema) { } +/** + * Get the extension's GSettings. + */ function getExtensionSettings() { return getSettings(); } +/** + * Get the KeyBinding AutoRepeat flag. + */ function keyBindingAutoRepeat() { // if version is less then 3.30 the keybinding flags are NONE if (shellMinorVersion < 30) @@ -72,6 +101,11 @@ function keyBindingAutoRepeat() { } +/** + * Get the actor from a given subject. + * + * @param {object} subject The object to get the actor from. + */ function getActor(subject) { if (shellMinorVersion > 34) return subject; diff --git a/src/extension.js b/src/extension.js index 745fd45..4b1bdd9 100644 --- a/src/extension.js +++ b/src/extension.js @@ -46,16 +46,26 @@ var backgrounder = null; var commander = null; +/** + * Extension initialization. + */ function init() { logDebug('Initializing extension...'); compat.initTranslations(Me.metadata['gettext-domain']); logDebug('Extension initialized.'); } +/** + * When the extension is enabled, we wait for the Extension Manager to be + * initialized before starting. + */ function enable() { - GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => waitForExtensionManager(start)); + GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => _waitForExtensionManager(start)); } +/** + * When the extension is started, we create and enable all the modules. + */ function start() { logDebug('Enabling extension...'); settings = new Settings(); @@ -80,6 +90,9 @@ function start() { logDebug('Extension enabled.'); } +/** + * When the extension is disabled, we disable and remove all the modules. + */ function disable() { logDebug('Disabling extension...'); enabled = false; @@ -104,7 +117,13 @@ function disable() { logDebug('Extension disabled.'); } -function waitForExtensionManager(callback) { +/** + * Wait for the Extension Manager to be initialized and run a callback function. + * + * @param {Function} callback The function to run when the Extension Manager + * is initialized. + */ +function _waitForExtensionManager(callback) { logDebug('Waiting for Extension Manager initialization...'); while (!compat.extensionManagerInitialized()) continue; diff --git a/src/modules/Backgrounder.js b/src/modules/Backgrounder.js index 37c5229..7828b8f 100644 --- a/src/modules/Backgrounder.js +++ b/src/modules/Backgrounder.js @@ -31,7 +31,6 @@ const { logDebug } = Me.imports.utils; * settings), it will use it as the current time background. */ var Backgrounder = class { - constructor() { this._statusChangedConnect = null; this._backgroundChangedConnect = null; @@ -139,5 +138,4 @@ var Backgrounder = class { e.settings.system.background = e.settings.backgrounds.night; } } - }; diff --git a/src/modules/Commander.js b/src/modules/Commander.js index 40a9877..234557e 100644 --- a/src/modules/Commander.js +++ b/src/modules/Commander.js @@ -29,7 +29,6 @@ const { logDebug } = Me.imports.utils; * The Commander is responsible for spawning commands according to the time. */ var Commander = class { - constructor() { this._statusChangedConnect = null; this._timeChangedConnect = null; @@ -93,5 +92,4 @@ var Commander = class { GLib.spawn_async(null, ['sh', '-c', command], null, GLib.SpawnFlags.SEARCH_PATH, null); logDebug(`Spawned ${time} command.`); } - }; diff --git a/src/modules/CursorThemer.js b/src/modules/CursorThemer.js index b44ee80..6f7b6fe 100644 --- a/src/modules/CursorThemer.js +++ b/src/modules/CursorThemer.js @@ -30,7 +30,6 @@ const { logDebug } = Me.imports.utils; * the time. */ var CursorThemer = class { - constructor() { this._statusChangedConnect = null; this._variantChangedConnect = null; @@ -140,5 +139,4 @@ var CursorThemer = class { e.settings.system.cursorTheme = e.settings.cursorVariants.night; } } - }; diff --git a/src/modules/GtkThemer.js b/src/modules/GtkThemer.js index b0ef5bd..f9e7c84 100644 --- a/src/modules/GtkThemer.js +++ b/src/modules/GtkThemer.js @@ -41,7 +41,6 @@ const _ = Gettext.gettext; * change the GTK variants in the extension's preferences. */ var GtkThemer = class { - constructor() { this._statusChangedConnect = null; this._variantChangedConnect = null; @@ -184,5 +183,4 @@ var GtkThemer = class { e.settings.gtkVariants.night = variants.get('night'); logDebug(`New GTK variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`); } - }; diff --git a/src/modules/GtkVariants.js b/src/modules/GtkVariants.js index 756a439..76e3d97 100644 --- a/src/modules/GtkVariants.js +++ b/src/modules/GtkVariants.js @@ -41,7 +41,6 @@ this program. If not, see . * - '-darkest' */ var GtkVariants = class { - static guessFrom(name) { const variants = new Map(); @@ -100,5 +99,4 @@ var GtkVariants = class { return variants; } - }; diff --git a/src/modules/IconThemer.js b/src/modules/IconThemer.js index 2790a3f..baf49f6 100644 --- a/src/modules/IconThemer.js +++ b/src/modules/IconThemer.js @@ -30,7 +30,6 @@ const { logDebug } = Me.imports.utils; * time. */ var IconThemer = class { - constructor() { this._statusChangedConnect = null; this._variantChangedConnect = null; @@ -140,5 +139,4 @@ var IconThemer = class { e.settings.system.iconTheme = e.settings.iconVariants.night; } } - }; diff --git a/src/modules/ShellThemer.js b/src/modules/ShellThemer.js index 144ddc8..d16da4d 100644 --- a/src/modules/ShellThemer.js +++ b/src/modules/ShellThemer.js @@ -41,7 +41,6 @@ const _ = Gettext.gettext; * change the shell variants in the extension's preferences. */ var ShellThemer = class { - constructor() { this._statusChangedConnect = null; this._variantChangedConnect = null; @@ -190,6 +189,5 @@ var ShellThemer = class { e.settings.shellVariants.night = variants.get('night'); logDebug(`New Shell variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`); } - }; Signals.addSignalMethods(ShellThemer.prototype); diff --git a/src/modules/ShellVariants.js b/src/modules/ShellVariants.js index 34acd53..3cae08b 100644 --- a/src/modules/ShellVariants.js +++ b/src/modules/ShellVariants.js @@ -41,7 +41,6 @@ this program. If not, see . * - '-darkest' */ var ShellVariants = class { - static guessFrom(name) { const variants = new Map(); @@ -97,5 +96,4 @@ var ShellVariants = class { return variants; } - }; diff --git a/src/modules/Timer.js b/src/modules/Timer.js index c039a8c..5eeb65d 100644 --- a/src/modules/Timer.js +++ b/src/modules/Timer.js @@ -45,7 +45,6 @@ const { TimerOndemand } = Me.imports.modules.TimerOndemand; * schedule in the extensions's preferences. */ var Timer = class { - constructor() { this._sources = []; this._previousTime = null; @@ -199,6 +198,5 @@ var Timer = class { } return source; } - }; Signals.addSignalMethods(Timer.prototype); diff --git a/src/modules/TimerLocation.js b/src/modules/TimerLocation.js index 17cfaf3..d42a2e7 100644 --- a/src/modules/TimerLocation.js +++ b/src/modules/TimerLocation.js @@ -40,7 +40,6 @@ const { logDebug } = Me.imports.utils; * case. */ var TimerLocation = class { - constructor() { this._previouslyDaytime = null; // Before we have the location suntimes, we'll use the manual schedule @@ -211,6 +210,5 @@ var TimerLocation = class { GLib.Source.remove(this._timeChangeTimer); logDebug('Stopped watching for time change.'); } - }; Signals.addSignalMethods(TimerLocation.prototype); diff --git a/src/modules/TimerNightlight.js b/src/modules/TimerNightlight.js index 5de1e19..08397bd 100644 --- a/src/modules/TimerNightlight.js +++ b/src/modules/TimerNightlight.js @@ -42,7 +42,6 @@ const COLOR_INTERFACE = ` * 'NightLightActive' property and will signal any change. */ var TimerNightlight = class { - constructor() { this._colorDbusProxy = null; this._nightlightFollowDisableConnect = null; @@ -135,6 +134,5 @@ var TimerNightlight = class { ? !this._colorDbusProxy.DisabledUntilTomorrow && this._colorDbusProxy.NightLightActive : this._colorDbusProxy.NightLightActive; } - }; Signals.addSignalMethods(TimerNightlight.prototype); diff --git a/src/modules/TimerOndemand.js b/src/modules/TimerOndemand.js index b4dd65a..2be2748 100644 --- a/src/modules/TimerOndemand.js +++ b/src/modules/TimerOndemand.js @@ -41,7 +41,6 @@ const _ = Gettext.gettext; * The user can change the key combination in the extension's preferences. */ var TimerOndemand = class { - constructor() { this._button = null; this._previousKeybinding = null; @@ -221,6 +220,5 @@ var TimerOndemand = class { e.settings.time.ondemandTime = e.timer.time === 'day' ? 'night' : 'day'; this.emit('time-changed', this.time); } - }; Signals.addSignalMethods(TimerOndemand.prototype); diff --git a/src/modules/TimerSchedule.js b/src/modules/TimerSchedule.js index f3d1355..541c47d 100644 --- a/src/modules/TimerSchedule.js +++ b/src/modules/TimerSchedule.js @@ -35,7 +35,6 @@ const { logDebug } = Me.imports.utils; * The user can change the schedule in the extension's preferences. */ var TimerSchedule = class { - constructor() { this._previouslyDaytime = null; this._timeChangeTimer = null; @@ -84,6 +83,5 @@ var TimerSchedule = class { GLib.Source.remove(this._timeChangeTimer); logDebug('Stopped watching for time change.'); } - }; Signals.addSignalMethods(TimerSchedule.prototype); diff --git a/src/preferences/Backgrounds.js b/src/preferences/Backgrounds.js index d6862d7..fe72b58 100644 --- a/src/preferences/Backgrounds.js +++ b/src/preferences/Backgrounds.js @@ -26,7 +26,6 @@ const _ = Gettext.gettext; var BackgroundsPreferences = class { - constructor(settings) { this._builder = new Gtk.Builder(); this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'backgrounds.ui'])); @@ -113,5 +112,4 @@ var BackgroundsPreferences = class { settings.backgrounds.connect('night-changed', () => updateNightClearButtonSensitivity()); updateNightClearButtonSensitivity(); } - }; diff --git a/src/preferences/Commands.js b/src/preferences/Commands.js index 2e06ebc..4445d5e 100644 --- a/src/preferences/Commands.js +++ b/src/preferences/Commands.js @@ -26,7 +26,6 @@ const _ = Gettext.gettext; var CommandsPreferences = class { - constructor(settings) { this._builder = new Gtk.Builder(); this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'commands.ui'])); @@ -91,5 +90,4 @@ var CommandsPreferences = class { settings.commands.connect('sunset-changed', () => updateSunsetClearButtonSensitivity()); updateSunsetClearButtonSensitivity(); } - }; diff --git a/src/preferences/CursorTheme.js b/src/preferences/CursorTheme.js index edf77e7..c23443f 100644 --- a/src/preferences/CursorTheme.js +++ b/src/preferences/CursorTheme.js @@ -28,7 +28,6 @@ const _ = Gettext.gettext; var CursorThemePreferences = class { - constructor(settings) { this._builder = new Gtk.Builder(); this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'cursor_theme.ui'])); @@ -77,5 +76,4 @@ var CursorThemePreferences = class { Gio.SettingsBindFlags.DEFAULT ); } - }; diff --git a/src/preferences/GtkTheme.js b/src/preferences/GtkTheme.js index 245e60b..9fc1da0 100644 --- a/src/preferences/GtkTheme.js +++ b/src/preferences/GtkTheme.js @@ -28,7 +28,6 @@ const _ = Gettext.gettext; var GtkThemePreferences = class { - constructor(settings) { this._builder = new Gtk.Builder(); this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'gtk_theme.ui'])); @@ -93,5 +92,4 @@ var GtkThemePreferences = class { Gio.SettingsBindFlags.DEFAULT ); } - }; diff --git a/src/preferences/Headerbar.js b/src/preferences/Headerbar.js index 9d525eb..47e14b1 100644 --- a/src/preferences/Headerbar.js +++ b/src/preferences/Headerbar.js @@ -28,7 +28,6 @@ const utils = Me.imports.utils; var Headerbar = class { - constructor(stack) { this._builder = new Gtk.Builder(); this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'headerbar.ui'])); @@ -62,5 +61,4 @@ var Headerbar = class { const commandsRadio = this._builder.get_object('commands_radio'); commandsRadio.connect('clicked', () => stack.set_visible_child_name('commands')); } - }; diff --git a/src/preferences/IconTheme.js b/src/preferences/IconTheme.js index ddffbb7..22a7f4b 100644 --- a/src/preferences/IconTheme.js +++ b/src/preferences/IconTheme.js @@ -28,7 +28,6 @@ const _ = Gettext.gettext; var IconThemePreferences = class { - constructor(settings) { this._builder = new Gtk.Builder(); this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'icon_theme.ui'])); @@ -77,5 +76,4 @@ var IconThemePreferences = class { Gio.SettingsBindFlags.DEFAULT ); } - }; diff --git a/src/preferences/OndemandKeyboardShortcutDialog.js b/src/preferences/OndemandKeyboardShortcutDialog.js index 30c0662..f0d2010 100644 --- a/src/preferences/OndemandKeyboardShortcutDialog.js +++ b/src/preferences/OndemandKeyboardShortcutDialog.js @@ -28,7 +28,6 @@ const utils = Me.imports.utils; var OndemandKeyboardShortcutDialog = class { - constructor(settings) { this._builder = new Gtk.Builder(); this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ondemand_keyboard_shortcut_dialog.ui'])); @@ -85,5 +84,4 @@ var OndemandKeyboardShortcutDialog = class { this.widget.close(); }); } - }; diff --git a/src/preferences/Preferences.js b/src/preferences/Preferences.js index 9a945ac..98258c0 100644 --- a/src/preferences/Preferences.js +++ b/src/preferences/Preferences.js @@ -35,7 +35,6 @@ const { Headerbar } = Me.imports.preferences.Headerbar; var Preferences = class { - constructor() { this.settings = new Settings(); this.settings.enable(); @@ -70,5 +69,4 @@ var Preferences = class { this.headerbar = new Headerbar(this.widget); } - }; diff --git a/src/preferences/Schedule.js b/src/preferences/Schedule.js index 5c2882f..8757eaa 100644 --- a/src/preferences/Schedule.js +++ b/src/preferences/Schedule.js @@ -28,7 +28,6 @@ const _ = Gettext.gettext; var SchedulePreferences = class { - constructor(settings) { this._builder = new Gtk.Builder(); this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'schedule.ui'])); @@ -242,5 +241,4 @@ var SchedulePreferences = class { Gio.SettingsBindFlags.DEFAULT ); } - }; diff --git a/src/preferences/ShellTheme.js b/src/preferences/ShellTheme.js index 612773e..55c3b7d 100644 --- a/src/preferences/ShellTheme.js +++ b/src/preferences/ShellTheme.js @@ -28,7 +28,6 @@ const _ = Gettext.gettext; var ShellThemePreferences = class { - constructor(settings) { this._builder = new Gtk.Builder(); this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'shell_theme.ui'])); @@ -94,5 +93,4 @@ var ShellThemePreferences = class { Gio.SettingsBindFlags.DEFAULT ); } - }; diff --git a/src/prefs.js b/src/prefs.js index d99b377..0cc7674 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -27,12 +27,18 @@ const { compat, utils } = Me.imports; const { Preferences } = Me.imports.preferences.Preferences; +/** + * Initialize the preferences. + */ function init() { compat.initTranslations(Me.metadata.uuid); const iconTheme = Gtk.IconTheme.get_default(); iconTheme.append_search_path(GLib.build_filenamev([Me.path, 'icons'])); } +/** + * Build the preferences widget. + */ function buildPrefsWidget() { const preferences = new Preferences(); GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { diff --git a/src/settings/Backgrounds.js b/src/settings/Backgrounds.js index a5b206c..18f8a69 100644 --- a/src/settings/Backgrounds.js +++ b/src/settings/Backgrounds.js @@ -26,7 +26,6 @@ const { logDebug, getSettingsSchema } = Me.imports.utils; var BackgroundsSettings = class { - constructor() { logDebug('Initializing backgrounds settings...'); this.settings = compat.getSettings(getSettingsSchema('backgrounds')); @@ -94,6 +93,5 @@ var BackgroundsSettings = class { this.emit('background-changed', 'night'); this.emit('night-changed'); } - }; Signals.addSignalMethods(BackgroundsSettings.prototype); diff --git a/src/settings/Commands.js b/src/settings/Commands.js index c4ad4bd..925ab4c 100644 --- a/src/settings/Commands.js +++ b/src/settings/Commands.js @@ -26,7 +26,6 @@ const { logDebug, getSettingsSchema } = Me.imports.utils; var CommandsSettings = class { - constructor() { logDebug('Initializing commands settings...'); this.settings = compat.getSettings(getSettingsSchema('commands')); @@ -94,6 +93,5 @@ var CommandsSettings = class { this.emit('command-changed', 'sunset'); this.emit('sunset-changed'); } - }; Signals.addSignalMethods(CommandsSettings.prototype); diff --git a/src/settings/CursorVariants.js b/src/settings/CursorVariants.js index 12f162a..05bbdfd 100644 --- a/src/settings/CursorVariants.js +++ b/src/settings/CursorVariants.js @@ -26,7 +26,6 @@ const { logDebug, getSettingsSchema } = Me.imports.utils; var CursorVariantsSettings = class { - constructor() { logDebug('Initializing cursor variants settings...'); this.settings = compat.getSettings(getSettingsSchema('cursor-variants')); @@ -96,6 +95,5 @@ var CursorVariantsSettings = class { logDebug(`Cursor night variant has changed to '${this.night}'.`); this.emit('variant-changed', 'night'); } - }; Signals.addSignalMethods(CursorVariantsSettings.prototype); diff --git a/src/settings/GtkVariants.js b/src/settings/GtkVariants.js index 62eb89c..deb1874 100644 --- a/src/settings/GtkVariants.js +++ b/src/settings/GtkVariants.js @@ -26,7 +26,6 @@ const { logDebug, getSettingsSchema } = Me.imports.utils; var GtkVariantsSettings = class { - constructor() { logDebug('Initializing GTK variants settings...'); this.settings = compat.getSettings(getSettingsSchema('gtk-variants')); @@ -112,6 +111,5 @@ var GtkVariantsSettings = class { logDebug(`Manual GTK variants have been ${this.manual ? 'ena' : 'disa'}bled.`); this.emit('manual-changed', this.manual); } - }; Signals.addSignalMethods(GtkVariantsSettings.prototype); diff --git a/src/settings/IconVariants.js b/src/settings/IconVariants.js index ecbef7c..986a536 100644 --- a/src/settings/IconVariants.js +++ b/src/settings/IconVariants.js @@ -26,7 +26,6 @@ const { logDebug, getSettingsSchema } = Me.imports.utils; var IconVariantsSettings = class { - constructor() { logDebug('Initializing icon variants settings...'); this.settings = compat.getSettings(getSettingsSchema('icon-variants')); @@ -96,6 +95,5 @@ var IconVariantsSettings = class { logDebug(`Icon night variant has changed to '${this.night}'.`); this.emit('variant-changed', 'night'); } - }; Signals.addSignalMethods(IconVariantsSettings.prototype); diff --git a/src/settings/Settings.js b/src/settings/Settings.js index 756a4ec..408694a 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -34,7 +34,6 @@ const { TimeSettings } = Me.imports.settings.Time; var Settings = class { - constructor() { logDebug('Initializing settings...'); this.extension = compat.getExtensionSettings(); @@ -91,5 +90,4 @@ var Settings = class { } } } - }; diff --git a/src/settings/ShellVariants.js b/src/settings/ShellVariants.js index 8cf32da..4e1c4a9 100644 --- a/src/settings/ShellVariants.js +++ b/src/settings/ShellVariants.js @@ -26,7 +26,6 @@ const { logDebug, getSettingsSchema } = Me.imports.utils; var ShellVariantsSettings = class { - constructor() { logDebug('Initializing shell variants settings...'); this.settings = compat.getSettings(getSettingsSchema('shell-variants')); @@ -112,6 +111,5 @@ var ShellVariantsSettings = class { logDebug(`Manual Shell variants have been ${this.manual ? 'ena' : 'disa'}bled.`); this.emit('manual-changed', this.manual); } - }; Signals.addSignalMethods(ShellVariantsSettings.prototype); diff --git a/src/settings/System.js b/src/settings/System.js index 7e12342..7d74d18 100644 --- a/src/settings/System.js +++ b/src/settings/System.js @@ -32,7 +32,6 @@ const { logDebug, getUserthemesExtension, getUserthemesSettings } = Me.imports.u * changes. */ var SystemSettings = class { - constructor() { logDebug('Initializing system settings...'); this.colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' }); @@ -172,6 +171,5 @@ var SystemSettings = class { logDebug(`Background has changed to '${this.background}'.`); this.emit('background-changed', this.background); } - }; Signals.addSignalMethods(SystemSettings.prototype); diff --git a/src/settings/Time.js b/src/settings/Time.js index c217a90..22ae90d 100644 --- a/src/settings/Time.js +++ b/src/settings/Time.js @@ -26,7 +26,6 @@ const { logDebug, getSettingsSchema } = Me.imports.utils; var TimeSettings = class { - constructor() { logDebug('Initializing time settings...'); this.settings = compat.getSettings(getSettingsSchema('time')); @@ -173,7 +172,5 @@ var TimeSettings = class { logDebug(`On-demand button placement has changed to ${this.ondemandButtonPlacement}`); this.emit('ondemand-button-placement-changed', this.ondemandButtonPlacement); } - - }; Signals.addSignalMethods(TimeSettings.prototype); diff --git a/src/settings/migrations/v0ToV1.js b/src/settings/migrations/v0ToV1.js index bc0b19a..4a9e5a5 100644 --- a/src/settings/migrations/v0ToV1.js +++ b/src/settings/migrations/v0ToV1.js @@ -24,6 +24,11 @@ const compat = Me.imports.compat; const { getSettingsSchema } = Me.imports.utils; +/** + * Migrate settings from v0 to v1. + * + * @param {Settings} settings The current settings. + */ function migrate(settings) { const oldSettings = compat.getSettings(getSettingsSchema('v0')); diff --git a/src/utils.js b/src/utils.js index a890573..3ea7822 100644 --- a/src/utils.js +++ b/src/utils.js @@ -29,6 +29,7 @@ const _ = Gettext.gettext; /** * Output a debug message to the console if the debug config is active. + * * @param {string} message The message to log. */ function logDebug(message) { @@ -38,6 +39,7 @@ function logDebug(message) { /** * Log an error and show a notification if it has a message. + * * @param {Error} error The error to log. */ function notifyError(error) { @@ -49,6 +51,7 @@ function notifyError(error) { /** * Build the full settings schema from a subschema. + * * @param {string} subSchema The subschema to get. * @returns {string} The full schema. */ @@ -58,6 +61,7 @@ function getSettingsSchema(subSchema) { /** * Get all the directories of the system for a resource. + * * @param {string} resource The resource to get the directories. * @returns {string[]} An array of paths. */ @@ -71,6 +75,7 @@ function getResourcesDirsPaths(resource) { /** * Get all the resources installed on the system. + * * @param {string} type The resources to get. * @returns {Set} A set of installed resources. */ @@ -101,6 +106,7 @@ function getInstalledResources(type) { /** * Get all the installed GTK themes on the system. + * * @returns {Set} A set containing all the installed GTK themes names. */ function getInstalledGtkThemes() { @@ -120,6 +126,7 @@ function getInstalledGtkThemes() { /** * Get all the installed shell themes on the system. + * * @returns {Set} A set containing all the installed shell themes names. */ function getInstalledShellThemes() { @@ -134,6 +141,7 @@ function getInstalledShellThemes() { /** * Get all the installed icon themes on the system. + * * @returns {Set} A set containing all the installed icon themes names. */ function getInstalledIconThemes() { @@ -149,6 +157,7 @@ function getInstalledIconThemes() { /** * Get all the installed cursor themes on the system. + * * @returns {Set} A set containing all the installed cursor themes names. */ function getInstalledCursorThemes() { @@ -163,7 +172,8 @@ function getInstalledCursorThemes() { /** * Get the User Themes extension. - * @returns {Object|undefined} The User Themes extension object or undefined if + * + * @returns {object|undefined} The User Themes extension object or undefined if * it isn't installed. */ function getUserthemesExtension() { @@ -172,6 +182,7 @@ function getUserthemesExtension() { /** * Get the User Themes extension settings. + * * @returns {Gio.Settings|null} The User Themes extension settings or null if * the extension isn't installed. */ @@ -192,6 +203,7 @@ function getUserthemesSettings() { /** * Get the shell theme stylesheet. + * * @param {string} theme The shell theme name. * @returns {string|null} Path to the shell theme stylesheet. */ @@ -211,6 +223,7 @@ function getShellThemeStylesheet(theme) { /** * Apply a stylesheet to the shell. + * * @param {string} stylesheet The shell stylesheet to apply. */ function applyShellStylesheet(stylesheet) { @@ -222,6 +235,7 @@ function applyShellStylesheet(stylesheet) { /** * Check if the given keyval is forbidden. + * * @param {number} keyval The keyval number. * @returns {boolean} `true` if the keyval is forbidden. */ @@ -245,6 +259,7 @@ function isKeyvalForbidden(keyval) { /** * Check if the given key combo is a valid binding + * * @param {{mask: number, keycode: number, keyval:number}} combo An object * representing the key combo. * @returns {boolean} `true` if the key combo is a valid binding. @@ -272,6 +287,7 @@ function isBindingValid({ mask, keycode, keyval }) { /** * Check if the given key combo is a valid accelerator. + * * @param {{mask: number, keyval:number}} combo An object representing the key * combo. * @returns {boolean} `true` if the key combo is a valid accelerator. @@ -282,6 +298,7 @@ function isAccelValid({ mask, keyval }) { /** * Find the position of a menu item in the Shell aggregate menu. + * * @param {*} menuItem The desired menu item. * @returns {number} The position of the menu item, `-1` if not found. */