Skip to content

Commit

Permalink
πŸ‘” add & run eslint
Browse files Browse the repository at this point in the history
const
  • Loading branch information
desandro committed Dec 29, 2020
1 parent cf253a4 commit 9a56be1
Show file tree
Hide file tree
Showing 38 changed files with 1,045 additions and 216 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
plugins: [ 'metafizzy' ],
extends: 'plugin:metafizzy/node',
};
48 changes: 23 additions & 25 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/* jshint node: true, undef: true, unused: true */

var gulp = require('gulp');
const gulp = require('gulp');

// ----- site ----- //

var taskName = process.argv[2];
let taskName = process.argv[2];

// stuff used across tasks
var site = {
let site = {
// templating data
data: {
productName: 'Infinite Scroll',
Expand All @@ -18,8 +16,8 @@ var site = {
// src to watch, tasks to trigger
watches: [],
watch: function( src, tasks ) {
site.watches.push( [ src, tasks ] );
}
site.watches.push([ src, tasks ]);
},
};

// ----- tasks ----- //
Expand All @@ -33,32 +31,32 @@ require('./tasks/content')( site );
// ----- default ----- //

gulp.task( 'default', gulp.parallel(
'content',
'js',
'css',
'dist',
'prod-assets',
));
'content',
'js',
'css',
'dist',
'prod-assets',
) );

// ----- export ----- //

// version of site used in infinite-scroll-docs.zip
gulp.task( 'export', gulp.parallel(
'content',
'js',
'css',
'dist',
'assets',
));
'content',
'js',
'css',
'dist',
'assets',
) );

// ----- watch ----- //

gulp.task( 'dev', gulp.parallel(
'dist',
'prod-assets',
'content'
'dist',
'prod-assets',
'content',
), function() {
site.watches.forEach( function( watchable ) {
gulp.watch.apply( gulp, watchable );
});
});
gulp.watch( ...watchable );
} );
} );
20 changes: 20 additions & 0 deletions js/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-env node */

module.exports = {
plugins: [ 'metafizzy' ],
extends: 'plugin:metafizzy/browser',
parserOptions: {
ecmaVersion: 2018,
},
globals: {
FizzyDocs: 'readonly',
fizzyUIUtils: 'readonly',
InfiniteScroll: 'readonly',
InfiniteScrollDocs: 'readonly',
Masonry: 'readonly',
imagesLoaded: 'readonly',
utils: 'readonly',
},
rules: {
},
};
12 changes: 0 additions & 12 deletions js/.jshintrc

This file was deleted.

