style: remove unnecessary function whitespace

Remove the unnecessary whitespace between the function name or the
'function' keyword and the opening parenthesis.
This commit is contained in:
2026-08-09 13:09:39 +02:00
committed by Gitea
parent 6bf315e4b8
commit 995e77b69a
31 changed files with 55 additions and 55 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ const route = useRoute();
const { getSetting } = useSettings(); const { getSetting } = useSettings();
const colorScheme = computed(() => getSetting(['appearance', 'colorScheme'])); const colorScheme = computed(() => getSetting(['appearance', 'colorScheme']));
const updateColorScheme = function updateColorScheme (newColorScheme) { const updateColorScheme = function updateColorScheme(newColorScheme) {
document.body.style.setProperty(colorScheme, { document.body.style.setProperty(colorScheme, {
auto: 'normal', auto: 'normal',
dark: 'dark', dark: 'dark',
+1 -1
View File
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
export const getAssetsUrl = function getAssetsUrl () { export const getAssetsUrl = function getAssetsUrl() {
return new URL( return new URL(
`${import.meta.env.VITE_ASSETS_BUILD_ID}/`, `${import.meta.env.VITE_ASSETS_BUILD_ID}/`,
import.meta.env.VITE_ASSETS_BASE_URL import.meta.env.VITE_ASSETS_BASE_URL
@@ -38,11 +38,11 @@ const colorSchemeIconMapper = {
'auto': 'circle-black-white' 'auto': 'circle-black-white'
}; };
const getTooltipTranslation = function (colorScheme) { const getTooltipTranslation = function(colorScheme) {
return t(`preferences.colorScheme.switch.${colorSchemeNextMapper[colorScheme]}`); return t(`preferences.colorScheme.switch.${colorSchemeNextMapper[colorScheme]}`);
}; };
const setColorScheme = function setColorScheme (newColorScheme) { const setColorScheme = function setColorScheme(newColorScheme) {
setSetting(['appearance', 'colorScheme'], newColorScheme); setSetting(['appearance', 'colorScheme'], newColorScheme);
}; };
</script> </script>
@@ -23,7 +23,7 @@ const { getSetting } = useSettings();
const colorSchemeSettingPath = ['appearance', 'colorScheme']; const colorSchemeSettingPath = ['appearance', 'colorScheme'];
const getWrapper = function getWrapper () { const getWrapper = function getWrapper() {
return mountComponent(ColorSchemeButton); return mountComponent(ColorSchemeButton);
}; };
@@ -29,19 +29,19 @@ const { setSetting, getSetting } = useSettings();
const isOpen = ref(false); const isOpen = ref(false);
const languageDropdown = ref(null); const languageDropdown = ref(null);
const selectLanguage = function selectLanguage (code) { const selectLanguage = function selectLanguage(code) {
setSetting(LANGUAGE_PATH, code); setSetting(LANGUAGE_PATH, code);
close(); close();
}; };
watch(() => getSetting(LANGUAGE_PATH), setLocale); watch(() => getSetting(LANGUAGE_PATH), setLocale);
const close = function () { const close = function() {
document.removeEventListener('click', closeWrapperOnClickOutside); document.removeEventListener('click', closeWrapperOnClickOutside);
isOpen.value = false; isOpen.value = false;
}; };
const closeWrapperOnClickOutside = function (e) { const closeWrapperOnClickOutside = function(e) {
if (languageDropdown.value) { if (languageDropdown.value) {
if (!languageDropdown.value.contains(e.target)) { if (!languageDropdown.value.contains(e.target)) {
close(); close();
@@ -49,7 +49,7 @@ const closeWrapperOnClickOutside = function (e) {
}; };
}; };
const open = function () { const open = function() {
if (!isOpen.value) { if (!isOpen.value) {
isOpen.value = true; isOpen.value = true;
setTimeout(() => { setTimeout(() => {
@@ -20,7 +20,7 @@ import { mountComponent } from '@/test-utils/mountComponent.js';
import { expect, test, describe } from 'vitest'; import { expect, test, describe } from 'vitest';
import LanguageSwitchButton from '../LanguageSwitchButton.vue'; import LanguageSwitchButton from '../LanguageSwitchButton.vue';
const getWrapper = function getWrapper () { const getWrapper = function getWrapper() {
return mountComponent(LanguageSwitchButton); return mountComponent(LanguageSwitchButton);
}; };
+1 -1
View File
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
export const getNavigatorLanguage = function getNavigatorLanguage () { export const getNavigatorLanguage = function getNavigatorLanguage() {
const locale = new Intl.Locale(navigator.language); const locale = new Intl.Locale(navigator.language);
return locale.language; return locale.language;
}; };
@@ -17,7 +17,7 @@ limitations under the License.
import { FetchError } from '../errors'; import { FetchError } from '../errors';
import { getAssetsUrl } from '@/config/env'; import { getAssetsUrl } from '@/config/env';
const fetchHtml = async function fetchHtml (url, options) { const fetchHtml = async function fetchHtml(url, options) {
let response; let response;
try { try {
response = await fetch(url, options); response = await fetch(url, options);
@@ -29,7 +29,7 @@ const fetchHtml = async function fetchHtml (url, options) {
else throw new FetchError(); else throw new FetchError();
}; };
export const getLegalNotice = async function getLegalNotice () { export const getLegalNotice = async function getLegalNotice() {
const legalNoticeUrl = new URL('legal/legal_notice.html', getAssetsUrl()).href; const legalNoticeUrl = new URL('legal/legal_notice.html', getAssetsUrl()).href;
const html = await fetchHtml(legalNoticeUrl); const html = await fetchHtml(legalNoticeUrl);
+1 -1
View File
@@ -27,7 +27,7 @@ const { t } = useI18n();
const router = useRouter(); const router = useRouter();
const props = defineProps(['autoSubmit']); const props = defineProps(['autoSubmit']);
const submitSearch = function () { const submitSearch = function() {
if (props.autoSubmit !== undefined) { if (props.autoSubmit !== undefined) {
router.push({ router.push({
name: 'searchResults', name: 'searchResults',
@@ -22,7 +22,7 @@ import { useI18n } from 'vue-i18n';
const { t } = useI18n(); const { t } = useI18n();
const normalizeSelectedValue = function normalizeSelectedValue (value) { const normalizeSelectedValue = function normalizeSelectedValue(value) {
if (props.setting.allowMultiple) { if (props.setting.allowMultiple) {
if (Array.isArray(value)) { if (Array.isArray(value)) {
return value; return value;
@@ -65,7 +65,7 @@ watch(inputModel, () => {
doneButtonInitial.value = false; doneButtonInitial.value = false;
}); });
const apply = function apply () { const apply = function apply() {
store.set(props.path, inputModel.value); store.set(props.path, inputModel.value);
}; };
</script> </script>
@@ -33,7 +33,7 @@ const props = defineProps({
} }
}); });
const followLink = function followLink () { const followLink = function followLink() {
goToSettingsPage(props.target); goToSettingsPage(props.target);
}; };
</script> </script>
+1 -1
View File
@@ -42,7 +42,7 @@ watch(store, (newStore) => {
// set value after registering watcher to avoid immediate value change // set value after registering watcher to avoid immediate value change
enabled.value = store.get(props.path) ?? props.setting.default; enabled.value = store.get(props.path) ?? props.setting.default;
const toggle = function toggle () { const toggle = function toggle() {
enabled.value = !enabled.value; enabled.value = !enabled.value;
store.set(props.path, enabled.value); store.set(props.path, enabled.value);
}; };
@@ -20,7 +20,7 @@ import { useSettingsStore } from '../../stores/settingsStore.js';
import { expect, describe, test } from 'vitest'; import { expect, describe, test } from 'vitest';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
const getWrapper = function getWrapper ({ const getWrapper = function getWrapper({
i18n = 'selection', i18n = 'selection',
options = [], options = [],
allowMultiple = false, allowMultiple = false,
@@ -43,7 +43,7 @@ const getWrapper = function getWrapper ({
}, translations, [], piniaOptions); }, translations, [], piniaOptions);
}; };
const getChecked = function getChecked (inputs) { const getChecked = function getChecked(inputs) {
return inputs.map((input) => input.element.matches(':checked')); return inputs.map((input) => input.element.matches(':checked'));
}; };
@@ -199,20 +199,20 @@ describe('Selection', () => {
}); });
test('stores multiple values', async () => { test('stores multiple values', async () => {
const setValue = async function setValue (input, value) { const setValue = async function setValue(input, value) {
input.setValue(value); input.setValue(value);
await nextTick(); await nextTick();
}; };
const check = function check (input) { const check = function check(input) {
return setValue(input, true); return setValue(input, true);
}; };
const uncheck = function uncheck (input) { const uncheck = function uncheck(input) {
return setValue(input, false); return setValue(input, false);
}; };
const expectSelectionValue = function expectSelectionValue (value, options = exampleOptions) { const expectSelectionValue = function expectSelectionValue(value, options = exampleOptions) {
value.sort(); value.sort();
expect(store.get('selection').sort()).toStrictEqual(value); expect(store.get('selection').sort()).toStrictEqual(value);
const checkedInputs = getChecked(inputs); const checkedInputs = getChecked(inputs);
@@ -20,7 +20,7 @@ import { useSettingsStore } from '../../stores/settingsStore.js';
import { expect, describe, test } from 'vitest'; import { expect, describe, test } from 'vitest';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
const getWrapper = function getWrapper ({ const getWrapper = function getWrapper({
i18n = 'switch1', i18n = 'switch1',
defaultValue = undefined, defaultValue = undefined,
translations = {}, translations = {},
@@ -21,13 +21,13 @@ import { getSettingRecursively } from '../utils/getSetting';
/** /**
* Provides access to the stored settings. * Provides access to the stored settings.
*/ */
export const useSettings = function useSettings () { export const useSettings = function useSettings() {
/** /**
* Returns the value of a specific setting. * Returns the value of a specific setting.
* @param {string[]} key - The settings key. * @param {string[]} key - The settings key.
* @return The value of the setting. * @return The value of the setting.
*/ */
const getSetting = function getSetting (key) { const getSetting = function getSetting(key) {
const settingsStore = useSettingsStore(); const settingsStore = useSettingsStore();
return ( return (
@@ -43,7 +43,7 @@ export const useSettings = function useSettings () {
* @param {string[]} key - The setting key. * @param {string[]} key - The setting key.
* @param value - The new value for the setting. * @param value - The new value for the setting.
*/ */
const setSetting = function setSetting (key, value) { const setSetting = function setSetting(key, value) {
const settingsStore = useSettingsStore(); const settingsStore = useSettingsStore();
settingsStore.set(key.join('.'), value); settingsStore.set(key.join('.'), value);
}; };
@@ -17,10 +17,10 @@ limitations under the License.
import { getSettingsPagePathSegments } from '../utils/settingsPage'; import { getSettingsPagePathSegments } from '../utils/settingsPage';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
export const useSettingsPage = function useSettingsPage () { export const useSettingsPage = function useSettingsPage() {
const router = useRouter(); const router = useRouter();
const goToSettingsPage = function goToSettingsPage (pagePath) { const goToSettingsPage = function goToSettingsPage(pagePath) {
return router.push({ return router.push({
name: 'settings', name: 'settings',
params: { params: {
@@ -20,19 +20,19 @@ import { reactive } from 'vue';
export const useSettingsStore = defineStore('settings', () => { export const useSettingsStore = defineStore('settings', () => {
const settings = reactive({}); const settings = reactive({});
const set = function set (key, value) { const set = function set(key, value) {
settings[key] = value; settings[key] = value;
}; };
const get = function get (key) { const get = function get(key) {
return settings[key]; return settings[key];
}; };
const remove = function remove (key) { const remove = function remove(key) {
delete settings[key]; delete settings[key];
}; };
const clear = function clear () { const clear = function clear() {
Object.keys(settings).forEach(key => delete settings[key]); Object.keys(settings).forEach(key => delete settings[key]);
}; };
+3 -3
View File
@@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
export const getSetting = function getSetting (name, settings) { export const getSetting = function getSetting(name, settings) {
return settings.filter((setting) => setting.name === name)[0]; return settings.filter((setting) => setting.name === name)[0];
}; };
export const getSettingRecursively = function getSettingRecursively (sectionPath, settings) { export const getSettingRecursively = function getSettingRecursively(sectionPath, settings) {
const oneSettingsLevel = function oneSettingsLevel (cursor, acc) { const oneSettingsLevel = function oneSettingsLevel(cursor, acc) {
const setting = getSetting(cursor[0], acc.content); const setting = getSetting(cursor[0], acc.content);
if (!setting) return; if (!setting) return;
+1 -1
View File
@@ -19,7 +19,7 @@ limitations under the License.
* @param {string} path - The settings page path. * @param {string} path - The settings page path.
* @returns {Array} The settings page path segments. * @returns {Array} The settings page path segments.
*/ */
export const getSettingsPagePathSegments = function getSettingsPagePathSegments (path) { export const getSettingsPagePathSegments = function getSettingsPagePathSegments(path) {
if (typeof path !== 'string') return []; if (typeof path !== 'string') return [];
return path return path
.replace(/^\.+|\.+$/g, '') .replace(/^\.+|\.+$/g, '')
@@ -16,13 +16,13 @@ limitations under the License.
const VALID_TYPES = ['bool', 'number', 'string', 'selection', 'section']; const VALID_TYPES = ['bool', 'number', 'string', 'selection', 'section'];
export const assertString = function assertString (value, path) { export const assertString = function assertString(value, path) {
if (typeof value !== 'string' || value.trim() === '') { if (typeof value !== 'string' || value.trim() === '') {
throw new Error(`[settings] "${path}" must be a non-empty string`); throw new Error(`[settings] "${path}" must be a non-empty string`);
} }
}; };
export const assertType = function assertType (value, path) { export const assertType = function assertType(value, path) {
if (!VALID_TYPES.includes(value)) { if (!VALID_TYPES.includes(value)) {
throw new Error( throw new Error(
`[settings] "${path}" has invalid type "${value}". Must be one of: ${VALID_TYPES.join(', ')}` `[settings] "${path}" has invalid type "${value}". Must be one of: ${VALID_TYPES.join(', ')}`
@@ -30,7 +30,7 @@ export const assertType = function assertType (value, path) {
} }
}; };
export const validateSelectionOptions = function validateSelectionOptions (options, path) { export const validateSelectionOptions = function validateSelectionOptions(options, path) {
if (!Array.isArray(options) || options.length === 0) { if (!Array.isArray(options) || options.length === 0) {
throw new Error(`[settings] "${path}.options" must be a non-empty array`); throw new Error(`[settings] "${path}.options" must be a non-empty array`);
} }
@@ -40,7 +40,7 @@ export const validateSelectionOptions = function validateSelectionOptions (optio
}); });
}; };
export const validateEntry = function validateEntry (entry, path) { export const validateEntry = function validateEntry(entry, path) {
assertType(entry.type, `${path}.type`); assertType(entry.type, `${path}.type`);
assertString(entry.name, `${path}.name`); assertString(entry.name, `${path}.name`);
@@ -98,7 +98,7 @@ export const validateEntry = function validateEntry (entry, path) {
} }
}; };
export const validateFirstLevelSection = function validateFirstLevelSection (section, path) { export const validateFirstLevelSection = function validateFirstLevelSection(section, path) {
assertString(section.name); assertString(section.name);
assertString(section.i18n); assertString(section.i18n);
+2 -2
View File
@@ -39,7 +39,7 @@ const activePath = computed(() => {
}); });
const activeSection = ref(null); const activeSection = ref(null);
const updateSettings = async function updateSettings () { const updateSettings = async function updateSettings() {
const setting = getSettingRecursively(activePath.value, settings); const setting = getSettingRecursively(activePath.value, settings);
if (setting) { if (setting) {
activeSection.value = setting; activeSection.value = setting;
@@ -50,7 +50,7 @@ const updateSettings = async function updateSettings () {
watch(route, (newRoute) => updateSettings(newRoute)); watch(route, (newRoute) => updateSettings(newRoute));
onMounted(updateSettings); onMounted(updateSettings);
const toggleSidebarIfSmallScreen = function toggleSidebarIfSmallScreen (toggleSidebarFunction) { const toggleSidebarIfSmallScreen = function toggleSidebarIfSmallScreen(toggleSidebarFunction) {
if (matchMedia('(max-width: 48rem)').matches) toggleSidebarFunction(); if (matchMedia('(max-width: 48rem)').matches) toggleSidebarFunction();
}; };
</script> </script>
@@ -211,7 +211,7 @@ vi.mock('vue-router', async (importOriginal) => {
}; };
}); });
const getWrapper = function getWrapper ({ translations = {} } = {}) { const getWrapper = function getWrapper({ translations = {} } = {}) {
return mountComponent(SettingsView, {}, translations, [], {}); return mountComponent(SettingsView, {}, translations, [], {});
}; };
+1 -1
View File
@@ -26,7 +26,7 @@ const props = defineProps({
}); });
const emit = defineEmits(['toggleExpanded']); const emit = defineEmits(['toggleExpanded']);
const toggleSidebar = function toggleSidebar () { const toggleSidebar = function toggleSidebar() {
emit('toggleExpanded'); emit('toggleExpanded');
}; };
</script> </script>
@@ -19,7 +19,7 @@ import Icon from '@/features/icons/components/Icon.vue';
const emit = defineEmits(['click']); const emit = defineEmits(['click']);
const click = function click (event) { const click = function click(event) {
emit('click', event); emit('click', event);
}; };
</script> </script>
+2 -2
View File
@@ -40,7 +40,7 @@ export const i18n = createI18n({
const loadedLanguages = new Set(); const loadedLanguages = new Set();
export async function loadLanguage (locale) { export async function loadLanguage(locale) {
if (!SUPPORTED_LANGUAGES.includes(locale)) { if (!SUPPORTED_LANGUAGES.includes(locale)) {
locale = fallbackLocale; locale = fallbackLocale;
} }
@@ -58,7 +58,7 @@ export async function loadLanguage (locale) {
loadedLanguages.add(locale); loadedLanguages.add(locale);
}; };
export const setLocale = async function setLocale (locale) { export const setLocale = async function setLocale(locale) {
await loadLanguage(locale); await loadLanguage(locale);
document.documentElement.lang = locale; document.documentElement.lang = locale;
document.documentElement.dir = LANGUAGES_RTL.includes(locale) ? 'rtl' : 'ltr'; document.documentElement.dir = LANGUAGES_RTL.includes(locale) ? 'rtl' : 'ltr';
+1 -1
View File
@@ -29,7 +29,7 @@ const props = defineProps({
const expanded = ref(props.expanded); const expanded = ref(props.expanded);
const toggleSidebar = function toggleSidebar () { const toggleSidebar = function toggleSidebar() {
expanded.value = !expanded.value; expanded.value = !expanded.value;
}; };
</script> </script>
+1 -1
View File
@@ -68,7 +68,7 @@ const router = createRouter({
routes routes
}); });
export const updatePageTitle = function updatePageTitle (route) { export const updatePageTitle = function updatePageTitle(route) {
const title = const title =
typeof route.meta.title === 'function' typeof route.meta.title === 'function'
? route.meta.title(route) ? route.meta.title(route)
+1 -1
View File
@@ -20,7 +20,7 @@ import { mount } from '@vue/test-utils';
import { createI18n } from 'vue-i18n'; import { createI18n } from 'vue-i18n';
import { createMemoryHistory, createRouter } from 'vue-router'; import { createMemoryHistory, createRouter } from 'vue-router';
export const mountComponent = function mountComponent (component, options = {}, i18nMessages = {}, routes = [], piniaOptions = {}) { export const mountComponent = function mountComponent(component, options = {}, i18nMessages = {}, routes = [], piniaOptions = {}) {
const { const {
setupStores, setupStores,
...testingPiniaOptions ...testingPiniaOptions
+1 -1
View File
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
export const ensureUnit = function (d) { export const ensureUnit = function(d) {
if (!d) d = 0; if (!d) d = 0;
// ensure that it is a string // ensure that it is a string
+1 -1
View File
@@ -26,7 +26,7 @@ const router = useRouter();
const searchQuery = ref(''); const searchQuery = ref('');
const submitSearch = function () { const submitSearch = function() {
}; };
</script> </script>