Browse Source

storage-node: Fix linter warnings.

Shamil Gadelshin 4 years ago
parent
commit
3ffabe873f

+ 0 - 2
storage-node/packages/cli/bin/dev.js

@@ -1,5 +1,3 @@
-/* eslint-disable no-console */
-
 'use strict'
 
 const debug = require('debug')('joystream:storage-cli:dev')

+ 1 - 1
storage-node/packages/colossus/bin/cli.js

@@ -201,7 +201,7 @@ function getServiceInformation(publicUrl) {
 
 async function announcePublicUrl(api, publicUrl) {
   // re-announce in future
-  const reannounce = function (timeoutMs) {
+  const reannounce = function(timeoutMs) {
     setTimeout(announcePublicUrl, timeoutMs, api, publicUrl)
   }
 

+ 1 - 1
storage-node/packages/colossus/lib/app.js

@@ -64,7 +64,7 @@ function createApp(projectRoot, storage, runtime) {
 
   // If no other handler gets triggered (errors), respond with the
   // error serialized to JSON.
-  app.use(function (err, req, res) {
+  app.use(function(err, req, res) {
     res.status(err.status).json(err)
   })
 

+ 1 - 1
storage-node/packages/colossus/lib/discovery.js

@@ -60,7 +60,7 @@ function createApp(projectRoot, runtime) {
 
   // If no other handler gets triggered (errors), respond with the
   // error serialized to JSON.
-  app.use(function (err, req, res) {
+  app.use(function(err, req, res) {
     res.status(err.status).json(err)
   })
 

+ 2 - 2
storage-node/packages/colossus/lib/middleware/file_uploads.js

@@ -21,8 +21,8 @@
 const multer = require('multer')
 
 // Taken from express-openapi examples
-module.exports = function (req, res, next) {
-  multer().any()(req, res, function (err) {
+module.exports = function(req, res, next) {
+  multer().any()(req, res, function(err) {
     if (err) {
       return next(err)
     }

+ 1 - 1
storage-node/packages/colossus/lib/middleware/validate_responses.js

@@ -21,7 +21,7 @@
 const debug = require('debug')('joystream:middleware:validate')
 
 // Function taken directly from https://github.com/kogosoftwarellc/open-api/tree/master/packages/express-openapi
-module.exports = function (req, res, next) {
+module.exports = function(req, res, next) {
   const strictValidation = !!req.apiDoc['x-express-openapi-validation-strict']
   if (typeof res.validateResponse === 'function') {
     const send = res.send

+ 1 - 1
storage-node/packages/colossus/paths/asset/v0/{id}.js

@@ -30,7 +30,7 @@ function errorHandler(response, err, code) {
   response.status(err.code || code || 500).send({ message: err.toString() })
 }
 
-module.exports = function (storage, runtime) {
+module.exports = function(storage, runtime) {
   const doc = {
     // parameters for all operations in this path
     parameters: [

+ 1 - 1
storage-node/packages/colossus/paths/discover/v0/{id}.js

@@ -4,7 +4,7 @@ const debug = require('debug')('joystream:colossus:api:discovery')
 const MAX_CACHE_AGE = 30 * 60 * 1000
 const USE_CACHE = true
 
-module.exports = function (runtime) {
+module.exports = function(runtime) {
   const doc = {
     // parameters for all operations in this path
     parameters: [

+ 1 - 1
storage-node/packages/util/fs/walk.js

@@ -126,7 +126,7 @@ class Walker {
  *
  * The callback is invoked one last time without data to signal the end of data.
  */
-module.exports = function (base, archive, cb) {
+module.exports = function(base, archive, cb) {
   // Archive is optional and defaults to fs, but cb is not.
   if (!cb) {
     cb = archive

+ 10 - 10
storage-node/packages/util/test/fs/resolve.js

@@ -24,45 +24,45 @@ const path = require('path')
 const resolve = require('@joystream/storage-utils/fs/resolve')
 
 function tests(base) {
-  it('resolves absolute paths relative to the base', function () {
+  it('resolves absolute paths relative to the base', function() {
     const resolved = resolve(base, '/foo')
     const relative = path.relative(base, resolved)
     expect(relative).to.equal('foo')
   })
 
-  it('allows for relative paths that stay in the base', function () {
+  it('allows for relative paths that stay in the base', function() {
     const resolved = resolve(base, 'foo/../bar')
     const relative = path.relative(base, resolved)
     expect(relative).to.equal('bar')
   })
 
-  it('prevents relative paths from breaking out of the base', function () {
+  it('prevents relative paths from breaking out of the base', function() {
     expect(() => resolve(base, '../foo')).to.throw()
   })
 
-  it('prevents long relative paths from breaking out of the base', function () {
+  it('prevents long relative paths from breaking out of the base', function() {
     expect(() => resolve(base, '../../../foo')).to.throw()
   })
 
-  it('prevents sneaky relative paths from breaking out of the base', function () {
+  it('prevents sneaky relative paths from breaking out of the base', function() {
     expect(() => resolve(base, 'foo/../../../bar')).to.throw()
   })
 }
 
-describe('util/fs/resolve', function () {
-  describe('slash base', function () {
+describe('util/fs/resolve', function() {
+  describe('slash base', function() {
     tests('/')
   })
 
-  describe('empty base', function () {
+  describe('empty base', function() {
     tests('')
   })
 
-  describe('short base', function () {
+  describe('short base', function() {
     tests('/base')
   })
 
-  describe('long base', function () {
+  describe('long base', function() {
     tests('/this/base/is/very/long/indeed')
   })
 })

+ 2 - 2
storage-node/packages/util/test/fs/walk.js

@@ -60,8 +60,8 @@ function walktest(archive, base, done) {
   })
 }
 
-describe('util/fs/walk', function () {
-  it('reports all files in a file system hierarchy', function (done) {
+describe('util/fs/walk', function() {
+  it('reports all files in a file system hierarchy', function(done) {
     walktest(fs, path.resolve(__dirname, '../data'), done)
   })
 })

+ 10 - 10
storage-node/packages/util/test/lru.js

@@ -29,9 +29,9 @@ function sleep(ms = DEFAULT_SLEEP) {
   })
 }
 
-describe('util/lru', function () {
-  describe('simple usage', function () {
-    it('does not contain keys that were not added', function () {
+describe('util/lru', function() {
+  describe('simple usage', function() {
+    it('does not contain keys that were not added', function() {
       const cache = new lru.LRUCache()
       expect(cache.size()).to.equal(0)
 
@@ -41,7 +41,7 @@ describe('util/lru', function () {
       expect(cache.has('something')).to.be.false
     })
 
-    it('contains keys that were added', function () {
+    it('contains keys that were added', function() {
       const cache = new lru.LRUCache()
       cache.put('something', 'yay!')
       expect(cache.size()).to.equal(1)
@@ -52,7 +52,7 @@ describe('util/lru', function () {
       expect(cache.has('something')).to.be.true
     })
 
-    it('does not contain keys that were deleted', function () {
+    it('does not contain keys that were deleted', function() {
       const cache = new lru.LRUCache()
       cache.put('something', 'yay!')
       expect(cache.size()).to.equal(1)
@@ -67,7 +67,7 @@ describe('util/lru', function () {
       expect(cache.has('something')).to.be.false
     })
 
-    it('can be cleared', function () {
+    it('can be cleared', function() {
       const cache = new lru.LRUCache()
       cache.put('something', 'yay!')
       expect(cache.size()).to.equal(1)
@@ -77,8 +77,8 @@ describe('util/lru', function () {
     })
   })
 
-  describe('capacity management', function () {
-    it('does not grow beyond capacity', async function () {
+  describe('capacity management', function() {
+    it('does not grow beyond capacity', async function() {
       const cache = new lru.LRUCache(2) // Small capacity
       expect(cache.size()).to.equal(0)
 
@@ -96,7 +96,7 @@ describe('util/lru', function () {
       expect(cache.size()).to.equal(2) // Capacity exceeded
     })
 
-    it('removes the oldest key when pruning', async function () {
+    it('removes the oldest key when pruning', async function() {
       const cache = new lru.LRUCache(2) // Small capacity
       expect(cache.size()).to.equal(0)
 
@@ -119,7 +119,7 @@ describe('util/lru', function () {
       expect(cache.has('baz')).to.be.true
     })
 
-    it('updates LRU timestamp when reading', async function () {
+    it('updates LRU timestamp when reading', async function() {
       const cache = new lru.LRUCache(2) // Small capacity
       expect(cache.size()).to.equal(0)
 

+ 12 - 8
storage-node/packages/util/test/pagination.js

@@ -23,9 +23,9 @@ const mockHttp = require('node-mocks-http')
 
 const pagination = require('@joystream/storage-utils/pagination')
 
-describe('util/pagination', function () {
-  describe('openapi()', function () {
-    it('should add parameters and definitions to an API spec', function () {
+describe('util/pagination', function() {
+  describe('openapi()', function() {
+    it('should add parameters and definitions to an API spec', function() {
       const api = pagination.openapi({})
 
       // Parameters
@@ -62,8 +62,8 @@ describe('util/pagination', function () {
     })
   })
 
-  describe('paginate()', function () {
-    it('should add pagination links to a response object', function () {
+  describe('paginate()', function() {
+    it('should add pagination links to a response object', function() {
       const req = mockHttp.createRequest({
         method: 'GET',
         url: '/foo?limit=10',
@@ -78,14 +78,16 @@ describe('util/pagination', function () {
 
       const res = pagination.paginate(req, {})
 
-      expect(res).to.have.property('pagination').that.has.all.keys('self', 'first', 'next')
+      expect(res)
+        .to.have.property('pagination')
+        .that.has.all.keys('self', 'first', 'next')
 
       expect(res.pagination.self).to.equal('http://localhost/foo?limit=10')
       expect(res.pagination.first).to.equal('http://localhost/foo?limit=10&offset=0')
       expect(res.pagination.next).to.equal('http://localhost/foo?limit=10&offset=10')
     })
 
-    it('should add a last pagination link when requested', function () {
+    it('should add a last pagination link when requested', function() {
       const req = mockHttp.createRequest({
         method: 'GET',
         url: '/foo?limit=10&offset=15',
@@ -101,7 +103,9 @@ describe('util/pagination', function () {
 
       const res = pagination.paginate(req, {}, 35)
 
-      expect(res).to.have.property('pagination').that.has.all.keys('self', 'first', 'next', 'prev', 'last')
+      expect(res)
+        .to.have.property('pagination')
+        .that.has.all.keys('self', 'first', 'next', 'prev', 'last')
 
       expect(res.pagination.self).to.equal('http://localhost/foo?limit=10&offset=15')
       expect(res.pagination.first).to.equal('http://localhost/foo?limit=10&offset=0')

+ 24 - 24
storage-node/packages/util/test/ranges.js

@@ -24,9 +24,9 @@ const streamBuffers = require('stream-buffers')
 
 const ranges = require('@joystream/storage-utils/ranges')
 
-describe('util/ranges', function () {
-  describe('parse()', function () {
-    it('should parse a full range', function () {
+describe('util/ranges', function() {
+  describe('parse()', function() {
+    it('should parse a full range', function() {
       // Range with unit
       let range = ranges.parse('bytes=0-100')
       expect(range.unit).to.equal('bytes')
@@ -50,14 +50,14 @@ describe('util/ranges', function () {
       expect(range.ranges[0][1]).to.equal(100)
     })
 
-    it('should error out on malformed strings', function () {
+    it('should error out on malformed strings', function() {
       expect(() => ranges.parse('foo')).to.throw()
       expect(() => ranges.parse('foo=bar')).to.throw()
       expect(() => ranges.parse('foo=100')).to.throw()
       expect(() => ranges.parse('foo=100-0')).to.throw()
     })
 
-    it('should parse a range without end', function () {
+    it('should parse a range without end', function() {
       const range = ranges.parse('0-')
       expect(range.unit).to.equal('bytes')
       expect(range.rangeStr).to.equal('0-')
@@ -65,7 +65,7 @@ describe('util/ranges', function () {
       expect(range.ranges[0][1]).to.be.undefined
     })
 
-    it('should parse a range without start', function () {
+    it('should parse a range without start', function() {
       const range = ranges.parse('-100')
       expect(range.unit).to.equal('bytes')
       expect(range.rangeStr).to.equal('-100')
@@ -73,7 +73,7 @@ describe('util/ranges', function () {
       expect(range.ranges[0][1]).to.equal(100)
     })
 
-    it('should parse multiple ranges', function () {
+    it('should parse multiple ranges', function() {
       const range = ranges.parse('0-10,30-40,60-80')
       expect(range.unit).to.equal('bytes')
       expect(range.rangeStr).to.equal('0-10,30-40,60-80')
@@ -85,7 +85,7 @@ describe('util/ranges', function () {
       expect(range.ranges[2][1]).to.equal(80)
     })
 
-    it('should merge overlapping ranges', function () {
+    it('should merge overlapping ranges', function() {
       // Two overlapping ranges
       let range = ranges.parse('0-20,10-30')
       expect(range.unit).to.equal('bytes')
@@ -119,7 +119,7 @@ describe('util/ranges', function () {
       expect(range.ranges[0][1]).to.equal(20)
     })
 
-    it('should sort ranges', function () {
+    it('should sort ranges', function() {
       const range = ranges.parse('10-30,0-5')
       expect(range.unit).to.equal('bytes')
       expect(range.rangeStr).to.equal('10-30,0-5')
@@ -131,8 +131,8 @@ describe('util/ranges', function () {
     })
   })
 
-  describe('send()', function () {
-    it('should send full files on request', function (done) {
+  describe('send()', function() {
+    it('should send full files on request', function(done) {
       const res = mockHttp.createResponse({})
       const inStream = new streamBuffers.ReadableStreamBuffer({})
 
@@ -141,7 +141,7 @@ describe('util/ranges', function () {
         name: 'test.file',
         type: 'application/test',
       }
-      ranges.send(res, inStream, opts, function (err) {
+      ranges.send(res, inStream, opts, function(err) {
         expect(err).to.not.exist
 
         // HTTP handling
@@ -163,7 +163,7 @@ describe('util/ranges', function () {
       inStream.stop()
     })
 
-    it('should send a range spanning the entire file on request', function (done) {
+    it('should send a range spanning the entire file on request', function(done) {
       const res = mockHttp.createResponse({})
       const inStream = new streamBuffers.ReadableStreamBuffer({})
 
@@ -175,7 +175,7 @@ describe('util/ranges', function () {
           ranges: [[0, 12]],
         },
       }
-      ranges.send(res, inStream, opts, function (err) {
+      ranges.send(res, inStream, opts, function(err) {
         expect(err).to.not.exist
 
         // HTTP handling
@@ -199,7 +199,7 @@ describe('util/ranges', function () {
       inStream.stop()
     })
 
-    it('should send a small range on request', function (done) {
+    it('should send a small range on request', function(done) {
       const res = mockHttp.createResponse({})
       const inStream = new streamBuffers.ReadableStreamBuffer({})
 
@@ -211,7 +211,7 @@ describe('util/ranges', function () {
           ranges: [[1, 11]], // Cut off first and last letter
         },
       }
-      ranges.send(res, inStream, opts, function (err) {
+      ranges.send(res, inStream, opts, function(err) {
         expect(err).to.not.exist
 
         // HTTP handling
@@ -235,7 +235,7 @@ describe('util/ranges', function () {
       inStream.stop()
     })
 
-    it('should send ranges crossing buffer boundaries', function (done) {
+    it('should send ranges crossing buffer boundaries', function(done) {
       const res = mockHttp.createResponse({})
       const inStream = new streamBuffers.ReadableStreamBuffer({
         chunkSize: 3, // Setting a chunk size smaller than the range should
@@ -250,7 +250,7 @@ describe('util/ranges', function () {
           ranges: [[1, 11]], // Cut off first and last letter
         },
       }
-      ranges.send(res, inStream, opts, function (err) {
+      ranges.send(res, inStream, opts, function(err) {
         expect(err).to.not.exist
 
         // HTTP handling
@@ -274,7 +274,7 @@ describe('util/ranges', function () {
       inStream.stop()
     })
 
-    it('should send multiple ranges', function (done) {
+    it('should send multiple ranges', function(done) {
       const res = mockHttp.createResponse({})
       const inStream = new streamBuffers.ReadableStreamBuffer({})
 
@@ -289,7 +289,7 @@ describe('util/ranges', function () {
           ], // Slice two ranges out
         },
       }
-      ranges.send(res, inStream, opts, function (err) {
+      ranges.send(res, inStream, opts, function(err) {
         expect(err).to.not.exist
 
         // HTTP handling
@@ -320,7 +320,7 @@ describe('util/ranges', function () {
       inStream.stop()
     })
 
-    it('should deal with ranges without end', function (done) {
+    it('should deal with ranges without end', function(done) {
       const res = mockHttp.createResponse({})
       const inStream = new streamBuffers.ReadableStreamBuffer({})
 
@@ -332,7 +332,7 @@ describe('util/ranges', function () {
           ranges: [[5, undefined]], // Skip the first part, but read until end
         },
       }
-      ranges.send(res, inStream, opts, function (err) {
+      ranges.send(res, inStream, opts, function(err) {
         expect(err).to.not.exist
 
         // HTTP handling
@@ -355,7 +355,7 @@ describe('util/ranges', function () {
       inStream.stop()
     })
 
-    it('should ignore ranges without start', function (done) {
+    it('should ignore ranges without start', function(done) {
       const res = mockHttp.createResponse({})
       const inStream = new streamBuffers.ReadableStreamBuffer({})
 
@@ -367,7 +367,7 @@ describe('util/ranges', function () {
           ranges: [[undefined, 5]], // Only last five
         },
       }
-      ranges.send(res, inStream, opts, function (err) {
+      ranges.send(res, inStream, opts, function(err) {
         expect(err).to.not.exist
 
         // HTTP handling

+ 3 - 3
storage-node/packages/util/test/stripEndingSlash.js

@@ -3,11 +3,11 @@
 const expect = require('chai').expect
 const stripEndingSlash = require('@joystream/storage-utils/stripEndingSlash')
 
-describe('stripEndingSlash', function () {
-  it('stripEndingSlash should keep URL without the slash', function () {
+describe('stripEndingSlash', function() {
+  it('stripEndingSlash should keep URL without the slash', function() {
     expect(stripEndingSlash('http://keep.one')).to.equal('http://keep.one')
   })
-  it('stripEndingSlash should remove ending slash', function () {
+  it('stripEndingSlash should remove ending slash', function() {
     expect(stripEndingSlash('http://strip.one/')).to.equal('http://strip.one')
   })
 })