From bed0c628219e29f40fe3e1e54068b3d37c1d5fb9 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Wed, 14 Mar 2018 11:30:25 -0700 Subject: [PATCH] Cleanup warnings Fixes a bunch of jshint and Moment warnings. --- client/src/components/Admin.js | 2 +- .../src/components/ClippingContainerComponent.js | 2 +- client/src/components/Landing.js | 2 +- client/src/components/Main.js | 1 - client/src/components/ShareContainerComponent.js | 2 +- client/src/data/most-recent-placeholder.js | 2 -- server/routes/admin.js | 2 +- server/routes/all-episode-data.js | 2 +- server/routes/create-video.js | 8 ++++---- server/routes/get-episode.js | 4 ++-- server/routes/getTranscript.js | 4 ++-- server/routes/helpers.js | 14 ++++++++------ server/routes/makeWaveform.js | 5 +---- 13 files changed, 23 insertions(+), 27 deletions(-) delete mode 100644 client/src/data/most-recent-placeholder.js diff --git a/client/src/components/Admin.js b/client/src/components/Admin.js index 9340cb4..b4975cc 100644 --- a/client/src/components/Admin.js +++ b/client/src/components/Admin.js @@ -108,7 +108,7 @@ class AdminComponent extends React.PureComponent { return (
-
+
diff --git a/client/src/components/ClippingContainerComponent.js b/client/src/components/ClippingContainerComponent.js index aec5f6b..e5fe5ba 100644 --- a/client/src/components/ClippingContainerComponent.js +++ b/client/src/components/ClippingContainerComponent.js @@ -169,7 +169,7 @@ class ClippingContainer extends React.PureComponent {
} - const friendlyDate = moment(this.props.airDate).format('LL'); + const friendlyDate = moment(this.props.airDate, 'LL'); // axis of slider should be top or left? // const scrubberAxis = window.innerWidth > '992' ? 'x' : 'y-reverse'; diff --git a/client/src/components/Landing.js b/client/src/components/Landing.js index 61b778b..cc43a5e 100644 --- a/client/src/components/Landing.js +++ b/client/src/components/Landing.js @@ -42,7 +42,7 @@ function Landing(props) { {ep.title} - {ep.original_air_date ? ` | ${moment(ep.original_air_date).format('LL')}` : ''} + {ep.original_air_date ? ` | ${moment(ep.original_air_date, 'LL')}` : ''}

diff --git a/client/src/components/Main.js b/client/src/components/Main.js index a99f71d..2ba5116 100644 --- a/client/src/components/Main.js +++ b/client/src/components/Main.js @@ -6,7 +6,6 @@ const Store = require('store'); // localStorage const isSecure = window.location.protocol == 'https:'; const apiEndpoint_default = isSecure ? require('config').default.apiEndpointSsl : require('config').default.apiEndpoint; -const dataBucket = require('config').default.dataBucket; const maxClipSeconds = require('config').default.maxClipSeconds; const minClipSeconds = require('config').default.minClipSeconds; const env = require('config').default.appEnv; diff --git a/client/src/components/ShareContainerComponent.js b/client/src/components/ShareContainerComponent.js index 99d81b2..567dda3 100644 --- a/client/src/components/ShareContainerComponent.js +++ b/client/src/components/ShareContainerComponent.js @@ -84,7 +84,7 @@ class ShareContainerComponent extends React.Component { return (

-
Previewing
{this.props.episode} | {moment(this.props.airDate).format('LL')}
+
Previewing
{this.props.episode} | {moment(this.props.airDate, 'LL')}
return to Greece with stories of people trying to move on with their lives in whatever way they can. We meet a couple who fell in love even though they weren't expecting anything like that to happen, and even though her family didn't approve. We also meet a shopkeeper in a camp who's running what amounts to a cigarette charity. INTERACTIVE TOUR | PART ONE","original_air_date":"2016-08-05T00:00:00","title":"Don’t Have to Live Like a Refugee"},{"number":"592","description":"A bunch of us from our show went to refugee camps all over Greece. We found people falling in love, kids mad at their parents for dragging them to Europe, women doing their laundry in a baseball stadium locker room, and hundreds of people living at a gas station—sitting next to the pumps, smoking. Also: wild pigs. 57,000 refugees are stuck in Greece, making homes in some surprising locations. We hear what that’s really like. INTERACTIVE TOUR | PART TWO","original_air_date":"2016-07-29T00:00:00","title":"Are We There Yet?"},{"number":"591","description":"Stories of people trying to make sure they get what they paid for, from political change to bedroom slippers. We follow a donor as he vets presidential candidates, and go inside a company wrestling with the consequences of its \"no questions asked,” lifetime return policy.","original_air_date":"2016-07-15T00:00:00","title":"Get Your Money's Worth"},{"number":"590","description":"Stories of people making the wrong choice, even though the right one is staring them squarely in the eye. Basketball players making a conscious decision to not do the thing that makes them better, pollsters refusing to see the truth of Donald Trump, and more.","original_air_date":"2016-06-24T00:00:00","title":"Choosing Wrong"},{"number":"589","description":"The way people talk about being fat is shifting. With one-third of Americans classified as overweight, and another third as obese, and almost none of us losing weight and keeping it off, maybe it’s time to rethink the way we see being fat. A show inspired by Lindy West’s book Shrill.","original_air_date":"2016-06-17T00:00:00","title":"Tell Me I'm Fat"},{"number":"588","description":"Stories of people who try simple mind games on others, and then find themselves in way over their heads.","original_air_date":"2016-06-03T00:00:00","title":"Mind Games 2016"},{"number":"587","description":"Stories about mysteries that exist in relationships we thought couldn't possibly surprise us, and the strangeness of putting our wants on the line with someone who may not share them at all-- and how much we're willing to risk for someone we may never see again.","original_air_date":"2016-05-27T00:00:00","title":"The Perils of Intimacy"},{"number":"586","description":"It’s nice to belong, to feel connected to others. But what happens when you realize that your fundamental beliefs don’t line up with the people you want to be close to? Do you bring it up? And, what does that conversation sound like? Including a story by Mariya Karimjee, pictured. Guest host Sean Cole sits in for Ira.","original_air_date":"2016-05-06T00:00:00","title":"Who Do We Think We Are?"},{"number":"585","description":"Exactly how incompetent you are. What your ex’s best friend really thinks of you. The approximate time that you will die. Some things in life are better not to know about. And sometimes there can be a benefit to not knowing. In this episode – examples of ignorance truly being bliss, or even being an asset","original_air_date":"2016-04-22T00:00:00","title":"In Defense of Ignorance"},{"number":"584","description":"The older and wiser we get, the more bewildering our past decisions can seem. This week, people revisit those decisions — and we revisit a story we aired a year ago with new, fascinating updates about a groundbreaking study that turned out to be false.","original_air_date":"2016-04-08T00:00:00","title":"For Your Reconsideration"},{"number":"583","description":"At first, it’s super annoying, getting told it’ll make sense when you’re older. Then, when you’re a teenager, hard lessons are learned, despite your best efforts to be too cool to care. By the time you’re actually old, you know a bunch of stuff— and you’re desperate to hold onto it. You might even wonder HOW you know all the things you know. Hosted by Chana Joffe-Walt and featuring SNL’s Sasheer Zamata.","original_air_date":"2016-03-25T00:00:00","title":"It'll Make Sense When You're Older"},{"number":"582","description":"We human beings think we run the world, that we’ve got things under control. And then an animal shows up, and things don’t go as planned. We have stories this week where seals, wolves and a moose drop in and show us who isn't boss.","original_air_date":"2016-03-11T00:00:00","title":"When the Beasts Come Marching In"},{"number":"581","description":"This week, a story about doubt: how it germinated, spread, and eventually took hold of an entire community, with terrible consequences. A collaboration with The Marshall Project and ProPublica.","original_air_date":"2016-02-26T00:00:00","title":"Anatomy of Doubt"},{"number":"580","description":"Forget the easy way. This week, stories about people who come up with very innovative…and unusual...solutions to their problems. Including the story of a young voter who defies political categorization.","original_air_date":"2016-02-19T00:00:00","title":"That's One Way to Do It"},{"number":"579","description":"The brain! It's powerful! We have the story of how one man's delusions lead him to a situation that's just as strange as the worst thoughts his mind is cooking up. That story's a collaboration with the New York Times. Our second story is about a man using the power of his own mind to deal with a problem.

Pictured: Alan Pean, with visible scar from a bullet wound. Photo by Chad Batka for The New York Times.","original_air_date":"2016-02-12T00:00:00","title":"My Damn Mind"},{"number":"578","description":"This week, stories of people who are feeling the ground shift underneath them when people they are close to change. Including conservative radio host Tony Beam in South Carolina who is completely baffled by the candidate his audience has decided to get behind this election season.","original_air_date":"2016-01-29T00:00:00","title":"I Thought I Knew You"},{"number":"577","description":"When you’re the only one who can see something, sometimes it feels like you’re in on a special secret. The hard part is getting anyone to believe your secret is real. This week, people trying to show others what they see—including a woman with muscular dystrophy who believes she has the same condition as an Olympic athlete.","original_air_date":"2016-01-15T00:00:00","title":"Something Only I Can See"},{"number":"576","description":"No Christmas can ever be as good as the ones you had as a kid. But this week we go all in and bring the joy, the spontaneity, the sense that anything can happen back to Christmas. We've got a live Christmas performance from some of the best improvisors in the country including Mike Birbiglia, Chris Gethard, and SNL's Aidy Bryant and Sasheer Zamata. Also holiday meals – on fire.","original_air_date":"2015-12-25T00:00:00","title":"Say Yes To Christmas"},{"number":"575","description":"Sure, there's a crude message that propaganda is trying to get across. But like poetry, when you know how to read it, propaganda contains lots of more subtle messages that you might not see at first glance. This week: examples, big and small, from around the world.","original_air_date":"2015-12-18T00:00:00","title":"Poetry of Propaganda"},{"number":"574","description":"For Frank Sinatra's 100th Birthday: stories, tributes, and attempts to understand the Chairman of the Board.

An updated version of an episode originally broadcast back in 1997.","original_air_date":"2015-12-11T00:00:00","title":"Sinatra's 100th Birthday"},{"number":"573","description":"Most of the time, the updates we share about our lives are small and inconsequential. This week, status updates that interrupt daily life. We hear two friends talk about how one of them has become rich and famous. And an entire town gets a status update on itself.","original_air_date":"2015-11-27T00:00:00","title":"Status Update"},{"number":"572","description":"This week we have stories of people deciding to take on some very big fears. A prisoner who hasn't talked to anyone in years comes up with a bold plan to re-introduce himself to the world, while a 90-year-old woman shocks her family when she announces a love interest.","original_air_date":"2015-11-06T00:00:00","title":"Transformers"},{"number":"571","description":"When Jesse first started getting letters from Pamala, he couldn’t believe his luck. He'd been waiting all his life to fall in love—and then he started getting these letters from the perfect woman. Vulnerable. In need of protection. Classic beauty. He was totally devoted. They corresponded for years. And when something happens that really should change how he feels about her— he just can’t give it up.","original_air_date":"2015-10-30T00:00:00","title":"The Heart Wants What It Wants"},{"number":"570","description":"Twenty years ago, the prime minister of Israel was assassinated. The killer was a lone gunman, Israeli and Jewish, just like the prime minister. Lots of witnesses saw it happen; the assassin confessed immediately, that night, and has never recanted. But today, oddly, lots of people don’t believe it happened that way. And a question hangs over the country: did this act change the fate of the nation?","original_air_date":"2015-10-16T00:00:00","title":"The Night In Question"},{"number":"569","description":"This week we go into the room at the headquarters of fast food chain Hardee's with the people who decided that this burger with beef, hot dogs, and chips is what America should be eating. We'll hear the story of how they sold that burger and other instances where how you tell the story is more important than the literal facts.","original_air_date":"2015-10-09T00:00:00","title":"Put a Bow on It"},{"number":"568","description":"Gladiators in the Colosseum. Sideshow performers. Reality television. We've always loved to gawk at the misery or majesty of others. But this week, we ask the question: What's it like when the tables are turned and all eyes are on you?

An episode from last year, with one story swapped.","original_air_date":"2015-10-02T00:00:00","title":"Human Spectacle 2015"},{"number":"567","description":"Often we see someone’s situation from the outside and think we know exactly what’s going on. This week we get inside and find out just how much more interesting the reality of it is. Including a teenaged girl who records a remarkable story about the boyfriend who abuses her, and why it’s so hard to break up with him. Also this week: our new video by Bianca Giaever.","original_air_date":"2015-09-18T00:00:00","title":"What's Going On In There?"},{"number":"566","description":"A father constructs an elaborate fantasy to occupy his 12 children, and a woman finds herself sucked into a world of make believe that we almost never get to see inside.

PHOTO GALLERY","original_air_date":"2015-09-11T00:00:00","title":"The Land of Make Believe"},{"number":"565","description":"Katrina bus tours go all over New Orleans, but it’s illegal for them to go into the Lower 9th Ward, the area that's been the slowest to rebuild. This week we go around talking to residents there about what matters the most to them (and what doesn't) ten years after the hurricane. The episode we did in 2005 the week of the storm is here.

Pictured: map of Katrina-related fatalities.","original_air_date":"2015-08-28T00:00:00","title":"Lower 9 + 10"},{"number":"564","description":"When is too soon for that celebrity comeback; that joke that is either brilliant or full-on repugnant; that parent-child conversation? This week: stories about a fallen man trying to kickstart his career with a reality show, and an awkward moment between a mom and a daughter.","original_air_date":"2015-08-14T00:00:00","title":"Too Soon?"},{"number":"563","description":"Last week we looked at a school district integrating by accident. This week: a city going all out to integrate its schools. Plus, a girl who comes up with her own one-woman integration plan. (Part one.)","original_air_date":"2015-08-07T00:00:00","title":"The Problem We All Live With - Part Two"},{"number":"562","description":"Right now, all sorts of people are trying to rethink and reinvent education, to get poor minority kids performing as well as white kids. But there's one thing nobody tries anymore, despite lots of evidence that it works: desegregation. Nikole Hannah-Jones looks at a district that, not long ago, accidentally launched a desegregation program. First of a two-part series.","original_air_date":"2015-07-31T00:00:00","title":"The Problem We All Live With"},{"number":"561","description":"A car plant in Fremont California that might have saved the U.S. car industry. In 1984, General Motors and Toyota opened NUMMI as a joint venture. Toyota showed GM the secrets of its production system: How it made cars of much higher quality and much lower cost than GM achieved. Frank Langfitt explains why GM didn't learn the lessons—until it was too late.","original_air_date":"2015-07-17T00:00:00","title":"NUMMI 2015"},{"number":"560","description":"For July 4th, a story about someone who's desperately trying – against long odds – to make it to the United States and become an American. Abdi is a Somali refugee living in Kenya and gets the luckiest break of his life: he wins a lottery that puts him on a short list for a U.S. visa. This is his ticket out. But before he can cash in his golden ticket, the police start raiding his neighborhood, targeting refugees.","original_air_date":"2015-07-03T00:00:00","title":"Abdi and the Golden Ticket"},{"number":"559","description":"A captain’s log is a simple thing: the date, the time, maybe the weather — and the current status of a long journey. You wouldn’t know from the cryptic notations what weird worlds lurk beneath. On this week's show, stories behind those cryptic notations — including a concentration camp in China that housed groups of Girl Scouts. Also, Aziz Ansari explains the significance of a Thanksgiving text message, and Etgar Keret destroys a marriage piece by piece.","original_air_date":"2015-06-26T00:00:00","title":"Captain's Log"},{"number":"558","description":"Blair Braverman was a dog musher on an Alaskan glacier. One day the weather turned rough, and she and a pack of tourists were stuck. The worst part? They had to pretend like nothing was wrong. This and other stories of people facing very difficult situations who put their game face on and muscle through. And, we hear from people whose faces betray them and prominently display all their anxiety.","original_air_date":"2015-05-29T00:00:00","title":"Game Face"},{"number":"557","description":"Some information is so big and so complicated that it seems impossible to talk to kids about. This week, stories about the vague and not-so-vague ways to teach children about race, death and sex - including a story about colleges responding to sexual assault by trying to teach students how to ask for consent. Also, a story about how and when to teach kids about the horrors of slavery and oppression in America.","original_air_date":"2015-05-15T00:00:00","title":"Birds & Bees"},{"number":"556","description":"Stories of people who are tied together, but imagine radically different futures. In one case, a movie star and her ex-husband plot against Kim Jong-Il. In another, a woman stalks her doppleganger. And sometimes, one bed is the basis for an entire relationship, even for a man who almost never sees the person who shares his bed.","original_air_date":"2015-05-01T00:00:00","title":"Same Bed, Different Dreams"},{"number":"555","description":"It’s rare for people to change what they believe, and if they do it, it’s usually a long process. This week, stories of those very infrequent instances where people’s opinions flip on fundamental things that they believe. Why does it happen in these particular and unusual circumstances? We explain. NOTE: One of the authors of a study covered in this episode has asked that the study be retracted.","original_air_date":"2015-04-24T00:00:00","title":"The Incredible Rarity of Changing Your Mind"}]; diff --git a/server/routes/admin.js b/server/routes/admin.js index f56024d..ca49a13 100644 --- a/server/routes/admin.js +++ b/server/routes/admin.js @@ -21,7 +21,7 @@ router.post('/setEpisode', function (req, res) { const newObject = { value: guid, enabled: enabled === 'true' - } + }; if (episodeIndex > -1) { episodes[episodeIndex] = newObject; } diff --git a/server/routes/all-episode-data.js b/server/routes/all-episode-data.js index a472ca2..9f0fd60 100644 --- a/server/routes/all-episode-data.js +++ b/server/routes/all-episode-data.js @@ -14,7 +14,7 @@ let cache; // update `allEpisodes` and `episodeDataVersions` const update = function(globalCache, cb) { - cb = cb || function(err, success) { + cb = cb || function(err) { if (err) { throw new Error('Unable to update episode data: ' + err); } diff --git a/server/routes/create-video.js b/server/routes/create-video.js index 0e900bc..b588375 100644 --- a/server/routes/create-video.js +++ b/server/routes/create-video.js @@ -28,7 +28,7 @@ module.exports = function(req, res) { // event variables const params = req.query; let showID, startTime, duration, type, bgColor, wordArray, opts; - let tweetData = false, bucketName; + let tweetData = false; let event = req.body; // destination file name / key @@ -114,8 +114,8 @@ module.exports = function(req, res) { localFilePaths.push(tempOutName); - res.header("Access-Control-Allow-Origin", "*"); - res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); + res.header('Access-Control-Allow-Origin', '*'); + res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); let videoData = { Bucket: results.s3.Bucket, Key: results.s3.Key, @@ -191,7 +191,7 @@ function timeToSegmentID(timeInSeconds) { return zeroPad( Math.floor(timeInSeconds / segmentLength) ); } -// segment IDs need to be formatted like this "001" +// segment IDs need to be formatted like this '001' function zeroPad(number) { var str = String(number); diff --git a/server/routes/get-episode.js b/server/routes/get-episode.js index 8ab3eeb..d51ee36 100644 --- a/server/routes/get-episode.js +++ b/server/routes/get-episode.js @@ -21,8 +21,8 @@ module.exports = function(req, res) { // generate signed url const protectedUrl = `${process.env.CLOUDFRONT_URL}${epVersion}`; const signedUrl = cfSign.getSignedUrl(protectedUrl, req); - res.setHeader("Cache-Control", "public, max-age=2592000"); - res.setHeader("Expires", new Date(Date.now() + 2592000000).toUTCString()); + res.setHeader('Cache-Control', 'public, max-age=2592000'); + res.setHeader('Expires', new Date(Date.now() + 2592000000).toUTCString()); // redirect to signedURL if url contains 'api' if (req.baseUrl.indexOf('api') > -1) { diff --git a/server/routes/getTranscript.js b/server/routes/getTranscript.js index 2d032b2..cb5b5ad 100644 --- a/server/routes/getTranscript.js +++ b/server/routes/getTranscript.js @@ -113,10 +113,10 @@ function episodeDataCallback(err, body, _startTime, _endTime, episodeNumber, epi timestamp = lastValidTimestamp+1; } lastValidTimestamp = timestamp; - return [Math.round(timestamp)+"", striptags(decodeHTMLEntities(showData.transcript.substr(word.startOffset, nextWord.startOffset-word.startOffset)).trim(), ['&'])]; + return [Math.round(timestamp)+'', striptags(decodeHTMLEntities(showData.transcript.substr(word.startOffset, nextWord.startOffset-word.startOffset)).trim(), ['&'])]; }); // add a placeholder empty string at time 0 (necessary for the reduce function that the client does) - wordsInRange.unshift(["0",""]); + wordsInRange.unshift(['0','']); // Fake paragraph breaks on every word that contains a terminal punctuation. paragraphsInRange = wordsInRange.filter(word => (word[1].match(/(\?$|\.$|\!$|(\.|\?|\!)\"$)$/) && word[1].length > 3)) diff --git a/server/routes/helpers.js b/server/routes/helpers.js index 7054213..0012131 100644 --- a/server/routes/helpers.js +++ b/server/routes/helpers.js @@ -1,6 +1,5 @@ const fs = require('fs'); const request = require('request'); -const path = require('path'); const inactiveEpisodes = process.env.BAD_EPISODES.split(','); const Parser = require('rss-parser'); const parser = new Parser(); @@ -22,7 +21,7 @@ module.exports = { let unfilteredEpisodes = feed.items.sort((a,b) => { return Date.parse(b.pubDate) - Date.parse(a.pubDate); }) - .map((episode, index, array) => { + .map((episode) => { let guid = episode.guid || episode.link; // set the ID number to the guid let number = guid; @@ -65,10 +64,13 @@ module.exports = { var tempName = tempDir + '/' + origPath.split('/').pop(); var dlStream = fs.createWriteStream(tempName); - dlStream.on('finish', function(err, msg) { - dlStream.close(function(err, msg) { + dlStream.on('finish', function(err) { + if (err) { + throw new Error(err); + } + dlStream.close(function(err) { if (err) { - console.log(err); + throw new Error(err); } console.log('finish'); setTimeout(function() { @@ -82,7 +84,7 @@ module.exports = { .on('response', function(response) { response.pipe(dlStream); }) - .on('end', function(resp) { + .on('end', function() { console.log('downloaded'); dlStream.end(); }); diff --git a/server/routes/makeWaveform.js b/server/routes/makeWaveform.js index ab74904..73afb5e 100644 --- a/server/routes/makeWaveform.js +++ b/server/routes/makeWaveform.js @@ -1,4 +1,4 @@ -waveform = require('waveform-util'); +const waveform = require('waveform-util'); // ... via waveform-util module documentation: // @@ -48,6 +48,3 @@ module.exports = { } }; - - -