From abc66a37433dcb32e190656b9591f2f1915e5d93 Mon Sep 17 00:00:00 2001 From: Beasta Date: Thu, 14 May 2020 12:16:44 -0700 Subject: [PATCH 1/2] Add eslint with one rule-no semicolons --- .eslintrc.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..49be8757 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,17 @@ +module.exports = { + "env": { + "browser": true, + "commonjs": true, + "es6": true + }, + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parserOptions": { + "ecmaVersion": 2018 + }, + "rules": { + "semi": ["error", "never"] + } +}; From 6663759877dcedd009aba52db5920a58a57a4ba5 Mon Sep 17 00:00:00 2001 From: Beasta Date: Thu, 14 May 2020 12:18:08 -0700 Subject: [PATCH 2/2] implement autofix for eslint-no semicolons --- index.js | 10 +++++----- test.js | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index 06b13e7f..823aa6c5 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,7 @@ const app = express() app.use(express.static(path.join(__dirname, 'public'))) app.get('/', function(req, res) { - res.send('Get ready for OpenSea!'); + res.send('Get ready for OpenSea!') }) app.get('/api/token/:token_id', function(req, res) { @@ -38,14 +38,14 @@ app.get('/api/token/:token_id', function(req, res) { }) app.listen(app.get('port'), function() { - console.log('Node app is running on port', app.get('port')); + console.log('Node app is running on port', app.get('port')) }) // returns the zodiac sign according to day and month ( https://coursesweb.net/javascript/zodiac-signs_cs ) function zodiac(day, month) { - var zodiac =['', 'Capricorn', 'Aquarius', 'Pisces', 'Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio', 'Sagittarius', 'Capricorn']; - var last_day =['', 19, 18, 20, 20, 21, 21, 22, 22, 21, 22, 21, 20, 19]; - return (day > last_day[month]) ? zodiac[month*1 + 1] : zodiac[month]; + var zodiac =['', 'Capricorn', 'Aquarius', 'Pisces', 'Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio', 'Sagittarius', 'Capricorn'] + var last_day =['', 19, 18, 20, 20, 21, 21, 22, 22, 21, 22, 21, 20, 19] + return (day > last_day[month]) ? zodiac[month*1 + 1] : zodiac[month] } function monthName(month) { diff --git a/test.js b/test.js index b8bc75c9..691fcc11 100644 --- a/test.js +++ b/test.js @@ -1,28 +1,28 @@ -const { spawn } = require('child_process'); -const request = require('request'); -const test = require('tape'); +const { spawn } = require('child_process') +const request = require('request') +const test = require('tape') // Start the app -const env = Object.assign({}, process.env, {PORT: 5000}); -const child = spawn('node', ['index.js'], {env}); +const env = Object.assign({}, process.env, {PORT: 5000}) +const child = spawn('node', ['index.js'], {env}) test('responds to requests', (t) => { - t.plan(4); + t.plan(4) // Wait until the server is ready child.stdout.on('data', _ => { // Make a request to our app request('http://127.0.0.1:5000', (error, response, body) => { // stop the server - child.kill(); + child.kill() // No error - t.false(error); + t.false(error) // Successful response - t.equal(response.statusCode, 200); + t.equal(response.statusCode, 200) // Assert content checks - t.notEqual(body.indexOf("Get ready"), -1); - t.notEqual(body.indexOf("for OpenSea!"), -1); - }); - }); -}); + t.notEqual(body.indexOf("Get ready"), -1) + t.notEqual(body.indexOf("for OpenSea!"), -1) + }) + }) +})