Skip to content

Commit

Permalink
Linting pass
Browse files Browse the repository at this point in the history
  • Loading branch information
af committed Jan 2, 2017
1 parent 1cc25d1 commit 9478aea
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
8 changes: 6 additions & 2 deletions index.js
Expand Up @@ -60,7 +60,9 @@ function cleanEnv(inputEnv, specs = {}, options = {}) {
((devDefault !== undefined) && (devDefault === rawValue))

try {
if (rawValue === undefined && !usingFalsyDefault) throw new EnvMissingError(spec.desc || '')
if (rawValue === undefined && !usingFalsyDefault) {
throw new EnvMissingError(spec.desc || '')
}
output[k] = validateVar({ name: k, spec, rawValue })
} catch (err) {
if (options.reporter === null) throw err
Expand Down Expand Up @@ -90,4 +92,6 @@ function cleanEnv(inputEnv, specs = {}, options = {}) {
return Object.freeze(output)
}

module.exports = { cleanEnv, makeValidator, bool, num, str, json, url, email, EnvError, EnvMissingError }
module.exports = {
cleanEnv, makeValidator, bool, num, str, json, url, email, EnvError, EnvMissingError
}
4 changes: 2 additions & 2 deletions lib/validators.js
Expand Up @@ -54,7 +54,7 @@ exports.num = makeValidator(input => {
}, 'num')

exports.str = makeValidator(input => {
if (typeof input === 'string') return input;
if (typeof input === 'string') return input
throw new EnvError(`Not a string: "${input}"`)
}, 'str')

Expand All @@ -65,7 +65,7 @@ exports.email = makeValidator(x => {

exports.url = makeValidator(x => {
const url = require('url')
let isValid;
let isValid = false

if (url.URL) {
try {
Expand Down
3 changes: 2 additions & 1 deletion tests/test_basics.js
Expand Up @@ -17,11 +17,12 @@ test('strict option: only specified fields are passed through', () => {
})

test('transformer option: allow transformation of keys', () => {
const lowerCaseKey = (acc, [key, value]) => Object.assign(acc, { [key.toLowerCase()]: value })
const opts = {
transformer: i => Object
.keys(i)
.map(e => [e, i[e]])
.reduce((memo, [key, value]) => Object.assign({}, memo, { [key.toLowerCase()]: value }), {})
.reduce(lowerCaseKey, {})
}
const env = cleanEnv({ FOO: 'bar', FOO_BAR: 'baz' }, {
FOO: str()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dotenv.js
@@ -1,6 +1,6 @@
const fs = require('fs')
const { createGroup, assert } = require('painless')
const { cleanEnv, EnvError, str, num } = require('..')
const { cleanEnv, str, num } = require('..')
const test = createGroup()

test.beforeEach(() => fs.writeFileSync('.env', `
Expand Down
2 changes: 1 addition & 1 deletion tests/test_reporter.js
Expand Up @@ -9,7 +9,7 @@ test.beforeEach(() => {
exitSpy = stub(process, 'exit', () => {})
})
test.afterEach(() => {
console.error.restore()
console.error.restore() // eslint-disable-line no-console
process.exit.restore()
})

Expand Down

0 comments on commit 9478aea

Please sign in to comment.