Skip to content

Commit dd0d98b

Browse files
chore: address PR feedback around createUserConfig
1. Use eslint disable instead of void marking the unused expression. 2. Make deprecatedCliArgumentWarnings a string instead of list of strings
1 parent 75d1221 commit dd0d98b

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

src/common/config/createUserConfig.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function createUserConfig({
3232
closeProcess = defaultUserConfigHelpers.closeProcess,
3333
cliArguments = defaultUserConfigHelpers.cliArguments,
3434
}: Partial<CreateUserConfigHelpers> = defaultUserConfigHelpers): UserConfig {
35-
const { unknownCliArgumentErrors, deprecatedCliArgumentWarnings, userAndArgsParserConfig, connectionSpecifier } =
35+
const { unknownCliArgumentErrors, deprecatedCliArgumentWarning, userAndArgsParserConfig, connectionSpecifier } =
3636
parseUserConfigSources(cliArguments);
3737

3838
if (unknownCliArgumentErrors.length) {
@@ -44,9 +44,9 @@ ${unknownCliArgumentErrors.join("\n")}
4444
return closeProcess(1);
4545
}
4646

47-
if (deprecatedCliArgumentWarnings.length) {
47+
if (deprecatedCliArgumentWarning) {
4848
const deprecatedMessages = `
49-
${deprecatedCliArgumentWarnings.join("\n")}
49+
${deprecatedCliArgumentWarning}
5050
- Refer to https://www.mongodb.com/docs/mcp-server/get-started/ for setting up the MCP Server.
5151
`;
5252
onWarning(deprecatedMessages);
@@ -79,13 +79,17 @@ ${deprecatedCliArgumentWarnings.join("\n")}
7979

8080
function parseUserConfigSources(cliArguments: string[]): {
8181
unknownCliArgumentErrors: string[];
82-
deprecatedCliArgumentWarnings: string[];
82+
deprecatedCliArgumentWarning: string | undefined;
8383
userAndArgsParserConfig: Record<string, unknown>;
8484
connectionSpecifier: string | undefined;
8585
} {
8686
const {
8787
_: positionalAndUnknownArguments,
88-
"--": endOfFlagArguments,
88+
// We don't make use of end of flag arguments but also don't want them to
89+
// end up alongside unknown arguments so we are extracting them and having a
90+
// no-op statement so ESLint does not complain.
91+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
92+
"--": _endOfFlagArguments,
8993
...parsedUserAndArgsParserConfig
9094
} = argv(cliArguments, {
9195
...OPTIONS,
@@ -103,11 +107,6 @@ function parseUserConfigSources(cliArguments: string[]): {
103107
},
104108
});
105109

106-
// We don't make use of end of flag arguments but also don't want them to
107-
// end up alongside unknown arguments so we are extracting them and having a
108-
// no-op statement so ESLint does not complain.
109-
void endOfFlagArguments;
110-
111110
// A connectionSpecifier can be one of:
112111
// - database name
113112
// - host name
@@ -139,16 +138,9 @@ function parseUserConfigSources(cliArguments: string[]): {
139138

140139
return `Error: Invalid command line argument '${argument}'.`;
141140
}),
142-
deprecatedCliArgumentWarnings: cliArguments
143-
.filter((argument) => argument.startsWith("--connectionString"))
144-
.map((argument) => {
145-
if (argument.startsWith("--connectionString")) {
146-
return "Warning: The --connectionString argument is deprecated. Prefer using the MDB_MCP_CONNECTION_STRING environment variable or the first positional argument for the connection string.";
147-
}
148-
149-
return undefined;
150-
})
151-
.filter((argument) => typeof argument === "string"),
141+
deprecatedCliArgumentWarning: cliArguments.find((argument) => argument.startsWith("--connectionString"))
142+
? "Warning: The --connectionString argument is deprecated. Prefer using the MDB_MCP_CONNECTION_STRING environment variable or the first positional argument for the connection string."
143+
: undefined,
152144
userAndArgsParserConfig: parsedUserAndArgsParserConfig,
153145
connectionSpecifier,
154146
};

0 commit comments

Comments
 (0)