Skip to content

Commit 4609867

Browse files
authored
Merge pull request #1 from OpenCageData/feature/eslint-prettier
Adds eslint, prettier
2 parents e98687d + c8062f6 commit 4609867

File tree

9 files changed

+1591
-268
lines changed

9 files changed

+1591
-268
lines changed

.prettierignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Lock files
2+
package-lock.json
3+
pnpm-lock.yaml
4+
yarn.lock
5+
# Other
6+
.vscode/
7+
# Ignore all node_modules directories
8+
node_modules/
9+
# Ignore all dist directories
10+
dist/
11+
# Ignore all build directories
12+
build/
13+
# Ignore all coverage directories
14+
coverage/

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

build/index.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface OpenCageResponse {
99
name: string;
1010
iso_code: string;
1111
};
12-
[key: string]: any;
12+
[key: string]: string | number | boolean | object | undefined;
1313
};
1414
components: {
1515
country: string;
@@ -20,7 +20,7 @@ export interface OpenCageResponse {
2020
road?: string;
2121
house_number?: string;
2222
postcode?: string;
23-
[key: string]: any;
23+
[key: string]: string | number | boolean | object | undefined;
2424
};
2525
confidence: number;
2626
formatted: string;
@@ -43,19 +43,21 @@ export declare class OpenCageServer {
4343
constructor();
4444
/**
4545
* Handles the geocoding request.
46+
*
4647
* @param args - The arguments for the request.
4748
* @returns The response containing the geocoded location information.
4849
*/
4950
private handleGeocode;
5051
/**
5152
* Handles the reverse geocoding request.
53+
*
5254
* @param args - The arguments for the request.
5355
* @returns The response containing the address and location information.
5456
*/
5557
private handleReverseGeocode;
5658
/**
5759
* Handles the OpenCage API info request.
58-
* @param args - The arguments for the request.
60+
* @param _args - The arguments for the request.
5961
* @returns The response containing API usage and rate limit information.
6062
*/
6163
private handleOpenCageInfo;

build/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ export class OpenCageServer {
3535
}
3636
/**
3737
* Handles the geocoding request.
38+
*
3839
* @param args - The arguments for the request.
3940
* @returns The response containing the geocoded location information.
4041
*/
42+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4143
async handleGeocode(args) {
4244
const { query, language = 'en', countrycode, bounds, limit = 5, } = args || {};
4345
try {
@@ -110,9 +112,11 @@ export class OpenCageServer {
110112
}
111113
/**
112114
* Handles the reverse geocoding request.
115+
*
113116
* @param args - The arguments for the request.
114117
* @returns The response containing the address and location information.
115118
*/
119+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
116120
async handleReverseGeocode(args) {
117121
const { latitude, longitude, language = 'en', no_annotations } = args;
118122
const params = new URLSearchParams({
@@ -165,10 +169,11 @@ export class OpenCageServer {
165169
}
166170
/**
167171
* Handles the OpenCage API info request.
168-
* @param args - The arguments for the request.
172+
* @param _args - The arguments for the request.
169173
* @returns The response containing API usage and rate limit information.
170174
*/
171-
async handleOpenCageInfo(args) {
175+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
176+
async handleOpenCageInfo(_args) {
172177
try {
173178
const params = new URLSearchParams({
174179
q: `0,0`,
@@ -381,6 +386,7 @@ What would you like to help me with regarding geocoding?`,
381386
}
382387
// Start the server
383388
const server = new OpenCageServer();
389+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
384390
server.run().catch((error) => {
385391
console.error('Fatal error in main():', error);
386392
process.exit(1);

eslint.config.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import ts from 'typescript-eslint';
4+
5+
export default [
6+
{ languageOptions: { globals: globals.node } },
7+
js.configs.recommended,
8+
...ts.configs.recommended,
9+
{ ignores: ['build/'] },
10+
];

0 commit comments

Comments
 (0)