aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2020-10-19 22:25:46 +1100
committerSam Potts <sam@potts.es>2020-10-19 22:25:46 +1100
commitfa653a8859a4191d30d90f0b560bbb4c5c3b83ac (patch)
treea86b1f5f860350470b602e3c5a8663b4fd095735
parentb6b7db73277184d472c03bfde9eab2fdfe21dd1a (diff)
downloadplyr-fa653a8859a4191d30d90f0b560bbb4c5c3b83ac.tar.lz
plyr-fa653a8859a4191d30d90f0b560bbb4c5c3b83ac.tar.xz
plyr-fa653a8859a4191d30d90f0b560bbb4c5c3b83ac.zip
chore: linting
-rw-r--r--demo/src/js/demo.js10
-rw-r--r--demo/src/js/tab-focus.js4
-rw-r--r--src/js/plyr.d.ts87
-rw-r--r--tasks/build.js6
-rw-r--r--tasks/deploy.js16
5 files changed, 57 insertions, 66 deletions
diff --git a/demo/src/js/demo.js b/demo/src/js/demo.js
index 6c5f7eb8..1101fd97 100644
--- a/demo/src/js/demo.js
+++ b/demo/src/js/demo.js
@@ -22,7 +22,7 @@ import toggleClass from './toggle-class';
if (window.location.host === production) {
Sentry.init({
dsn: 'https://d4ad9866ad834437a4754e23937071e4@sentry.io/305555',
- whitelistUrls: [production].map(d => new RegExp(`https://(([a-z0-9])+(.))*${d}`)),
+ whitelistUrls: [production].map((d) => new RegExp(`https://(([a-z0-9])+(.))*${d}`)),
});
}
@@ -79,13 +79,13 @@ import toggleClass from './toggle-class';
function render(type) {
// Remove active classes
- Array.from(buttons).forEach(button => toggleClass(button.parentElement, 'active', false));
+ Array.from(buttons).forEach((button) => toggleClass(button.parentElement, 'active', false));
// Set active on parent
toggleClass(document.querySelector(`[data-source="${type}"]`), 'active', true);
// Show cite
- Array.from(document.querySelectorAll('.plyr__cite')).forEach(cite => {
+ Array.from(document.querySelectorAll('.plyr__cite')).forEach((cite) => {
// eslint-disable-next-line no-param-reassign
cite.hidden = true;
});
@@ -110,7 +110,7 @@ import toggleClass from './toggle-class';
}
// Bind to each button
- Array.from(buttons).forEach(button => {
+ Array.from(buttons).forEach((button) => {
button.addEventListener('click', () => {
const type = button.getAttribute('data-source');
@@ -123,7 +123,7 @@ import toggleClass from './toggle-class';
});
// List for backwards/forwards
- window.addEventListener('popstate', event => {
+ window.addEventListener('popstate', (event) => {
if (event.state && Object.keys(event.state).includes('type')) {
setSource(event.state.type);
}
diff --git a/demo/src/js/tab-focus.js b/demo/src/js/tab-focus.js
index b13049bc..935a3c42 100644
--- a/demo/src/js/tab-focus.js
+++ b/demo/src/js/tab-focus.js
@@ -3,7 +3,7 @@ const container = document.getElementById('container');
const tabClassName = 'tab-focus';
// Remove class on blur
-document.addEventListener('focusout', event => {
+document.addEventListener('focusout', (event) => {
if (!event.target.classList || container.contains(event.target)) {
return;
}
@@ -12,7 +12,7 @@ document.addEventListener('focusout', event => {
});
// Add classname to tabbed elements
-document.addEventListener('keydown', event => {
+document.addEventListener('keydown', (event) => {
if (event.keyCode !== 9) {
return;
}
diff --git a/src/js/plyr.d.ts b/src/js/plyr.d.ts
index 572ed2da..ce8f428a 100644
--- a/src/js/plyr.d.ts
+++ b/src/js/plyr.d.ts
@@ -214,26 +214,17 @@ declare class Plyr {
/**
* Add an event listener for the specified event.
*/
- on<K extends keyof Plyr.PlyrEventMap>(
- event: K,
- callback: (this: this, event: Plyr.PlyrEventMap[K]) => void,
- ): void;
+ on<K extends keyof Plyr.PlyrEventMap>(event: K, callback: (this: this, event: Plyr.PlyrEventMap[K]) => void): void;
/**
* Add an event listener for the specified event once.
*/
- once<K extends keyof Plyr.PlyrEventMap>(
- event: K,
- callback: (this: this, event: Plyr.PlyrEventMap[K]) => void,
- ): void;
+ once<K extends keyof Plyr.PlyrEventMap>(event: K, callback: (this: this, event: Plyr.PlyrEventMap[K]) => void): void;
/**
* Remove an event listener for the specified event.
*/
- off<K extends keyof Plyr.PlyrEventMap>(
- event: K,
- callback: (this: this, event: Plyr.PlyrEventMap[K]) => void,
- ): void;
+ off<K extends keyof Plyr.PlyrEventMap>(event: K, callback: (this: this, event: Plyr.PlyrEventMap[K]) => void): void;
/**
* Check support for a mime type.
@@ -250,45 +241,45 @@ declare namespace Plyr {
type MediaType = 'audio' | 'video';
type Provider = 'html5' | 'youtube' | 'vimeo';
type StandardEventMap = {
- 'progress': PlyrEvent,
- 'playing': PlyrEvent,
- 'play': PlyrEvent,
- 'pause': PlyrEvent,
- 'timeupdate': PlyrEvent,
- 'volumechange': PlyrEvent,
- 'seeking': PlyrEvent,
- 'seeked': PlyrEvent,
- 'ratechange': PlyrEvent,
- 'ended': PlyrEvent,
- 'enterfullscreen': PlyrEvent,
- 'exitfullscreen': PlyrEvent,
- 'captionsenabled': PlyrEvent,
- 'captionsdisabled': PlyrEvent,
- 'languagechange': PlyrEvent,
- 'controlshidden': PlyrEvent,
- 'controlsshown': PlyrEvent,
- 'ready': PlyrEvent
+ progress: PlyrEvent;
+ playing: PlyrEvent;
+ play: PlyrEvent;
+ pause: PlyrEvent;
+ timeupdate: PlyrEvent;
+ volumechange: PlyrEvent;
+ seeking: PlyrEvent;
+ seeked: PlyrEvent;
+ ratechange: PlyrEvent;
+ ended: PlyrEvent;
+ enterfullscreen: PlyrEvent;
+ exitfullscreen: PlyrEvent;
+ captionsenabled: PlyrEvent;
+ captionsdisabled: PlyrEvent;
+ languagechange: PlyrEvent;
+ controlshidden: PlyrEvent;
+ controlsshown: PlyrEvent;
+ ready: PlyrEvent;
};
// For retrocompatibility, we keep StandadEvent
type StandadEvent = keyof Plyr.StandardEventMap;
type Html5EventMap = {
- 'loadstart': PlyrEvent,
- 'loadeddata': PlyrEvent,
- 'loadedmetadata': PlyrEvent,
- 'canplay': PlyrEvent,
- 'canplaythrough': PlyrEvent,
- 'stalled': PlyrEvent,
- 'waiting': PlyrEvent,
- 'emptied': PlyrEvent,
- 'cuechange': PlyrEvent,
- 'error': PlyrEvent
+ loadstart: PlyrEvent;
+ loadeddata: PlyrEvent;
+ loadedmetadata: PlyrEvent;
+ canplay: PlyrEvent;
+ canplaythrough: PlyrEvent;
+ stalled: PlyrEvent;
+ waiting: PlyrEvent;
+ emptied: PlyrEvent;
+ cuechange: PlyrEvent;
+ error: PlyrEvent;
};
// For retrocompatibility, we keep Html5Event
type Html5Event = keyof Plyr.Html5EventMap;
type YoutubeEventMap = {
- 'statechange': PlyrStateChangeEvent,
- 'qualitychange': PlyrEvent,
- 'qualityrequested': PlyrEvent
+ statechange: PlyrStateChangeEvent;
+ qualitychange: PlyrEvent;
+ qualityrequested: PlyrEvent;
};
// For retrocompatibility, we keep YoutubeEvent
type YoutubeEvent = keyof Plyr.YoutubeEventMap;
@@ -643,14 +634,14 @@ declare namespace Plyr {
PLAYING = 1,
PAUSED = 2,
BUFFERING = 3,
- CUED = 5
+ CUED = 5,
}
-
+
interface PlyrStateChangeEvent extends CustomEvent {
readonly detail: {
- readonly plyr: Plyr,
- readonly code: YoutubeState
- }
+ readonly plyr: Plyr;
+ readonly code: YoutubeState;
+ };
}
interface Support {
diff --git a/tasks/build.js b/tasks/build.js
index c9709060..271545d9 100644
--- a/tasks/build.js
+++ b/tasks/build.js
@@ -75,8 +75,8 @@ const tasks = {
const sizeOptions = { showFiles: true, gzip: true };
// Clean out /dist
-gulp.task('clean', done => {
- const dirs = [paths.plyr.output, paths.demo.output].map(dir => path.join(dir, '**/*'));
+gulp.task('clean', (done) => {
+ const dirs = [paths.plyr.output, paths.demo.output].map((dir) => path.join(dir, '**/*'));
// Don't delete the mp4
dirs.push(`!${path.join(paths.plyr.output, '**/*.mp4')}`);
@@ -90,7 +90,7 @@ gulp.task('clean', done => {
Object.entries(build.js).forEach(([filename, entry]) => {
const { dist, formats, namespace, polyfill, src } = entry;
- formats.forEach(format => {
+ formats.forEach((format) => {
const name = `js:${filename}:${format}`;
const extension = format === 'es' ? 'mjs' : 'js';
tasks.js.push(name);
diff --git a/tasks/deploy.js b/tasks/deploy.js
index d505d188..42fa14e8 100644
--- a/tasks/deploy.js
+++ b/tasks/deploy.js
@@ -27,7 +27,7 @@ const { version } = pkg;
const minSuffix = '.min';
// Get AWS config
-Object.values(deploy).forEach(target => {
+Object.values(deploy).forEach((target) => {
Object.assign(target, {
publisher: publish.create({
region: target.region,
@@ -102,7 +102,7 @@ const localPath = new RegExp('(../)?dist/', 'gi');
const versionPath = `https://${deploy.cdn.domain}/${version}/`;
const cdnpath = new RegExp(`${deploy.cdn.domain}/${regex}/`, 'gi');
-const renameFile = rename(p => {
+const renameFile = rename((p) => {
p.basename = p.basename.replace(minSuffix, ''); // eslint-disable-line
p.dirname = p.dirname.replace('.', version); // eslint-disable-line
});
@@ -120,7 +120,7 @@ const canDeploy = () => {
return true;
};
-gulp.task('version', done => {
+gulp.task('version', (done) => {
if (!canDeploy()) {
done();
return null;
@@ -135,7 +135,7 @@ gulp.task('version', done => {
return gulp
.src(
- files.map(file => path.join(root, `src/js/${file}`)),
+ files.map((file) => path.join(root, `src/js/${file}`)),
{ base: '.' },
)
.pipe(replace(semver, `v${version}`))
@@ -144,7 +144,7 @@ gulp.task('version', done => {
});
// Publish version to CDN bucket
-gulp.task('cdn', done => {
+gulp.task('cdn', (done) => {
if (!canDeploy()) {
done();
return null;
@@ -198,7 +198,7 @@ gulp.task('purge', () => {
.on('end', () => {
const purge = new FastlyPurge(fastly.token);
- list.forEach(url => {
+ list.forEach((url) => {
log(`Purging ${ansi.cyan(url)}...`);
purge.url(url, (error, result) => {
@@ -213,7 +213,7 @@ gulp.task('purge', () => {
});
// Publish to demo bucket
-gulp.task('demo', done => {
+gulp.task('demo', (done) => {
if (!canDeploy()) {
done();
return null;
@@ -248,7 +248,7 @@ gulp.task('demo', done => {
.src(pages)
.pipe(replace(localPath, versionPath))
.pipe(
- rename(p => {
+ rename((p) => {
if (options.demo.uploadPath) {
// eslint-disable-next-line no-param-reassign
p.dirname += options.demo.uploadPath;