Skip to content

Commit

Permalink
Update all .js files to comply with 'npx standard --fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
mmattel committed Jan 23, 2025
1 parent 5b86a68 commit 6bffc56
Show file tree
Hide file tree
Showing 17 changed files with 394 additions and 392 deletions.
86 changes: 43 additions & 43 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
"use strict";
'use strict'

const connect = require("gulp-connect");
const path = require("path");
const gulp = require("gulp");
const del = require("del");
const connect = require('gulp-connect')
const path = require('path')
const gulp = require('gulp')
const del = require('del')

const build = require("./tasks/build");
const buildPreview = require("./tasks/build-preview");
const format = require("./tasks/format");
const lintCss = require("./tasks/lint-css");
const lintJs = require("./tasks/lint-js");
const pack = require("./tasks/pack");
const preview = require("./tasks/preview");
const build = require('./tasks/build')
const buildPreview = require('./tasks/build-preview')
const format = require('./tasks/format')
const lintCss = require('./tasks/lint-css')
const lintJs = require('./tasks/lint-js')
const pack = require('./tasks/pack')
const preview = require('./tasks/preview')

const bundleName = "ui";
const buildDir = "build";
const previewSiteSrcDir = "preview-site-src";
const previewSiteDestDir = "public";
const srcDir = "src";
const destDir = path.join(previewSiteDestDir, "_");
const bundleName = 'ui'
const buildDir = 'build'
const previewSiteSrcDir = 'preview-site-src'
const previewSiteDestDir = 'public'
const srcDir = 'src'
const destDir = path.join(previewSiteDestDir, '_')

const jsFiles = [
"gulpfile.js",
"tasks/**/*.js",
path.join(srcDir, "{helpers,js}/**/*.js"),
];
'gulpfile.js',
'tasks/**/*.js',
path.join(srcDir, '{helpers,js}/**/*.js')
]

gulp.task("clean", function () {
return del(["./public/**", "./build/**"]);
});
gulp.task('clean', function () {
return del(['./public/**', './build/**'])
})

gulp.task("lint:css", () => lintCss(`${srcDir}/css/**/*.css`));
gulp.task("lint:js", () => lintJs(jsFiles));
gulp.task("lint", gulp.parallel("lint:css", "lint:js"));
gulp.task('lint:css', () => lintCss(`${srcDir}/css/**/*.css`))
gulp.task('lint:js', () => lintJs(jsFiles))
gulp.task('lint', gulp.parallel('lint:css', 'lint:js'))

gulp.task("bundle", () => pack(destDir, buildDir, bundleName));
gulp.task('bundle', () => pack(destDir, buildDir, bundleName))

gulp.task("format", () => format(jsFiles));
gulp.task('format', () => format(jsFiles))

gulp.task("build", () => build(srcDir, destDir));
gulp.task('build', () => build(srcDir, destDir))

gulp.task(
"build:preview",
gulp.series("build", () =>
'build:preview',
gulp.series('build', () =>
buildPreview(
srcDir,
destDir,
Expand All @@ -51,23 +51,23 @@ gulp.task(
connect.reload
)
)
);
)

gulp.task(
"preview",
gulp.series("build:preview", () =>
'preview',
gulp.series('build:preview', () =>
preview(previewSiteDestDir, {
host: "0.0.0.0",
host: '0.0.0.0',
port: 5252,
livereload: process.env.LIVERELOAD === "true",
livereload: process.env.LIVERELOAD === 'true',
watch: {
src: [srcDir, previewSiteSrcDir],
onChange: () => gulp.start("build:preview"),
},
onChange: () => gulp.start('build:preview')
}
})
)
);
)

gulp.task("pack", gulp.series("clean", "lint", "build", "bundle"));
gulp.task('pack', gulp.series('clean', 'lint', 'build', 'bundle'))

gulp.task("default", gulp.series("build"));
gulp.task('default', gulp.series('build'))
30 changes: 15 additions & 15 deletions src/helpers/contains.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict'

module.exports = (needle, haystack, options) => {
// searches for a needle in haystack
Expand All @@ -8,33 +8,33 @@ module.exports = (needle, haystack, options) => {
// word is only to go for whole words. blanks and commas separates words (regex \b)
// word just needs to have a value which is converted to true (set) or false (absent)

let startIndex;
let word = false;
let startIndex
let word = false

if (typeof options.hash.startIndex !== "undefined") {
startIndex = options.hash.startIndex;
if (typeof options.hash.startIndex !== 'undefined') {
startIndex = options.hash.startIndex
if (!Number.isInteger(startIndex)) {
startIndex = undefined;
startIndex = undefined
}
}
if (typeof options.hash.word !== "undefined") {
word = options.hash.word;
if (typeof options.hash.word !== 'undefined') {
word = options.hash.word
}

return contains(needle, haystack, startIndex, word);
};
return contains(needle, haystack, startIndex, word)
}

function contains(needle, haystack, startIndex, word) {
function contains (needle, haystack, startIndex, word) {
if (needle == null || haystack == null || isNaN(needle.length)) {
return false;
return false
}

if (word) {
const regex = new RegExp("\\b" + needle + "\\b", "g");
const regex = new RegExp('\\b' + needle + '\\b', 'g')
// no matches gives you null, which is converted to false
// one or more matches gives you an array, which is converted to true
return !!haystack.match(regex);
return !!haystack.match(regex)
} else {
return haystack.indexOf(needle, startIndex) !== -1;
return haystack.indexOf(needle, startIndex) !== -1
}
}
12 changes: 6 additions & 6 deletions src/helpers/year.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
* Licensed under the MIT license.
*/

'use strict';
'use strict'

module.exports = (pattern) => {
const year = new Date().getUTCFullYear().toString();
const year = new Date().getUTCFullYear().toString()

if (typeof pattern !== 'string') {
return year;
return year
}

if (/[Yy]{4}/.test(pattern)) {
return year;
return year
}

if (/[Yy]{2}/.test(pattern)) {
return year.substr(2, 2);
return year.substr(2, 2)
}
};
}
Loading

0 comments on commit 6bffc56

Please sign in to comment.