3 changes: 1 addition & 2 deletions js/boilerplate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// boilerplate
( function() {
'use strict';

// global namespace
window.InfiniteScrollDocs = {};
Expand All @@ -9,4 +8,4 @@ window.InfiniteScrollDocs = {};

window.utils = fizzyUIUtils;

})();
} )();
13 changes: 6 additions & 7 deletions js/init.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
( function() {
'use strict';

// init all modules, based on their data-js attribute
InfiniteScrollDocs.initElementJS = function( elem ) {
var jsModuleElems = elem.querySelectorAll('[data-js]');
for ( var i=0; i < jsModuleElems.length; i++ ) {
var moduleElem = jsModuleElems[i];
var moduleName = moduleElem.getAttribute('data-js');
var module = InfiniteScrollDocs[ moduleName ] || FizzyDocs[ moduleName ];
let jsModuleElems = elem.querySelectorAll('[data-js]');
for ( let i = 0; i < jsModuleElems.length; i++ ) {
let moduleElem = jsModuleElems[i];
let moduleName = moduleElem.getAttribute('data-js');
let module = InfiniteScrollDocs[ moduleName ] || FizzyDocs[ moduleName ];
if ( module ) {
module( moduleElem );
}
Expand All @@ -17,4 +16,4 @@ InfiniteScrollDocs.initElementJS = function( elem ) {
// init all data-js elems
InfiniteScrollDocs.initElementJS( document );

})();
} )();
20 changes: 20 additions & 0 deletions modules/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-env node */

module.exports = {
plugins: [ 'metafizzy' ],
extends: 'plugin:metafizzy/browser',
parserOptions: {
ecmaVersion: 2018,
},
globals: {
FizzyDocs: 'readonly',
fizzyUIUtils: 'readonly',
InfiniteScroll: 'readonly',
InfiniteScrollDocs: 'readonly',
Masonry: 'readonly',
imagesLoaded: 'readonly',
utils: 'readonly',
},
rules: {
},
};
15 changes: 0 additions & 15 deletions modules/.jshintrc

This file was deleted.

4 changes: 2 additions & 2 deletions modules/demos/append/append.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
InfiniteScrollDocs.append = function( elem ) {

var scrollerContent = elem.querySelector('.scroller__content');
let scrollerContent = elem.querySelector('.scroller__content');

new InfiniteScroll( scrollerContent, {
path: 'demo/element-scroll/page{{#}}.html',
Expand All @@ -9,6 +9,6 @@ InfiniteScrollDocs.append = function( elem ) {
elementScroll: elem,
status: elem.querySelector('.scroller-status'),
history: false,
});
} );

};
4 changes: 2 additions & 2 deletions modules/demos/button-option/button-option.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
InfiniteScrollDocs['button-option'] = function( elem ) {

var scrollerContent = elem.querySelector('.scroller__content');
let scrollerContent = elem.querySelector('.scroller__content');

new InfiniteScroll( scrollerContent, {
path: 'demo/element-scroll/page{{#}}.html',
Expand All @@ -11,6 +11,6 @@ InfiniteScrollDocs['button-option'] = function( elem ) {
button: elem.querySelector('.view-more-button'),
status: elem.querySelector('.scroller-status'),
history: false,
});
} );

};
8 changes: 4 additions & 4 deletions modules/demos/button-start/button-start.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
InfiniteScrollDocs['button-start'] = function( elem ) {

var scrollerContent = elem.querySelector('.scroller__content');
let scrollerContent = elem.querySelector('.scroller__content');

var infScroll = new InfiniteScroll( scrollerContent, {
let infScroll = new InfiniteScroll( scrollerContent, {
path: 'demo/element-scroll/page{{#}}.html',
append: '.scroller-item',
checkLastPage: '.pagination__next',
elementScroll: elem,
loadOnScroll: false,
status: elem.querySelector('.scroller-status'),
history: false,
});
} );

var button = elem.querySelector('.view-more-button');
let button = elem.querySelector('.view-more-button');
button.addEventListener( 'click', onButtonClick );

function onButtonClick() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
InfiniteScrollDocs['check-last-page-disabled'] = function( elem ) {

var scrollerContent = elem.querySelector('.scroller__content');
let scrollerContent = elem.querySelector('.scroller__content');

new InfiniteScroll( scrollerContent, {
path: 'demo/element-scroll/page{{#}}.html',
Expand All @@ -11,6 +11,6 @@ InfiniteScrollDocs['check-last-page-disabled'] = function( elem ) {
button: elem.querySelector('.view-more-button'),
status: elem.querySelector('.scroller-status'),
history: false,
});
} );

};
4 changes: 2 additions & 2 deletions modules/demos/debug/debug.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
InfiniteScrollDocs.debug = function( elem ) {

var scrollerContent = elem.querySelector('.scroller__content');
let scrollerContent = elem.querySelector('.scroller__content');

new InfiniteScroll( scrollerContent, {
path: 'demo/element-scroll/page{{#}}.html',
Expand All @@ -10,6 +10,6 @@ InfiniteScrollDocs.debug = function( elem ) {
status: elem.querySelector('.scroller-status'),
history: false,
debug: true,
});
} );

};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ InfiniteScrollDocs['element-scroll-container'] = function( elem ) {
checkLastPage: '.pagination__next',
elementScroll: true,
history: false,
});
} );

};
14 changes: 7 additions & 7 deletions modules/demos/load-count/load-count.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
InfiniteScrollDocs['load-count'] = function( elem ) {

var scroller = elem.querySelector('.scroller');
var scrollerContent = elem.querySelector('.scroller__content');
var demoStatus = elem.querySelector('.demo-status');
let scroller = elem.querySelector('.scroller');
let scrollerContent = elem.querySelector('.scroller__content');
let demoStatus = elem.querySelector('.demo-status');

var infScroll = new InfiniteScroll( scrollerContent, {
let infScroll = new InfiniteScroll( scrollerContent, {
path: 'demo/element-scroll/page{{#}}.html',
append: '.scroller-item',
checkLastPage: '.pagination__next',
elementScroll: scroller,
status: elem.querySelector('.scroller-status'),
history: false,
});
} );

infScroll.on( 'load', function() {
demoStatus.textContent = infScroll.loadCount + ' page' +
demoStatus.textContent = infScroll.loadCount + ' page' +
( infScroll.loadCount > 1 ? 's' : '' ) + ' loaded';
});
} );

};
10 changes: 5 additions & 5 deletions modules/demos/masonry-small/masonry-small.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
InfiniteScrollDocs['masonry-small'] = function( elem ) {

var scrollerContent = elem.querySelector('.scroller__content');
let scrollerContent = elem.querySelector('.scroller__content');

var msnry = new Masonry( scrollerContent, {
let msnry = new Masonry( scrollerContent, {
itemSelector: '.image-grid__item',
columnWidth: '.image-grid__col-sizer',
gutter: '.image-grid__gutter-sizer',
Expand All @@ -11,11 +11,11 @@ InfiniteScrollDocs['masonry-small'] = function( elem ) {
// nicer reveal transition
visibleStyle: { transform: 'translateY(0)', opacity: 1 },
hiddenStyle: { transform: 'translateY(100px)', opacity: 0 },
});
} );

imagesLoaded( scrollerContent, function() {
msnry.layout();
});
} );

