Skip to content

Commit

Permalink
Resolving lint errors (#1347)
Browse files Browse the repository at this point in the history
* Resolving lint errors

* Resolving lint errors under gulp/

* Resolving hasOwnProperty lint error

* Resolving the last lint error

* Improving the if else code

* Reverting changes in jquery.butterfly.js and prism.js

* reverting more lint changes in external libraries

* reverting more lint changes in external libraries

* reverting more lint changes in external libraries

* reverting more lint changes in external libraries

* Reverting changes in ext libraries

* Using var instead of let resolved the lint error

* Using var instead of let resolved the lint error - accordion.js
  • Loading branch information
ghazal-salehi authored Dec 1, 2023
1 parent 5a72eef commit 06ced19
Show file tree
Hide file tree
Showing 37 changed files with 1,709 additions and 1,791 deletions.
12 changes: 6 additions & 6 deletions gulp/build-tasks/assets-includes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ const pjson = require('../../package.json');

module.exports = function (gulp, plugins, config, dest, local = false, relpath = false) {
return function (cb) {
let src = [
const src = [
`${config.basepath.src}/assets/_project/_blocks/layout/**/*.html`,
];
//.concat(config.build.excludes); //remove concat excludes, remove from gulp-config.json also
let versionLocked = {
const versionLocked = {
regex: new RegExp(`/assets/${config.versionName}/{{version}}/`, 'g'),
replacement: `/assets/${config.versionName}/${pjson.version}/`,
};
let cdnLink = {
const cdnLink = {
regex: new RegExp(`="/assets/${config.versionName}`, 'g'),
replacement: `="https://static.qgov.net.au/assets/${config.versionName}`,
};
let folderNameChange = {
regex: new RegExp(`="/assets/includes-local`, 'g'),
replacement: `="/assets/includes-cdn`,
const folderNameChange = {
regex: new RegExp('="/assets/includes-local', 'g'),
replacement: '="/assets/includes-cdn',
};

// Test if the element is set to deploy this component
Expand Down
9 changes: 4 additions & 5 deletions gulp/build-tasks/node-docs-flatten.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
const path = require('path');
const ssiToStatic = require('../ssi-to-static.js');

let includeSrc = path.join('build');
let src = path.join('build', 'docs');
let dest = path.join('build', 'docs');
let exclude = [];
const includeSrc = path.join('build');
const src = path.join('build', 'docs');
const dest = path.join('build', 'docs');
const exclude = [];

ssiToStatic(includeSrc, src, dest, exclude);

4 changes: 2 additions & 2 deletions gulp/build-tasks/serve.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = function (gulp, plugins, connect, connectssi, argv, path, randomPort) {
'use strict';
return (cb) => {
let root = argv.root ? path.resolve(argv.root) : path.resolve('build');
let connectServer = (root, subpath, port) => {
const root = argv.root ? path.resolve(argv.root) : path.resolve('build');
const connectServer = (root, subpath, port) => {
connect.server({
root: subpath ? `${root}/${subpath}` : `${root}`,
port: port || argv.port || 8086,
Expand Down
6 changes: 3 additions & 3 deletions gulp/build-tasks/template-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ module.exports = function (gulp, plugins, config, src, dest, type = 'cdn') {
`${config.basepath.src}/${src}/**/*.html`,
].concat(config.build.excludes); //remove concat excludes, remove from gulp-config.json also

let projectAssets = new RegExp('="(/)?assets/_project/', 'g');
let cdnIncludes = new RegExp('="(/)?assets/includes-cdn/', 'g');
const projectAssets = new RegExp('="(/)?assets/_project/', 'g');
const cdnIncludes = new RegExp('="(/)?assets/includes-cdn/', 'g');
return gulp.src(target, { dot: true })
.pipe(plugins.include({
hardFail: true,
// includePaths: ['/', '/src'],
}))
// Replace /assets/_project/ with /assets/v3/
.pipe(plugins.replace(projectAssets, `="$1assets/${config.versionName}/`))
.pipe(plugins.if(type === 'local', plugins.replace(cdnIncludes, `="$1assets/includes-local/`))) // Replace cdn assets with local assets
.pipe(plugins.if(type === 'local', plugins.replace(cdnIncludes, '="$1assets/includes-local/'))) // Replace cdn assets with local assets
.on('error', console.log)
.pipe(gulp.dest(`${config.basepath.build}/${dest}/`));
};
Expand Down
2 changes: 1 addition & 1 deletion gulp/common-tasks/js-webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function (gulp, plugins, config, destFolder, banner) {
return `/assets/${config.versionName}`;
}
};
let dest = {
const dest = {
base: `${config.basepath.build}`,
release: `${config.basepath.build}`,
ext: `${config.versionName}/latest/js`,
Expand Down
6 changes: 3 additions & 3 deletions gulp/publish-tasks/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const gitFunctions = {
branch: (folder, argv) => {
return (cb) => {
let branchname = `v${pjson.version}-test`;
branchname += argv.hasOwnProperty('branch') ? `--${argv.branch}` : '';
branchname += Object.prototype.hasOwnProperty.call(argv, 'branch') ? `--${argv.branch}` : '';
if (folder) process.chdir(path.resolve(folder));
return git.checkout(branchname, { args: '-B' }, function (err) {
if (err) throw err;
Expand All @@ -45,7 +45,7 @@ const gitFunctions = {
},
sync: (from, to, ignore) => {
return (cb) => {
let ignoreFiles = ['.git', '.gitignore'].concat(ignore);
const ignoreFiles = ['.git', '.gitignore'].concat(ignore);
return gulp
.src(`${from}/**/*`)
.pipe(
Expand Down Expand Up @@ -115,7 +115,7 @@ const gitFunctions = {
});
} else {
let branchname = `v${pjson.version}-test`;
branchname += argv.hasOwnProperty('branch') ? `--${argv.branch}` : '';
branchname += Object.prototype.hasOwnProperty.call(argv, 'branch') ? `--${argv.branch}` : '';
return git.push('origin', [branchname], { args: ' -f' }, function (err) {
if (err) throw err;
cb();
Expand Down
4 changes: 2 additions & 2 deletions gulp/release-tasks/docs-pages-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

module.exports = function (gulp, plugins, config, local = false, relpath = false) {
return function (cb) {
let src = [
const src = [
`${config.basepath.release}/docs/**/*.html`,
];

let relLink = {
const relLink = {
regex: new RegExp('="/assets/', 'g'),
replacement: '="assets/',
};
Expand Down
4 changes: 2 additions & 2 deletions gulp/release-tasks/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function (gulp, plugins, config, es, path, banner) {
`!**/${config.versionName}/**/*.js`, // handled by JS task that minifies
`!**/${config.versionName}/**/*.css`, // handled by SCSS -> CSS task that minifies
].concat(config.release.excludes);
let includesLink = {
const includesLink = {
cdnRegex: new RegExp('="(/)?assets/includes-cdn/', 'g'),
localRegex: new RegExp('="(/)?assets/includes-local/', 'g'),
cdnReplacement: '="$1assets/includes-cdn/',
Expand Down Expand Up @@ -60,7 +60,7 @@ module.exports = function (gulp, plugins, config, es, path, banner) {
//CSS task
gulp.src(`${config.basepath.build}/assets/${config.versionName}/**/*.css`, { dot: true })
.pipe(plugins.postcss([cssnano({
discardComments: {removeAll: true},
discardComments: { removeAll: true },
})]))
.on('error', console.log)
.pipe(plugins.insert.prepend(banner))
Expand Down
2 changes: 1 addition & 1 deletion gulp/ssi-to-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = function (includeSrc, src, dest, exclude) {
baseDir: includeSrc, // Source of includes
});

let filesList = getFiles(src);
const filesList = getFiles(src);
filesList.forEach(function (file) {
ssi.compileFile(file, function (err, content) {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion gulp/test-tasks/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function (gulp, plugins, argv) {
console.log('\x1b[33m%s\x1b[0m: ', '1.) Browsers list missing. Example gulp test:browserstack --browsers ie,safari\n2.) Also make sure to run gulp serve to start a local server before performing e2e testing');
return;
}
gulp.src('', {read: false})
gulp.src('', { read: false })
.pipe(plugins.shell([
'node tests/e2e/runner.js -c tests/e2e/conf.js -e ' + argv.browsers,
]));
Expand Down
14 changes: 7 additions & 7 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ gulp.task('template-pages', require('./gulp/build-tasks/template-pages')(gulp, p
gulp.task('template-pages-docs', require('./gulp/build-tasks/template-pages')(gulp, plugins, config, 'docs', 'docs'));
gulp.task('template-pages-to-docs', require('./gulp/build-tasks/template-pages')(gulp, plugins, config, 'template-pages', 'docs/pagemodels'));

let assetDests = ['assets', 'docs/assets'];
const assetDests = ['assets', 'docs/assets'];
gulp.task('scss', require('./gulp/common-tasks/scss')(gulp, plugins, config, assetDests, addSrc));
gulp.task('js', require('./gulp/common-tasks/js-webpack.js')(gulp, plugins, config, assetDests, banner));
gulp.task('other-assets-root', require('./gulp/build-tasks/other-assets')(gulp, plugins, config, es, assetDests[0]));
Expand Down Expand Up @@ -104,7 +104,7 @@ gulp.task('release', gulp.series(
});

/* LOCAL SERVER */
let randomPort = Math.floor(1000 + Math.random() * 9000);
const randomPort = Math.floor(1000 + Math.random() * 9000);
gulp.task('serve', require('./gulp/build-tasks/serve')(gulp, plugins, connect, connectssi, argv, path, randomPort));

/* PUBLISH TASKS */
Expand All @@ -115,10 +115,10 @@ gulp.task('wt-clone', require('./gulp/publish-tasks/git').clone(config.webTempla
// wt-branch task creates a test branch on 'web-template-release'.
gulp.task('wt-branch', require('./gulp/publish-tasks/git').branch(config.webTemplateRepo.folder, argv));
gulp.task('wt-sync', require('./gulp/publish-tasks/git').sync(config.basepath.release, config.webTemplateRepo.folder, ['package.json']));
gulp.task('wt-updateVersion', require('./gulp/publish-tasks/git').updateVersion(config.webTemplateRepo.folder, pjson['version']));
gulp.task('wt-updateVersion', require('./gulp/publish-tasks/git').updateVersion(config.webTemplateRepo.folder, pjson.version));
gulp.task('wt-add', require('./gulp/publish-tasks/git').add(config.webTemplateRepo.folder));
gulp.task('wt-commit', require('./gulp/publish-tasks/git').commit(config.webTemplateRepo.folder, pjson['version']));
gulp.task('wt-tag', require('./gulp/publish-tasks/git').tag(config.webTemplateRepo.folder, pjson['version']));
gulp.task('wt-commit', require('./gulp/publish-tasks/git').commit(config.webTemplateRepo.folder, pjson.version));
gulp.task('wt-tag', require('./gulp/publish-tasks/git').tag(config.webTemplateRepo.folder, pjson.version));
gulp.task('wt-push', require('./gulp/publish-tasks/git').push(config.webTemplateRepo.folder, argv));

// CDN release
Expand All @@ -132,9 +132,9 @@ gulp.task('cdn-push', require('./gulp/publish-tasks/git').push(config.staticCdnR

// SWE release
gulp.task('swe-add', require('./gulp/publish-tasks/git').add());
gulp.task('swe-commit', require('./gulp/publish-tasks/git').commit('./', pjson['version']));
gulp.task('swe-commit', require('./gulp/publish-tasks/git').commit('./', pjson.version));
gulp.task('swe-push', require('./gulp/publish-tasks/git').push('./', argv));
gulp.task('swe-tag', require('./gulp/publish-tasks/git').tag('./', pjson['version']));
gulp.task('swe-tag', require('./gulp/publish-tasks/git').tag('./', pjson.version));

/* WATCH TASKS */
// Note: External libraries and external modules are not watched
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ function opensInNewWindow () {
}

function addCorrectIncorrect () {
let ext = ':not(:has(.qg-blank-notice))';
let $correct = $(`.qg-correct${ext}, table.qg-correct-incorrect td:nth-child(odd)${ext}`);
let $incorrect = $(`.qg-incorrect${ext}, table.qg-correct-incorrect td:nth-child(even)${ext}`);
const ext = ':not(:has(.qg-blank-notice))';
const $correct = $(`.qg-correct${ext}, table.qg-correct-incorrect td:nth-child(odd)${ext}`);
const $incorrect = $(`.qg-incorrect${ext}, table.qg-correct-incorrect td:nth-child(even)${ext}`);

$correct.prepend('<span class="qg-blank-notice sr-only">Correct.</span> ');
$incorrect.prepend('<span class="qg-blank-notice sr-only">Incorrect.</span> ');
Expand All @@ -37,4 +37,3 @@ function init () {
}

module.exports = { init: init };

22 changes: 11 additions & 11 deletions src/assets/_project/_blocks/components/accordion/qg-accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export class QgAccordion {
* @return {undefined}
**/
hashTrigger(){
let self = this;
let hashValTrimmed = this.filterSpecialChar(self.urlHashVal);
let hashValueIdMatch = self.urlHashVal.replace('#', '');
const self = this;
const hashValTrimmed = this.filterSpecialChar(self.urlHashVal);
const hashValueIdMatch = self.urlHashVal.replace('#', '');
if (hashValTrimmed.length > 0) {
// supports ID match
self.$accordion.find('.collapsing-section').each(function (index, titleEl){
Expand Down Expand Up @@ -85,8 +85,8 @@ export class QgAccordion {
* @return {undefined}
**/
accordionPanelClick(){
let self = this;
let accHeading = self.$accordion_v2.find(self.$accHeading);
const self = this;
const accHeading = self.$accordion_v2.find(self.$accHeading);
accHeading.on('click', function (event) {
self.toggleOpenCloseClass($(this));
});
Expand Down Expand Up @@ -115,7 +115,7 @@ export class QgAccordion {
* @return {undefined}
**/
collapseAll(){
let self = this;
const self = this;
// collapse all click
// label selector is to provide backward compatibility in case projects are using old markup
$('.qg-acc-controls .collapse, label[for=\'collapse\']').on('click keypress', function (event) {
Expand All @@ -133,7 +133,7 @@ export class QgAccordion {
* @return {undefined}
**/
expandAll(){
let self = this;
const self = this;
//expand all click
// label selector is to provide backward compatibility in case projects are using old markup
$('.qg-acc-controls .expand, label[for=\'expand\']').on('click keypress', function (event) {
Expand All @@ -152,7 +152,7 @@ export class QgAccordion {
**/
gaTracking(){
this.$accordion.find('.qg-accordion--ga').each(function(){
let title = 'accordion title - ' + $(this).find($('.title')).text();
const title = 'accordion title - ' + $(this).find($('.title')).text();
$(this).attr('data-analytics-link-group', title);
});
}
Expand All @@ -162,13 +162,13 @@ export class QgAccordion {
* @return {undefined}
**/
legacyAccordion(){
let self = this;
let accItem = $('.qg-accordion:not(.qg-accordion-v2)').find('article');
var self = this;
var accItem = $('.qg-accordion:not(.qg-accordion-v2)').find('article');
accItem.find('.acc-heading').on('keypress', function (event) {
if (event.target === event.currentTarget) {
event.preventDefault();
if (self.keyboardAccessibility(event) === true) {
let parent = $(this).parent();
const parent = $(this).parent();
if (parent.find('input[name="tabs"]:checked').length > 0) {
parent.find('input[name="tabs"]').prop('checked', false);
} else {
Expand Down
14 changes: 7 additions & 7 deletions src/assets/_project/_blocks/components/carousel/qg-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
'use strict';

(function ($) {
let carousels = [];
var carousels = [];

let eqHeight = (carousels) => {
const eqHeight = (carousels) => {
//For each carousel on the page...
carousels.forEach(function (carousel) {
//Get the height of each carousel slide in the carousel...
let slides = $('#' + carousel).find('.carousel-item');
const slides = $('#' + carousel).find('.carousel-item');

//Each slides height into an array...
let slideHeights = slides.map(function(e, slide) {
const slideHeights = slides.map(function(e, slide) {
return $(slide).height();
});

Expand All @@ -23,7 +23,7 @@
};

$('.qg-featured .carousel.slide').each(function (int, element) {
let carouselID = $(element).attr('id');
const carouselID = $(element).attr('id');
carousels.push(carouselID);

//Start all slides to cycle by default
Expand All @@ -32,8 +32,8 @@
//Bind click/tap event
$('#' + carouselID).find('.toggleCarousel').on('click', function (e) {
e.preventDefault();
let parentCarousel = $(this).parents('div.carousel.slide');
let currentState = parentCarousel.attr('data-state');
const parentCarousel = $(this).parents('div.carousel.slide');
const currentState = parentCarousel.attr('data-state');
switch (currentState) {
//If paused, switch to cycling state
case 'pause':
Expand Down
Loading

0 comments on commit 06ced19

Please sign in to comment.