Skip to content

chore: add type-powered eslint rules #62

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

Merged
merged 2 commits into from
Apr 11, 2025
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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dist
coverage
package-lock.json
tests/tmp
src/common/atlas/openapi.d.ts
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"singleQuote": false,
"printWidth": 120,
"overrides": [
{
"files": "*.ts",
"options": {
"insertPragma": false,
"proseWrap": "preserve"
}
},
{
"files": "*.json",
"options": {
Expand Down
29 changes: 25 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,31 @@ import globals from "globals";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier/flat";

const files = ["src/**/*.ts", "scripts/**/*.ts", "tests/**/*.test.ts", "eslint.config.js", "jest.config.js"];

export default defineConfig([
{ files: ["src/**/*.ts"], plugins: { js }, extends: ["js/recommended"] },
{ files: ["src/**/*.ts"], languageOptions: { globals: globals.node } },
tseslint.configs.recommended,
{ files, plugins: { js }, extends: ["js/recommended"] },
{ files, languageOptions: { globals: globals.node } },
tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files,
rules: {
"@typescript-eslint/switch-exhaustiveness-check": "error",
},
},
// Ignore features specific to TypeScript resolved rules
tseslint.config({
// TODO: Configure tests and scripts to work with this.
ignores: ["eslint.config.js", "jest.config.js", "tests/**/*.ts", "scripts/**/*.ts"],
}),
globalIgnores(["node_modules", "dist", "src/common/atlas/openapi.d.ts"]),
eslintConfigPrettier,
globalIgnores(["node_modules", "dist"]),
]);
14 changes: 13 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
"prepare": "npm run build",
"build:clean": "rm -rf dist",
"build:compile": "tsc",
"build:addshebang": "echo '#!/usr/bin/env node' > dist/index2.js && cat dist/index.js >> dist/index2.js && mv dist/index2.js dist/index.js",
"build:chmod": "chmod +x dist/index.js",
"build": "npm run build:clean && npm run build:compile && npm run build:addshebang && npm run build:chmod",
"build": "npm run build:clean && npm run build:compile && npm run build:chmod",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're removing shebang you should also remove chmod, that was meant to help before npm package is sorted

Copy link
Collaborator Author

@gagik gagik Apr 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"inspect": "npm run build && mcp-inspector -- dist/index.js",
"prettier": "prettier",
"check": "npm run build && npm run check:lint && npm run check:format",
Expand All @@ -38,6 +37,7 @@
"@modelcontextprotocol/inspector": "^0.8.2",
"@modelcontextprotocol/sdk": "^1.8.0",
"@redocly/cli": "^1.34.2",
"@types/express": "^5.0.1",
"@types/jest": "^29.5.14",
"@types/node": "^22.14.0",
"@types/simple-oauth2": "^5.0.7",
Expand All @@ -60,7 +60,6 @@
"dependencies": {
"@mongodb-js/devtools-connect": "^3.7.2",
"@mongosh/service-provider-node-driver": "^3.6.0",
"@types/express": "^5.0.1",
"bson": "^6.10.3",
"mongodb": "^6.15.0",
"mongodb-log-writer": "^2.4.1",
Expand Down
9 changes: 5 additions & 4 deletions src/common/atlas/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ export class ApiClient {
this.client.use(this.errorMiddleware());
}

async getIpInfo() {
public async getIpInfo(): Promise<{
currentIpv4Address: string;
}> {
const accessToken = await this.getAccessToken();

const endpoint = "api/private/ipinfo";
Expand All @@ -130,10 +132,9 @@ export class ApiClient {
throw await ApiClientError.fromResponse(response);
}

const responseBody = await response.json();
return responseBody as {
return (await response.json()) as Promise<{
currentIpv4Address: string;
};
}>;
}

async listProjects(options?: FetchOptions<operations["listProjects"]>) {
Expand Down
Loading
Loading