new InfiniteScroll( scrollerContent, {
path: 'demo/masonry/page{{#}}.html',
Expand All @@ -25,6 +25,6 @@ InfiniteScrollDocs['masonry-small'] = function( elem ) {
history: false,
elementScroll: elem,
status: elem.querySelector('.scroller-status'),
});
} );

};
12 changes: 6 additions & 6 deletions modules/demos/page-index/page-index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
InfiniteScrollDocs['page-index'] = function( elem ) {

var scroller = elem.querySelector('.scroller');
var scrollerContent = elem.querySelector('.scroller__content');
var demoStatus = elem.querySelector('.demo-status');
let scroller = elem.querySelector('.scroller');
let scrollerContent = elem.querySelector('.scroller__content');
let demoStatus = elem.querySelector('.demo-status');

var infScroll = new InfiniteScroll( scrollerContent, {
let infScroll = new InfiniteScroll( scrollerContent, {
path: 'demo/element-scroll/page{{#}}.html',
append: '.scroller-item',
checkLastPage: '.pagination__next',
elementScroll: scroller,
status: elem.querySelector('.scroller-status'),
history: false,
});
} );

infScroll.on( 'load', function() {
demoStatus.textContent = 'Loaded page: ' + this.pageIndex;
});
} );

};
8 changes: 4 additions & 4 deletions modules/demos/prefill/prefill.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
InfiniteScrollDocs.prefill = function( elem ) {

var scroller = elem.querySelector('.scroller');
var scrollerContent = elem.querySelector('.scroller__content');
var button = elem.querySelector('.button');
let scroller = elem.querySelector('.scroller');
let scrollerContent = elem.querySelector('.scroller__content');
let button = elem.querySelector('.button');

button.addEventListener( 'click', onButtonClick );

Expand All @@ -15,7 +15,7 @@ InfiniteScrollDocs.prefill = function( elem ) {
prefill: true,
status: elem.querySelector('.scroller-status'),
history: false,
});
} );

button.disabled = 'disabled';
button.removeEventListener( 'click', onButtonClick );
Expand Down
Loading

0 comments on commit 9a56be1

Please sign in to comment.