Skip to content

Commit 554c920

Browse files
committed
Hand-fix some more ESLint errors
1 parent 7a2149d commit 554c920

File tree

7 files changed

+19
-16
lines changed

7 files changed

+19
-16
lines changed

src/helpers.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,13 @@ export function normalizeSwagger(parsedSpec) {
127127
o.operationId = `${op}${i + 1}`
128128
})
129129
}
130-
else {
131-
// Ensure we always add the normalized operation ID if one already exists ( potentially different, given that we normalize our IDs)
130+
else if (typeof operation.operationId !== 'undefined') {
131+
// Ensure we always add the normalized operation ID if one already exists
132+
// ( potentially different, given that we normalize our IDs)
132133
// ... _back_ to the spec. Otherwise, they might not line up
133-
if (typeof operation.operationId !== 'undefined') {
134-
const obj = map[op][0]
135-
obj.__originalOperationId = obj.__originalOperationId || operation.operationId
136-
obj.operationId = op
137-
}
134+
const obj = map[op][0]
135+
obj.__originalOperationId = obj.__originalOperationId || operation.operationId
136+
obj.operationId = op
138137
}
139138
})
140139
}

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import cloneDeep from 'lodash/cloneDeep'
22
import assign from 'lodash/assign'
3+
import Url from 'url'
34
import Http, {makeHttp, serializeRes, serializeHeaders} from './http'
45
import Resolver, {clearCache} from './resolver'
5-
import url from 'url'
66
import {makeApisTagOperation} from './interfaces'
77
import {execute, buildRequest, PARAMETER_BUILDERS} from './execute'
88
import {opId} from './helpers'
@@ -82,7 +82,7 @@ Swagger.prototype.applyDefaults = function () {
8282
const spec = this.spec
8383
const specUrl = this.url
8484
if (specUrl && specUrl.startsWith('http')) {
85-
const parsed = url.parse(specUrl)
85+
const parsed = Url.parse(specUrl)
8686
if (!spec.host) {
8787
spec.host = parsed.host
8888
}

src/interfaces.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function mapTagOperations({spec, cb = nullFn, defaultTag = 'default'}) {
8282
const cbResult = cb({spec, pathName, method, operation, operationId: id})
8383

8484
if (operationIdCounter[id]) {
85-
operationIdCounter[id] = operationIdCounter[id] + 1
85+
operationIdCounter[id]++
8686
tagObj[`${id}${operationIdCounter[id]}`] = cbResult
8787
}
8888
else if (typeof tagObj[id] !== 'undefined') {

src/resolver.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ export function clearCache() {
2323
plugins.refs.clearCache()
2424
}
2525

26-
export default function resolve({http, fetch, spec, url, baseDoc, mode, allowMetaPatches = true, modelPropertyMacro, parameterMacro}) {
26+
export default function resolve({
27+
http, fetch, spec, url, baseDoc, mode, allowMetaPatches = true,
28+
modelPropertyMacro, parameterMacro
29+
}) {
2730
// @TODO Swagger-UI uses baseDoc instead of url, this is to allow both
2831
// need to fix and pick one.
2932
baseDoc = baseDoc || url

src/specmap/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function applyPatch(obj, patch, opts) {
4949

5050
// deepExtend doesn't merge arrays, so we will do it manually
5151
for (const prop in patch.value) {
52-
if (patch.value.hasOwnProperty(prop)) {
52+
if (Object.prototype.hasOwnProperty.call(patch.value, prop)) {
5353
const propVal = patch.value[prop]
5454
if (Array.isArray(propVal)) {
5555
const existing = origValPatchValue[prop] || []

src/specmap/lib/parameters.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ export default {
1919
}
2020
})
2121

22-
const patch = lib.replace(fullPath, val)
23-
24-
return patch
22+
return lib.replace(fullPath, val)
2523
}
2624

2725
return lib.replace(fullPath, parameters)

test/execute.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,11 @@ describe('execute', () => {
536536
'content-type': 'multipart/form-data'
537537
})
538538

539+
// Would like to do a more thourough test ( ie: ensure the value `foo` exists..
540+
// but I don't feel like attacking the interals of the node pollyfill
541+
// for FormData, as it seems to be missing `.get()`)
539542
expect(req.url).toEqual('http://swagger.io/one')
540-
expect(req.body).toBeA(FormData) // Would like to do a more thourough test ( ie: ensure the value `foo` exists.. but I don't feel like attacking the interals of the node pollyfill for FormData, as it seems to be missing `.get()`)
543+
expect(req.body).toBeA(FormData)
541544
})
542545

543546
it('should add content-type application/x-www-form-urlencoded when in: formData ', function () {

0 commit comments

Comments
 (0)