Skip to content

Commit

Permalink
add prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Svindland committed Oct 16, 2024
1 parent 04fd946 commit b05adc3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dist/index.es.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.umd.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
},
"homepage": "https://github.com/shukerullah/react-geocode#readme",
"scripts": {
"build": "vite build"
"build": "vite build",
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx}\""
},
"devDependencies": {
"@types/node": "^20.16.11",
"prettier": "^3.3.3",
"typescript": "^5.6.3",
"vite": "^5.4.9",
"vite-plugin-dts": "^4.2.4"
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

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

18 changes: 9 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ let defaultOptions: GeocodeOptions = {
* @throws {Error} - Throws an error if the geocoding request fails.
*/
async function geocodeRequest(
queryParams: GeocodeQueryParams
queryParams: GeocodeQueryParams,
): Promise<GeocodeResponse> {
const { outputFormat, ...restParams } = queryParams;
const queryString = new URLSearchParams(
restParams as Record<string, string>
restParams as Record<string, string>,
).toString();
const url = `${GOOGLE_GEOCODE_API}/${outputFormat}?${queryString}`;
try {
Expand All @@ -88,7 +88,7 @@ async function geocodeRequest(
}

throw new Error(
`Geocoding failed: ${error_message}. Server returned status code ${status}.`
`Geocoding failed: ${error_message}. Server returned status code ${status}.`,
);
} catch (error: unknown) {
if (error instanceof Error) {
Expand Down Expand Up @@ -196,7 +196,7 @@ export function setOutputFormat(outputFormat: OutputFormat): void {
* @param enableAddressDescriptor - A boolean parameter indicating whether to include the address descriptor.
*/
export function enableAddressDescriptor(
enableAddressDescriptor: boolean
enableAddressDescriptor: boolean,
): void {
defaultOptions.enable_address_descriptor = enableAddressDescriptor;
}
Expand All @@ -214,12 +214,12 @@ export function enableAddressDescriptor(
export function geocode(
requestType: RequestType | string,
value: string,
options?: GeocodeOptions
options?: GeocodeOptions,
): Promise<any> {
if (typeof requestType !== "string" || typeof value !== "string") {
throw new Error(
`Both requestType and value are required and must be of type string.
requestType: ${typeof requestType}, value: ${typeof value}`
requestType: ${typeof requestType}, value: ${typeof value}`,
);
}

Expand All @@ -239,7 +239,7 @@ export function fromAddress(
address: string,
key?: string,
language?: string,
region?: string
region?: string,
) {
const options: GeocodeOptions = {
outputFormat: OutputFormat.JSON,
Expand All @@ -264,7 +264,7 @@ export function fromPlaceId(
placeId: string,
key?: string,
language?: string,
region?: string
region?: string,
) {
const options: GeocodeOptions = {
outputFormat: OutputFormat.JSON,
Expand All @@ -291,7 +291,7 @@ export function fromLatLng(
key?: string,
language?: string,
region?: string,
location_type?: string
location_type?: string,
) {
const options: GeocodeOptions = {
outputFormat: OutputFormat.JSON,
Expand Down

0 comments on commit b05adc3

Please sign in to comment.