generated from Seekra/repository-template
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:
@@ -38,11 +38,11 @@ const colorSchemeIconMapper = {
|
||||
'auto': 'circle-black-white'
|
||||
};
|
||||
|
||||
const getTooltipTranslation = function (colorScheme) {
|
||||
const getTooltipTranslation = function(colorScheme) {
|
||||
return t(`preferences.colorScheme.switch.${colorSchemeNextMapper[colorScheme]}`);
|
||||
};
|
||||
|
||||
const setColorScheme = function setColorScheme (newColorScheme) {
|
||||
const setColorScheme = function setColorScheme(newColorScheme) {
|
||||
setSetting(['appearance', 'colorScheme'], newColorScheme);
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -23,7 +23,7 @@ const { getSetting } = useSettings();
|
||||
|
||||
const colorSchemeSettingPath = ['appearance', 'colorScheme'];
|
||||
|
||||
const getWrapper = function getWrapper () {
|
||||
const getWrapper = function getWrapper() {
|
||||
return mountComponent(ColorSchemeButton);
|
||||
};
|
||||
|
||||
|
||||
@@ -29,19 +29,19 @@ const { setSetting, getSetting } = useSettings();
|
||||
const isOpen = ref(false);
|
||||
const languageDropdown = ref(null);
|
||||
|
||||
const selectLanguage = function selectLanguage (code) {
|
||||
const selectLanguage = function selectLanguage(code) {
|
||||
setSetting(LANGUAGE_PATH, code);
|
||||
close();
|
||||
};
|
||||
|
||||
watch(() => getSetting(LANGUAGE_PATH), setLocale);
|
||||
|
||||
const close = function () {
|
||||
const close = function() {
|
||||
document.removeEventListener('click', closeWrapperOnClickOutside);
|
||||
isOpen.value = false;
|
||||
};
|
||||
|
||||
const closeWrapperOnClickOutside = function (e) {
|
||||
const closeWrapperOnClickOutside = function(e) {
|
||||
if (languageDropdown.value) {
|
||||
if (!languageDropdown.value.contains(e.target)) {
|
||||
close();
|
||||
@@ -49,7 +49,7 @@ const closeWrapperOnClickOutside = function (e) {
|
||||
};
|
||||
};
|
||||
|
||||
const open = function () {
|
||||
const open = function() {
|
||||
if (!isOpen.value) {
|
||||
isOpen.value = true;
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -20,7 +20,7 @@ import { mountComponent } from '@/test-utils/mountComponent.js';
|
||||
import { expect, test, describe } from 'vitest';
|
||||
import LanguageSwitchButton from '../LanguageSwitchButton.vue';
|
||||
|
||||
const getWrapper = function getWrapper () {
|
||||
const getWrapper = function getWrapper() {
|
||||
return mountComponent(LanguageSwitchButton);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
export const getNavigatorLanguage = function getNavigatorLanguage () {
|
||||
export const getNavigatorLanguage = function getNavigatorLanguage() {
|
||||
const locale = new Intl.Locale(navigator.language);
|
||||
return locale.language;
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
import { FetchError } from '../errors';
|
||||
import { getAssetsUrl } from '@/config/env';
|
||||
|
||||
const fetchHtml = async function fetchHtml (url, options) {
|
||||
const fetchHtml = async function fetchHtml(url, options) {
|
||||
let response;
|
||||
try {
|
||||
response = await fetch(url, options);
|
||||
@@ -29,7 +29,7 @@ const fetchHtml = async function fetchHtml (url, options) {
|
||||
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 html = await fetchHtml(legalNoticeUrl);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const props = defineProps(['autoSubmit']);
|
||||
|
||||
const submitSearch = function () {
|
||||
const submitSearch = function() {
|
||||
if (props.autoSubmit !== undefined) {
|
||||
router.push({
|
||||
name: 'searchResults',
|
||||
|
||||
@@ -22,7 +22,7 @@ import { useI18n } from 'vue-i18n';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const normalizeSelectedValue = function normalizeSelectedValue (value) {
|
||||
const normalizeSelectedValue = function normalizeSelectedValue(value) {
|
||||
if (props.setting.allowMultiple) {
|
||||
if (Array.isArray(value)) {
|
||||
return value;
|
||||
|
||||
@@ -65,7 +65,7 @@ watch(inputModel, () => {
|
||||
doneButtonInitial.value = false;
|
||||
});
|
||||
|
||||
const apply = function apply () {
|
||||
const apply = function apply() {
|
||||
store.set(props.path, inputModel.value);
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -33,7 +33,7 @@ const props = defineProps({
|
||||
}
|
||||
});
|
||||
|
||||
const followLink = function followLink () {
|
||||
const followLink = function followLink() {
|
||||
goToSettingsPage(props.target);
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -42,7 +42,7 @@ watch(store, (newStore) => {
|
||||
// set value after registering watcher to avoid immediate value change
|
||||
enabled.value = store.get(props.path) ?? props.setting.default;
|
||||
|
||||
const toggle = function toggle () {
|
||||
const toggle = function toggle() {
|
||||
enabled.value = !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 { nextTick } from 'vue';
|
||||
|
||||
const getWrapper = function getWrapper ({
|
||||
const getWrapper = function getWrapper({
|
||||
i18n = 'selection',
|
||||
options = [],
|
||||
allowMultiple = false,
|
||||
@@ -43,7 +43,7 @@ const getWrapper = function getWrapper ({
|
||||
}, translations, [], piniaOptions);
|
||||
};
|
||||
|
||||
const getChecked = function getChecked (inputs) {
|
||||
const getChecked = function getChecked(inputs) {
|
||||
return inputs.map((input) => input.element.matches(':checked'));
|
||||
};
|
||||
|
||||
@@ -199,20 +199,20 @@ describe('Selection', () => {
|
||||
});
|
||||
|
||||
test('stores multiple values', async () => {
|
||||
const setValue = async function setValue (input, value) {
|
||||
const setValue = async function setValue(input, value) {
|
||||
input.setValue(value);
|
||||
await nextTick();
|
||||
};
|
||||
|
||||
const check = function check (input) {
|
||||
const check = function check(input) {
|
||||
return setValue(input, true);
|
||||
};
|
||||
|
||||
const uncheck = function uncheck (input) {
|
||||
const uncheck = function uncheck(input) {
|
||||
return setValue(input, false);
|
||||
};
|
||||
|
||||
const expectSelectionValue = function expectSelectionValue (value, options = exampleOptions) {
|
||||
const expectSelectionValue = function expectSelectionValue(value, options = exampleOptions) {
|
||||
value.sort();
|
||||
expect(store.get('selection').sort()).toStrictEqual(value);
|
||||
const checkedInputs = getChecked(inputs);
|
||||
|
||||
@@ -20,7 +20,7 @@ import { useSettingsStore } from '../../stores/settingsStore.js';
|
||||
import { expect, describe, test } from 'vitest';
|
||||
import { nextTick } from 'vue';
|
||||
|
||||
const getWrapper = function getWrapper ({
|
||||
const getWrapper = function getWrapper({
|
||||
i18n = 'switch1',
|
||||
defaultValue = undefined,
|
||||
translations = {},
|
||||
|
||||
@@ -21,13 +21,13 @@ import { getSettingRecursively } from '../utils/getSetting';
|
||||
/**
|
||||
* Provides access to the stored settings.
|
||||
*/
|
||||
export const useSettings = function useSettings () {
|
||||
export const useSettings = function useSettings() {
|
||||
/**
|
||||
* Returns the value of a specific setting.
|
||||
* @param {string[]} key - The settings key.
|
||||
* @return The value of the setting.
|
||||
*/
|
||||
const getSetting = function getSetting (key) {
|
||||
const getSetting = function getSetting(key) {
|
||||
const settingsStore = useSettingsStore();
|
||||
|
||||
return (
|
||||
@@ -43,7 +43,7 @@ export const useSettings = function useSettings () {
|
||||
* @param {string[]} key - The setting key.
|
||||
* @param value - The new value for the setting.
|
||||
*/
|
||||
const setSetting = function setSetting (key, value) {
|
||||
const setSetting = function setSetting(key, value) {
|
||||
const settingsStore = useSettingsStore();
|
||||
settingsStore.set(key.join('.'), value);
|
||||
};
|
||||
|
||||
@@ -17,10 +17,10 @@ limitations under the License.
|
||||
import { getSettingsPagePathSegments } from '../utils/settingsPage';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
export const useSettingsPage = function useSettingsPage () {
|
||||
export const useSettingsPage = function useSettingsPage() {
|
||||
const router = useRouter();
|
||||
|
||||
const goToSettingsPage = function goToSettingsPage (pagePath) {
|
||||
const goToSettingsPage = function goToSettingsPage(pagePath) {
|
||||
return router.push({
|
||||
name: 'settings',
|
||||
params: {
|
||||
|
||||
@@ -20,19 +20,19 @@ import { reactive } from 'vue';
|
||||
export const useSettingsStore = defineStore('settings', () => {
|
||||
const settings = reactive({});
|
||||
|
||||
const set = function set (key, value) {
|
||||
const set = function set(key, value) {
|
||||
settings[key] = value;
|
||||
};
|
||||
|
||||
const get = function get (key) {
|
||||
const get = function get(key) {
|
||||
return settings[key];
|
||||
};
|
||||
|
||||
const remove = function remove (key) {
|
||||
const remove = function remove(key) {
|
||||
delete settings[key];
|
||||
};
|
||||
|
||||
const clear = function clear () {
|
||||
const clear = function clear() {
|
||||
Object.keys(settings).forEach(key => delete settings[key]);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
|
||||
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];
|
||||
};
|
||||
|
||||
export const getSettingRecursively = function getSettingRecursively (sectionPath, settings) {
|
||||
const oneSettingsLevel = function oneSettingsLevel (cursor, acc) {
|
||||
export const getSettingRecursively = function getSettingRecursively(sectionPath, settings) {
|
||||
const oneSettingsLevel = function oneSettingsLevel(cursor, acc) {
|
||||
const setting = getSetting(cursor[0], acc.content);
|
||||
if (!setting) return;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ limitations under the License.
|
||||
* @param {string} path - The settings page path.
|
||||
* @returns {Array} The settings page path segments.
|
||||
*/
|
||||
export const getSettingsPagePathSegments = function getSettingsPagePathSegments (path) {
|
||||
export const getSettingsPagePathSegments = function getSettingsPagePathSegments(path) {
|
||||
if (typeof path !== 'string') return [];
|
||||
return path
|
||||
.replace(/^\.+|\.+$/g, '')
|
||||
|
||||
@@ -16,13 +16,13 @@ limitations under the License.
|
||||
|
||||
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() === '') {
|
||||
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)) {
|
||||
throw new Error(
|
||||
`[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) {
|
||||
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`);
|
||||
|
||||
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.i18n);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ const activePath = computed(() => {
|
||||
});
|
||||
|
||||
const activeSection = ref(null);
|
||||
const updateSettings = async function updateSettings () {
|
||||
const updateSettings = async function updateSettings() {
|
||||
const setting = getSettingRecursively(activePath.value, settings);
|
||||
if (setting) {
|
||||
activeSection.value = setting;
|
||||
@@ -50,7 +50,7 @@ const updateSettings = async function updateSettings () {
|
||||
watch(route, (newRoute) => updateSettings(newRoute));
|
||||
onMounted(updateSettings);
|
||||
|
||||
const toggleSidebarIfSmallScreen = function toggleSidebarIfSmallScreen (toggleSidebarFunction) {
|
||||
const toggleSidebarIfSmallScreen = function toggleSidebarIfSmallScreen(toggleSidebarFunction) {
|
||||
if (matchMedia('(max-width: 48rem)').matches) toggleSidebarFunction();
|
||||
};
|
||||
</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, [], {});
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ const props = defineProps({
|
||||
});
|
||||
const emit = defineEmits(['toggleExpanded']);
|
||||
|
||||
const toggleSidebar = function toggleSidebar () {
|
||||
const toggleSidebar = function toggleSidebar() {
|
||||
emit('toggleExpanded');
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -19,7 +19,7 @@ import Icon from '@/features/icons/components/Icon.vue';
|
||||
|
||||
const emit = defineEmits(['click']);
|
||||
|
||||
const click = function click (event) {
|
||||
const click = function click(event) {
|
||||
emit('click', event);
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user