1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00

Move helpers/utils exports to end of file

Improves readability by always expecting exports at the end of the file.
This commit is contained in:
Chauncey McAskill
2022-10-13 14:42:22 -04:00
parent 7742bbb9d0
commit 9db0c71a82
7 changed files with 68 additions and 24 deletions

View File

@@ -17,3 +17,7 @@ try {
}
export default loconfig;
export {
loconfig,
};

View File

@@ -31,9 +31,7 @@ try {
// do nothing
}
export const supportsGlob = (typeof glob === 'function');
export default glob;
const supportsGlob = (typeof glob === 'function');
/**
* Imports the first available glob function.
@@ -95,3 +93,10 @@ function createArrayableGlob(glob, options) {
});
};
}
export default glob;
export {
glob,
supportsGlob,
};

View File

@@ -11,7 +11,7 @@ import kleur from 'kleur';
* @param {string} [type] - The type of message.
* @param {string} [timerID] - The console time label to output.
*/
export default function message(text, type, timerID) {
function message(text, type, timerID) {
switch (type) {
case 'success':
console.log('✅ ', kleur.bgGreen().black(text));
@@ -52,4 +52,10 @@ export default function message(text, type, timerID) {
}
console.log('');
}
export default message;
export {
message,
};

View File

@@ -16,7 +16,7 @@ import notifier from 'node-notifier';
* @param {function} callback - The notification callback.
* @return {void}
*/
export default function notification(options, callback) {
function notification(options, callback) {
if (typeof options === 'string') {
options = {
message: options
@@ -42,4 +42,10 @@ export default function notification(options, callback) {
}
notifier.notify(options, callback);
}
export default notification;
export {
notification,
};

View File

@@ -50,18 +50,14 @@ try {
// do nothing
}
export const supportsPostCSS = (typeof postcss === 'function');
const supportsPostCSS = (typeof postcss === 'function');
export default postcss;
export const pluginsList = [
const pluginsList = [
autoprefixer,
];
export const pluginsMap = {
const pluginsMap = {
'autoprefixer': autoprefixer,
};
export {
autoprefixer
};
/**
* Attempts to create a PostCSS Processor with the given plugins and options.
@@ -71,7 +67,7 @@ export {
* @param {PostCSSOptions} options - The PostCSS wrapper options.
* @return {?Processor}
*/
export function createProcessor(pluginsListOrMap, options)
function createProcessor(pluginsListOrMap, options)
{
if (!postcss) {
return null;
@@ -90,7 +86,7 @@ export function createProcessor(pluginsListOrMap, options)
* @param {PostCSSOptions} options - The PostCSS wrapper options.
* @return {PluginList}
*/
export function parsePlugins(pluginsListOrMap, options)
function parsePlugins(pluginsListOrMap, options)
{
if (Array.isArray(pluginsListOrMap)) {
return pluginsListOrMap;
@@ -109,3 +105,15 @@ export function parsePlugins(pluginsListOrMap, options)
return plugins;
}
export default postcss;
export {
autoprefixer,
createProcessor,
parsePlugins,
pluginsList,
pluginsMap,
postcss,
supportsPostCSS,
};

View File

@@ -26,7 +26,7 @@ const templateData = flatten({
* @param {object} [data] - An object in the form `{ 'from': 'to', … }`.
* @return {*} Returns the transformed value.
*/
export default function resolve(input, data = templateData) {
function resolve(input, data = templateData) {
switch (typeof input) {
case 'string': {
return resolveValue(input, data);
@@ -60,7 +60,7 @@ export default function resolve(input, data = templateData) {
* @param {object} [data] - An object in the form `{ 'from': 'to', … }`.
* @return {string} Returns the translated string.
*/
export function resolveValue(input, data = templateData) {
function resolveValue(input, data = templateData) {
const tags = [];
if (data !== templateData) {
@@ -96,3 +96,10 @@ export function resolveValue(input, data = templateData) {
return '';
});
}
export default resolve;
export {
resolve,
resolveValue,
};

View File

@@ -2,13 +2,18 @@
* @file Provides generic functions and constants.
*/
/**
* @type {RegExp} - Match all special characters.
*/
const regexUnescaped = /[\[\]\{\}\(\)\-\*\+\?\.\,\\\^\$\|\#\s]/g;
/**
* Quotes regular expression characters.
*
* @param {string} str - The input string.
* @return {string} Returns the quoted (escaped) string.
*/
export function escapeRegExp(str) {
function escapeRegExp(str) {
return str.replace(regexUnescaped, '\\$&');
}
@@ -41,7 +46,7 @@ export function escapeRegExp(str) {
* @param {object} target - The object that will receive the flattened properties.
* @return {object} Returns the `target` object.
*/
export function flatten(input, prefix, target = {}) {
function flatten(input, prefix, target = {}) {
for (const key in input) {
const field = (prefix ? prefix + '.' + key : key);
@@ -62,7 +67,7 @@ export function flatten(input, prefix, target = {}) {
* @return {boolean} Returns `true` if the value is an `Object`,
* otherwise `false`.
*/
export function isObjectLike(value) {
function isObjectLike(value) {
return (value != null && typeof value === 'object');
}
@@ -75,7 +80,7 @@ export function isObjectLike(value) {
* @throws {TypeError} If the target and source are the same.
* @return {object} Returns the `target` object.
*/
export function merge(target, ...sources) {
function merge(target, ...sources) {
for (const source of sources) {
if (target === source) {
throw new TypeError(
@@ -101,7 +106,10 @@ export function merge(target, ...sources) {
return target;
}
/**
* @type {RegExp} - Match all special characters.
*/
export const regexUnescaped = /[\[\]\{\}\(\)\-\*\+\?\.\,\\\^\$\|\#\s]/g;
export {
escapeRegExp,
flatten,
isObjectLike,
merge,
regexUnescaped,
};