Skip to content

Commit

Permalink
chore(v3): eslint and prettier fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoazh committed Mar 29, 2024
1 parent c078590 commit c4bb6a8
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 74 deletions.
2 changes: 1 addition & 1 deletion packages/v3/cypress/e2e/circle-shape.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('CircleShape component', () => {
cy.get('button[name=circle]').click();
cy.get('[aria-label=Map]').within(() => {
cy.get(
'div > div > [style="position: absolute; left: 0px; top: 0px; z-index: 106; width: 100%;"] > div > div'
'div > div > [style="position: absolute; left: 0px; top: 0px; z-index: 106; width: 100%;"] > div > div',
).should('have.length', 5);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/v3/cypress/e2e/cluster-icon.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('ClusterIcon component', () => {
cy.get('[aria-label="Cluster of 2 markers"]').should(
'have.attr',
'title',
'Cluster of 2 markers'
'Cluster of 2 markers',
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/v3/cypress/e2e/polygon-shape.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('PolygonShape component', () => {
cy.get('button[name=polygon]').click();
cy.get('[aria-label=Map]').within(() => {
cy.get(
'div > div > [style="position: absolute; left: 0px; top: 0px; z-index: 106; width: 100%;"] > div > div'
'div > div > [style="position: absolute; left: 0px; top: 0px; z-index: 106; width: 100%;"] > div > div',
).should('have.length', 16);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/v3/cypress/e2e/polyline-shape.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('PolylineShape component', () => {
cy.get('button[name=polyline]').click();
cy.get('[aria-label=Map]').within(() => {
cy.get(
'div > div > [style="position: absolute; left: 0px; top: 0px; z-index: 106; width: 100%;"] > div > div'
'div > div > [style="position: absolute; left: 0px; top: 0px; z-index: 106; width: 100%;"] > div > div',
).should('have.length', 3);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/v3/cypress/e2e/rectangle-shape.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('RectangleShape component', () => {
cy.get('button[name=rectangle]').click();
cy.get('[aria-label=Map]').within(() => {
cy.get(
'div > div > [style="position: absolute; left: 0px; top: 0px; z-index: 106; width: 100%;"] > div > div'
'div > div > [style="position: absolute; left: 0px; top: 0px; z-index: 106; width: 100%;"] > div > div',
).should('have.length', 8);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/v3/cypress/runner/components/PolylineTest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default {
coordinates: this.path.map(({ lat, lng }) => [lng, lat]),
},
null,
2
2,
);
}
}, 1000),
Expand Down
4 changes: 2 additions & 2 deletions packages/v3/cypress/runner/runner.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const server = http.createServer((req, res) => {
req.url === '/'
? path.join(baseUrl, 'index.html')
: !/^https?:\/\//gim.test(req.url)
? path.join(baseUrl, req.url)
: req.url;
? path.join(baseUrl, req.url)
: req.url;
const extension = path.extname(filePath);
let contentType = 'text/html';

Expand Down
90 changes: 51 additions & 39 deletions packages/v3/src/composables/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,34 @@ export function capitalizeFirstLetter(text: string): string {
*/
export function getPropsValuesWithoutOptionsProp(
props: { [key: string | number | symbol]: unknown },
vueInst?: ComponentPublicInstance
vueInst?: ComponentPublicInstance,
): Omit<{ [key: string | number | symbol]: IVueProp }, 'options'> {
if (vueInst) {
return Object.keys(props).reduce((acc, propKey) => {
if (propKey !== 'options' && (vueInst?.$props as any)[propKey] != null) {
acc[propKey] = (vueInst?.$props as any)[propKey];
}
return Object.keys(props).reduce(
(acc, propKey) => {
if (
propKey !== 'options' &&
(vueInst?.$props as any)[propKey] != null
) {
acc[propKey] = (vueInst?.$props as any)[propKey];
}

return acc;
}, {} as { [key: string | number | symbol]: IVueProp });
return acc;
},
{} as { [key: string | number | symbol]: IVueProp },
);
}

return Object.keys(props).reduce((acc, propKey) => {
if (propKey !== 'options' && (props as any)[propKey] != null) {
acc[propKey] = (props as any)[propKey];
}
return Object.keys(props).reduce(
(acc, propKey) => {
if (propKey !== 'options' && (props as any)[propKey] != null) {
acc[propKey] = (props as any)[propKey];
}

return acc;
}, {} as { [key: string | number | symbol]: IVueProp });
return acc;
},
{} as { [key: string | number | symbol]: IVueProp },
);
}

/**
Expand All @@ -64,7 +73,7 @@ export function getPropsValuesWithoutOptionsProp(
* @internal
*/
export function getLazyValue<T>(
fn: LazyValueGetterFn<T>
fn: LazyValueGetterFn<T>,
): LazyValueGetterFn<T> {
let called = false;
let ret: Promise<T>;
Expand All @@ -89,7 +98,7 @@ export function getLazyValue<T>(
* @internal
*/
export function filterVuePropsOptions<T extends GmapVuePluginProps>(
mappedProps: T
mappedProps: T,
): {
[key in keyof T]: IVueProp;
} {
Expand All @@ -103,11 +112,14 @@ export function filterVuePropsOptions<T extends GmapVuePluginProps>(

return [key, value];
}) as Array<[keyof T, IVueProp]>
).reduce((acc, [key, val]) => {
acc[key] = val;
).reduce(
(acc, [key, val]) => {
acc[key] = val;

return acc;
}, {} as { [key in keyof T]: IVueProp });
return acc;
},
{} as { [key in keyof T]: IVueProp },
);
}

/**
Expand All @@ -127,7 +139,7 @@ export function filterVuePropsOptions<T extends GmapVuePluginProps>(
export function downArrowSimulator(input: HTMLInputElement | null): void {
if (!input) {
throw new Error(
`The input for downArrowSimulator should be defined, currently: ${input}`
`The input for downArrowSimulator should be defined, currently: ${input}`,
);
}

Expand All @@ -144,7 +156,7 @@ export function downArrowSimulator(input: HTMLInputElement | null): void {
*/
function addEventListenerWrapper(
type: string,
listener: (...args: any[]) => any
listener: (...args: any[]) => any,
): void {
// Simulate a 'down arrow' keypress on hitting 'return' when no pac suggestion is selected,
// and then trigger the original listener.
Expand Down Expand Up @@ -228,8 +240,8 @@ export function twoWayBindingWrapper(
fn: (
increment: () => void,
decrement: () => void,
shouldUpdate: () => boolean
) => void
shouldUpdate: () => boolean,
) => void,
): void {
let counter = 0;

Expand All @@ -240,7 +252,7 @@ export function twoWayBindingWrapper(
() => {
counter = Math.max(0, counter - 1);
},
() => counter === 0
() => counter === 0,
);
}

Expand All @@ -265,7 +277,7 @@ export function watchPrimitiveProperties(
propertiesToTrack: string[],
handler: () => any,
vueInst: ComponentPublicInstance,
immediate = false
immediate = false,
): void {
let isHandled = false;

Expand Down Expand Up @@ -310,7 +322,7 @@ export function watchPrimitivePropertiesOnSetup(
propertiesToTrack: string[],
handler: () => any,
props: Record<any, any>,
immediate = false
immediate = false,
): void {
let isHandled = false;

Expand Down Expand Up @@ -354,7 +366,7 @@ export function bindEvents(
eventsConfig: string[],
googleMapsInst: Record<string, any>,
vueInst: ComponentPublicInstance & { $gmapOptions: IGmapVuePluginOptions },
excludedEvents: string[] = []
excludedEvents: string[] = [],
): void {
eventsConfig.forEach((eventName) => {
if (!excludedEvents.includes(eventName) && !/_changed/.test(eventName)) {
Expand Down Expand Up @@ -384,7 +396,7 @@ export function bindEvents(
export function bindProps(
propsComponentConfig: Omit<SinglePluginComponentConfig, 'events'>,
AnyGoogleMapsClassInstance: Record<string, any>,
vueInst: ComponentPublicInstance & { $gmapOptions: IGmapVuePluginOptions }
vueInst: ComponentPublicInstance & { $gmapOptions: IGmapVuePluginOptions },
): void {
Object.entries(vueInst.$props).forEach(([propKey, propValue]) => {
if (!propsComponentConfig.noBind.includes(propKey)) {
Expand Down Expand Up @@ -413,18 +425,18 @@ export function bindProps(
{
immediate: propValue != undefined,
deep: typeof propValue !== 'object' && !Array.isArray(propValue),
}
},
);
} else {
watchPrimitivePropertiesOnSetup(
propsComponentConfig.trackProperties[propKey].map(
(prop) => `${propKey}.${prop}`
(prop) => `${propKey}.${prop}`,
),
() => {
AnyGoogleMapsClassInstance[setMethodName](propValue);
},
vueInst.$props,
propValue != undefined
propValue != undefined,
);
}
}
Expand All @@ -440,7 +452,7 @@ export function bindProps(
if (value && !isEqual(value, (vueInst.$props as any)[propKey])) {
vueInst.$emit(
eventName,
AnyGoogleMapsClassInstance[getMethodName]()
AnyGoogleMapsClassInstance[getMethodName](),
);
}
});
Expand All @@ -467,7 +479,7 @@ export function bindGoogleMapsEventsToVueEventsOnSetup(
eventsComponentConfig: string[],
AnyGoogleMapsClassInstance: Record<string, any>,
emits: (ev: string, value: any) => void,
excludedEvents: string[] = []
excludedEvents: string[] = [],
): void {
eventsComponentConfig.forEach((eventName) => {
if (!excludedEvents.includes(eventName) && !/_changed/.test(eventName)) {
Expand Down Expand Up @@ -499,7 +511,7 @@ export function bindPropsWithGoogleMapsSettersAndGettersOnSetup(
propsComponentConfig: Omit<SinglePluginComponentConfig, 'events'>,
AnyGoogleMapsClassInstance: Record<string, any>,
emits: (ev: string, value: any) => void,
props: Record<any, any>
props: Record<any, any>,
): void {
Object.keys(props).forEach((propKey) => {
if (!propsComponentConfig.noBind.includes(propKey)) {
Expand All @@ -508,7 +520,7 @@ export function bindPropsWithGoogleMapsSettersAndGettersOnSetup(
propKey,
props,
propsComponentConfig.trackProperties[propKey],
AnyGoogleMapsClassInstance
AnyGoogleMapsClassInstance,
);

if (propsComponentConfig.twoWay.includes(propKey)) {
Expand All @@ -534,7 +546,7 @@ function bindVuePropsWithGoogleMapsPropsSetters(
propKey: string,
props: Record<any, any>,
trackProperties: string[],
AnyGoogleMapsClassInstance: Record<string, any>
AnyGoogleMapsClassInstance: Record<string, any>,
): { eventName: string; getMethodName: string } {
const setMethodName = `set${capitalizeFirstLetter(propKey)}`;
const getMethodName = `get${capitalizeFirstLetter(propKey)}`;
Expand Down Expand Up @@ -563,7 +575,7 @@ function bindVuePropsWithGoogleMapsPropsSetters(
deep:
typeof props[propKey] !== 'object' &&
!Array.isArray(props[propKey]),
}
},
);
} else {
watchPrimitivePropertiesOnSetup(
Expand All @@ -572,7 +584,7 @@ function bindVuePropsWithGoogleMapsPropsSetters(
AnyGoogleMapsClassInstance[setMethodName](props[propKey]);
},
props,
props[propKey] != undefined
props[propKey] != undefined,
);
}
}
Expand All @@ -582,7 +594,7 @@ function bindVuePropsWithGoogleMapsPropsSetters(

/** @internal */
function oldHtmlInputElementGuard(
input: HTMLInputElement | OldHtmlInputElement
input: HTMLInputElement | OldHtmlInputElement,
): input is OldHtmlInputElement {
return (input as OldHtmlInputElement).attachEvent !== undefined;
}
2 changes: 1 addition & 1 deletion packages/v3/src/composables/map-promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const promise: Promise<google.maps.Map | undefined> = new Promise(
(resolve, reject) => {
mapPromiseDeferred.resolve = resolve;
mapPromiseDeferred.reject = reject;
}
},
);

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/v3/src/composables/plugin-component-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function _assert(v: boolean, message: string): void {
* @returns {Object} A component object that should be exported by default from a Vue component
*/
export function pluginComponentBuilder(
providedOptions: IGmapVueElementOptions
providedOptions: IGmapVueElementOptions,
): ComponentOptions {
const {
mappedProps,
Expand Down Expand Up @@ -136,8 +136,8 @@ export function pluginComponentBuilder(
null,
...ctrArgs(
options,
getPropsValuesWithoutOptionsProp(props || {}, this)
)
getPropsValuesWithoutOptionsProp(props || {}, this),
),
))()
: new ConstructorObject(options);

Expand Down
4 changes: 2 additions & 2 deletions packages/v3/src/composables/plugin-component-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ const componentConfigs: PluginComponentConfig = {
* @returns {SinglePluginComponentConfigWithoutEvents}
*/
export function getComponentPropsConfig(
componentName: PluginComponentNames
componentName: PluginComponentNames,
): Omit<SinglePluginComponentConfig, 'events'> {
const { events, ...config } = componentConfigs[componentName];
return config;
Expand All @@ -357,7 +357,7 @@ export function getComponentPropsConfig(
*/
export function getComponentEventsConfig(
componentName: PluginComponentNames,
type?: 'auto' | 'manual'
type?: 'auto' | 'manual',
): string[] {
if (type) {
return componentConfigs[componentName].events[type];
Expand Down
6 changes: 3 additions & 3 deletions packages/v3/src/composables/resize-bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let _delayedResizeCallback: () => Promise<void>;
export function onMountedResizeBusHook(
map: google.maps.Map, // TODO: maybe can be removed
props: { [key: string]: any },
resizeFn: () => void
resizeFn: () => void,
) {
if (!props.resizeBus) {
currentResizeBus.value = defaultResizeBus;
Expand All @@ -44,7 +44,7 @@ export function onMountedResizeBusHook(
() => props.resizeBus,
(newVal) => {
currentResizeBus.value = newVal.value;
}
},
);

watch(
Expand All @@ -57,7 +57,7 @@ export function onMountedResizeBusHook(
if (newVal.value) {
newVal.value.on('resize', _delayedResizeCallback);
}
}
},
);
}

Expand Down
Loading

0 comments on commit c4bb6a8

Please sign in to comment.