Skip to content

Commit

Permalink
Fix lint errors with custom events branch (#52)
Browse files Browse the repository at this point in the history
* Address eslint errors with custom events branch

* Make CI workflow run regardless of target branch
  • Loading branch information
dglsparsons authored Feb 23, 2023
1 parent 4f10562 commit 41a1819
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: ci
on:
pull_request:
branches:
- main
push:
branches:
- main
Expand Down
2 changes: 2 additions & 0 deletions packages/web/src/generic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ describe('track custom events', () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
nested: {
object: '',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
});

Expand Down Expand Up @@ -173,6 +174,7 @@ describe('track custom events', () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
nested: {
object: '',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
});

Expand Down
16 changes: 8 additions & 8 deletions packages/web/src/generic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { name, version } from '../package.json';
import { name as packageName, version } from '../package.json';
import { initQueue } from './queue';
import type { AllowedPropertyValues, AnalyticsProps } from './types';
import {
Expand All @@ -9,11 +9,11 @@ import {
isProduction,
} from './utils';

export const inject = (
export function inject(
props: AnalyticsProps = {
debug: true,
},
): void => {
): void {
if (!isBrowser()) return;

setMode(props.mode);
Expand All @@ -33,20 +33,20 @@ export const inject = (
const script = document.createElement('script');
script.src = src;
script.defer = true;
script.setAttribute('data-sdkn', name);
script.setAttribute('data-sdkn', packageName);
script.setAttribute('data-sdkv', version);

if (isDevelopment() && props.debug === false) {
script.setAttribute('data-debug', 'false');
}

document.head.appendChild(script);
};
}

export const track = (
export function track(
name: string,
properties?: Record<string, AllowedPropertyValues>,
): void => {
): void {
if (!isBrowser()) {
// eslint-disable-next-line no-console
console.warn(
Expand Down Expand Up @@ -75,7 +75,7 @@ export const track = (
console.error(err);
}
}
};
}

// eslint-disable-next-line import/no-default-export
export default {
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/react.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ describe('<Analytics />', () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
nested: {
object: '',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
});

Expand Down
8 changes: 6 additions & 2 deletions packages/web/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ export function isDevelopment(): boolean {
return getMode() === 'development';
}

const removeKey = (key: string, { [key]: _, ...rest }): Record<string, any> =>
rest;
function removeKey(
key: string,
{ [key]: _, ...rest },
): Record<string, unknown> {
return rest;
}

export function parseProperties(
properties: Record<string, unknown>,
Expand Down

0 comments on commit 41a1819

Please sign in to comment.