Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint airbnb transloadit #95

Merged
merged 6 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 1 addition & 34 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
// Selectively include rules from airbnb https://github.com/transloadit/node-sdk/issues/90
// eslint-disable-next-line import/no-extraneous-dependencies
const airbnbRulesImports = require('eslint-config-airbnb-base/rules/imports').rules

module.exports = {
extends: 'standard',
env : {
es6 : true,
jest: true,
node: true,
},
rules: {
// See https://github.com/transloadit/node-sdk/issues/93
'import/no-extraneous-dependencies': airbnbRulesImports['import/no-extraneous-dependencies'],
'no-multi-spaces' : 0,
'comma-dangle' : [
'error',
'always-multiline',
],
'key-spacing': [
'error',
{
multiLine: {
beforeColon: false,
afterColon : true,
},
align: {
beforeColon: false,
afterColon : true,
on : 'colon',
mode : 'strict',
},
},
],
},
extends: 'transloadit',
}
5 changes: 5 additions & 0 deletions examples/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
rules: {
'no-console': 0,
},
}
8 changes: 4 additions & 4 deletions examples/face_detect_download.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
// This example will take an image and find a face and crop out the face.
// Then it will download the result as a file in the current directory
// See https://transloadit.com/demos/artificial-intelligence/detect-faces-in-images/
//
// You'll likely just want to `require('transloadit')`, but we're requiring the local
// variant here for easier testing:
const Transloadit = require('../src/Transloadit')

const got = require('got')
const { createWriteStream } = require('fs')

// You'll likely just want to `require('transloadit')`, but we're requiring the local
// variant here for easier testing:
const Transloadit = require('../src/Transloadit')

const transloadit = new Transloadit({
authKey : process.env.TRANSLOADIT_KEY,
authSecret: process.env.TRANSLOADIT_SECRET,
Expand Down
2 changes: 2 additions & 0 deletions examples/fetch_costs_of_all_assemblies_in_timeframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ const todate = '2020-12-31 15:30:01';
let lastCount
do {
console.log('Processing page', params.page)
// eslint-disable-next-line no-await-in-loop
const { count, items } = await transloadit.listAssemblies(params)
lastCount = count
params.page++

// eslint-disable-next-line no-await-in-loop,no-loop-func
await pMap(items, async (assembly) => {
const assemblyFull = await transloadit.getAssembly(assembly.id)
// console.log(assemblyFull.assembly_id)
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@
"into-stream": "^6.0.0",
"is-stream": "^2.0.0",
"lodash": "^4.17.20",
"p-map": "^4.0.0",
"tus-js-client": "^2.2.0"
},
"devDependencies": {
"@types/jest": "^26.0.19",
"badge-maker": "^3.3.0",
"eslint": "^7.18.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-standard": "^16.0.2",
"eslint-config-transloadit": "^1.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"fakefile": "^0.0.9",
"jest": "^26.6.3",
"localtunnel": "^2.0.0",
Expand Down
9 changes: 6 additions & 3 deletions src/PaginationStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ class PaginationStream extends stream.Readable {
async _read () {
if (this._items.length > 0) {
this._itemsRead++
return process.nextTick(() => this.push(this._items.pop()))
process.nextTick(() => this.push(this._items.pop()))
return
}

if (this._nitems != null && this._itemsRead >= this._nitems) {
return process.nextTick(() => this.push(null))
process.nextTick(() => this.push(null))
return
}

try {
Expand All @@ -26,7 +28,8 @@ class PaginationStream extends stream.Readable {
this._items = Array.from(items)
this._items.reverse()

return this._read()
this._read()
return
} catch (err) {
this.emit('error', err)
}
Expand Down
Loading