Skip to content

Commit

Permalink
chore(lint): fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-super committed Nov 18, 2022
1 parent cc5a004 commit cf7a756
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"prettier": "2.7.1",
"rimraf": "3.0.2",
"semantic-release": "19.0.5",
"typescript": "4.9.3"
"typescript": "4.8.4"
},
"keywords": [
"environment",
Expand Down
2 changes: 1 addition & 1 deletion src/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('makeEnv', () => {
},
processEnv,
);
}).toThrowError(description);
}).toThrow(description);
});

test('uses process.env if the processEnv argument is not provided', () => {
Expand Down
13 changes: 8 additions & 5 deletions src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,18 @@ export function makeEnv<TSchemaData extends Record<string, any>>(
): Env<TSchemaData> {
logDebug('making env object...');

const env = Object.entries(schema).reduce((acc, [key, schemaEntry]) => {
const value = getValue(key, schemaEntry, processEnv);
const env = Object.fromEntries(
Object.entries(schema).map(([key, schemaEntry]) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- not sure how to fix this `any` issue...
const value = getValue(key, schemaEntry, processEnv);

return { ...acc, [key]: value };
}, {}) as Env<TSchemaData>;
return [key, value];
}),
);

logDebug('env object ready: %o', env);

return env;
return env as Env<TSchemaData>;
}

function getValue<TType>(
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
negativeInteger,
nonNegativeInteger,
nonPositiveInteger,
Parser,
port,
positiveInteger,
string,
Expand All @@ -35,7 +34,7 @@ const parsers = {
whitelist,
};

export { Parser, parsers };
export { parsers };
export {
makeEnv,
Env,
Expand All @@ -44,3 +43,5 @@ export {
SchemaEntryRequiredInfo,
} from './environment';
export { default as EnvironmentVariableError } from './EnvironmentVariableError';

export { Parser } from './parsers';
6 changes: 5 additions & 1 deletion src/parsers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import validator from 'validator';
import { IsURLOptions } from 'validator/lib/isURL';

import EnvironmentVariableError from './EnvironmentVariableError';

Expand Down Expand Up @@ -80,7 +81,10 @@ export const email: Parser<string> = (serializedValue) => {
/**
* Parses a URL.
*/
export const url: Parser<string> = (serializedValue: string, opts?: any) => {
export const url: Parser<string> = (
serializedValue: string,
opts?: IsURLOptions,
) => {
const value = serializedValue;

if (!validator.isURL(value, opts)) {
Expand Down
11 changes: 8 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3479,7 +3479,7 @@ dateformat@^3.0.0:
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==

debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2:
debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1:
version "4.3.2"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
Expand All @@ -3500,7 +3500,7 @@ debug@^3.2.7:
dependencies:
ms "^2.1.1"

debug@^4.3.3, debug@^4.3.4:
debug@^4.3.2, debug@^4.3.3, debug@^4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
Expand Down Expand Up @@ -8420,7 +8420,12 @@ type-fest@^1.0.2:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-1.4.0.tgz#e9fb813fe3bf1744ec359d55d1affefa76f14be1"
integrity sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==

[email protected], typescript@^4.6.4:
[email protected]:
version "4.8.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==

typescript@^4.6.4:
version "4.9.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.3.tgz#3aea307c1746b8c384435d8ac36b8a2e580d85db"
integrity sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==
Expand Down

0 comments on commit cf7a756

Please sign in to comment.