Skip to content

Commit

Permalink
Fix eslint (#189)
Browse files Browse the repository at this point in the history
* Fix eslint

* fix some lint issues

* fix remaining lint issues

* add test workflow

* enable remote cache
  • Loading branch information
lukasIO authored Jan 12, 2023
1 parent bd75b1e commit 707fdb7
Show file tree
Hide file tree
Showing 13 changed files with 534 additions and 46 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2

- uses: actions/setup-node@v3
with:
node-version: '16.x'
cache: 'yarn'

- name: Install Yarn
run: |
npm install -g yarn
yarn install
- name: Build Packages
run: yarn build

- name: ESLint
run: yarn lint

- name: Prettier
run: yarn format

- name: Run Tests
run: yarn test
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"start:next": "turbo run start --filter=@livekit/component-example-next...",
"lint": "turbo run lint",
"test": "turbo run test",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"format": "prettier --check \"**/src/**/*.{ts,tsx,md}\"",
"format:write": "prettier --write \"**/src/**/*.{ts,tsx,md}\"",
"clean:all": "turbo run clean:all",
"release": "turbo run build --filter=./packages/* && changeset publish",
"tooling:update-readme-nav": "node tooling/readme-manager/update-nav-in-readmes.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
*/
module.exports = {
root: true,
extends: ['custom'],
extends: ['lk-custom'],
};
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"author": "LiveKit",
"devDependencies": {
"@livekit/components-styles": "0.1.4",
"eslint-config-custom": "*",
"eslint-config-lk-custom": "0.1.0",
"tsup": "^6.5.0",
"typescript": "^4.7.4",
"vitest": "^0.26.2"
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/components/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { DataPacket_Kind, Participant, Room } from 'livekit-client';
import { Observable, Subscriber } from 'rxjs';
import { createDataObserver } from '../observables/room';

export const enum MessageType {
CHAT,
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/observables/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ export function screenShareObserver(room: Room) {
screenShareSubscriber.next(screenShareTracks);
};
observers.push(
roomEventSelector(room, RoomEvent.TrackSubscribed).subscribe(([_, ...args]) =>
roomEventSelector(room, RoomEvent.TrackSubscribed).subscribe(([, ...args]) =>
handleSub(...args),
),
);
observers.push(
roomEventSelector(room, RoomEvent.TrackUnsubscribed).subscribe(([_, ...args]) =>
roomEventSelector(room, RoomEvent.TrackUnsubscribed).subscribe(([, ...args]) =>
handleSub(...args),
),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/observables/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export function observeTrackEvents(track: TrackPublication, ...events: TrackEven
};

events.forEach((evt) => {
// @ts-ignore
// @ts-expect-error type of `TrackEvent` and `PublicationCallbacks` are congruent
track.on(evt, onTrackUpdate);
});

const unsubscribe = () => {
events.forEach((evt) => {
// @ts-ignore
// @ts-expect-error type of `TrackEvent` and `PublicationCallbacks` are congruent
track.off(evt, onTrackUpdate);
});
};
Expand Down
5 changes: 3 additions & 2 deletions packages/eslint-config-custom/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module.exports = {
plugins: ['@typescript-eslint/eslint-plugin', 'eslint-plugin-tsdoc', 'svelte3', 'react-hooks'],
extends: [
'standard',
'next',
'turbo',
'prettier',
Expand Down Expand Up @@ -32,8 +31,10 @@ module.exports = {
'react/jsx-handler-names': 0,
'react/jsx-fragments': 0,
'react/no-unused-prop-types': 0,
'no-unused-vars': 0,
'@typescript-eslint/no-unused-vars': 'error',
'import/export': 0,
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-empty-interface': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-config-custom/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "eslint-config-custom",
"name": "eslint-config-lk-custom",
"main": "index.js",
"private": true,
"version": "0.1.0",
"devDependencies": {
"@changesets/cli": "^2.25.0",
"@typescript-eslint/eslint-plugin": "^5.22.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
*/
module.exports = {
root: true,
extends: ['custom'],
extends: ['lk-custom'],
};
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"@svgr/cli": "^6.5.1",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"eslint-config-custom": "*",
"eslint-config-lk-custom": "0.1.0",
"livekit-client": "^1.6.2",
"tsup": "^6.5.0"
}
}
}
25 changes: 13 additions & 12 deletions packages/react/src/layout/FocusLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@ import { Participant, Track } from 'livekit-client';
import * as React from 'react';
import { useMaybeLayoutContext, useLayoutContext } from '../context';
import { mergeProps } from '../utils';
import { TrackLoop } from '../components/TrackLoop';
import { TrackParticipantPair } from '@livekit/components-core';
import { TileLoop } from '../components/TileLoop';
import { ParticipantTile } from '../prefabs/ParticipantTile';
import { ParticipantClickEvent } from '@livekit/components-core';
import { ParticipantFilter } from '../hooks/participant-hooks';

export interface FocusLayoutContainerProps extends React.HTMLAttributes<HTMLDivElement> {
trackParticipantPair?: TrackParticipantPair;
participants?: Array<Participant>;
onParticipantClick?: (evt: ParticipantClickEvent) => void;
}

export function FocusLayoutContainer({
trackParticipantPair,
onParticipantClick,
...props
}: FocusLayoutContainerProps) {
const elementProps = mergeProps(props, { className: 'lk-focus-layout' });
Expand Down Expand Up @@ -48,11 +46,7 @@ export interface FocusLayoutProps extends React.HTMLAttributes<HTMLElement> {
onParticipantClick?: (evt: ParticipantClickEvent) => void;
}

export function FocusLayout({
trackParticipantPair,
onParticipantClick,
...props
}: FocusLayoutProps) {
export function FocusLayout({ trackParticipantPair, ...props }: FocusLayoutProps) {
const { state } = useMaybeLayoutContext().pin;

const pair: TrackParticipantPair | null = React.useMemo(() => {
Expand All @@ -79,14 +73,21 @@ export function FocusLayout({
}

export interface CarouselViewProps extends React.HTMLAttributes<HTMLMediaElement> {
// participants: Participant[];
// onParticipantClick?: (evt: ParticipantClickEvent) => void;
filter?: ParticipantFilter;
filterDependencies?: [];
}

export function CarouselView({ ...props }: CarouselViewProps) {
export function CarouselView({ filter, filterDependencies, ...props }: CarouselViewProps) {
return (
<aside {...props}>
{props.children ?? <TrackLoop sources={[Track.Source.Camera]} excludePinnedTracks={true} />}
{props.children ?? (
<TileLoop
sources={[Track.Source.Camera, Track.Source.ScreenShare]}
filter={filter}
filterDependencies={filterDependencies}
excludePinnedTracks={true}
/>
)}
</aside>
);
}
Loading

1 comment on commit 707fdb7

@vercel
Copy link

@vercel vercel bot commented on 707fdb7 Jan 12, 2023

Choose a reason for hiding this comment

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

Deployment failed with the following error:

Resource is limited - try again in 21 minutes (more than 100, code: "api-deployments-free-per-day").

Please sign in to comment.