Skip to content

Commit

Permalink
Big refactor: clean TSLint + AirBnB config (#1129)
Browse files Browse the repository at this point in the history
* refactor: fix code issues, details follow

These are some, but not all, of the changes:

* add lint commands, including CI, to `package.json`.
* remove eslint, we will invest on tslint instead.
* add `readonly` modifier to fields that deserve it.
* shorten imports.
* fix chatbot templates having invalid syntax.
* add AirBnB config through tslint and apply automatic fixes.
* manual fixes.

* test: import `reflect-metadata` in services manager

Perhaps related to compilation order, `reflect-metadata` has to be imported in this file, otherwise
we would get the following compilation error:

```
app/services-manager.ts(545,21): error TS2339: Property 'getMetadata' does not exist on type 'typeof Reflect'.
```
  • Loading branch information
blackxored authored and andycreeth committed Dec 20, 2018
1 parent 9a388b9 commit b94f0b5
Show file tree
Hide file tree
Showing 418 changed files with 6,248 additions and 7,945 deletions.
41 changes: 0 additions & 41 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .idea/streamlabs-obs.iml

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

31 changes: 15 additions & 16 deletions app/app.ts
Expand Up @@ -29,10 +29,11 @@ const isProduction = process.env.NODE_ENV === 'production';

window['obs'] = window['require']('obs-studio-node');

{ // Set up things for IPC
{
// Set up things for IPC
// Connect to the IPC Server
window['obs'].IPC.connect(remote.process.env.SLOBS_IPC_PATH);
document.addEventListener('close', (e) => {
document.addEventListener('close', e => {
window['obs'].IPC.disconnect();
});
}
Expand All @@ -53,12 +54,15 @@ if (isProduction) {
'token=e3f92ff3be69381afe2718f94c56da4644567935cc52dec601cf82b3f52a06ce',
extra: {
version: slobsVersion,
processType: 'renderer'
}
processType: 'renderer',
},
});
}

if ((isProduction || process.env.SLOBS_REPORT_TO_SENTRY) && !electron.remote.process.env.SLOBS_IPC) {
if (
(isProduction || process.env.SLOBS_REPORT_TO_SENTRY) &&
!electron.remote.process.env.SLOBS_IPC
) {
Sentry.init({
dsn: sentryDsn,
release: slobsVersion,
Expand All @@ -82,9 +86,7 @@ if ((isProduction || process.env.SLOBS_REPORT_TO_SENTRY) && !electron.remote.pro

return event;
},
integrations: [
new Sentry.Integrations.Vue({ Vue })
]
integrations: [new Sentry.Integrations.Vue({ Vue })],
});

const oldConsoleError = console.error;
Expand Down Expand Up @@ -112,7 +114,6 @@ Vue.use(Toasted);
Vue.use(VeeValidate); // form validations
Vue.use(VModal);


// Disable chrome default drag/drop behavior
document.addEventListener('dragover', event => event.preventDefault());
document.addEventListener('drop', event => event.preventDefault());
Expand All @@ -135,7 +136,6 @@ document.addEventListener('DOMContentLoaded', () => {
}

storePromise.then(async store => {

Vue.use(VueI18n);

await i18nService.load();
Expand All @@ -144,32 +144,31 @@ document.addEventListener('DOMContentLoaded', () => {
locale: i18nService.state.locale,
fallbackLocale: i18nService.getFallbackLocale(),
messages: i18nService.getLoadedDictionaries(),
silentTranslationWarn: true
silentTranslationWarn: true,
});

I18nService.setVuei18nInstance(i18n);

const vm = new Vue({
el: '#app',
i18n,
store,
el: '#app',
render: h => {
if (windowId === 'child') return h(ChildWindow);
if (windowId === 'main') {
const componentName = windowsService.state[windowId].componentName;
return h(windowsService.components[componentName]);
}
return h(OneOffWindow);
}
},
});

});
});

// EVENT LOGGING

const consoleError = console.error;
console.error = function (...args: any[]) {
console.error = function(...args: any[]) {
logError(args[0]);
consoleError.call(console, ...args);
};
Expand All @@ -181,7 +180,7 @@ function logError(error: Error | string) {
if (error instanceof Error) {
message = error.message;
stack = error.stack;
} else if (typeof(error) == 'string') {
} else if (typeof error === 'string') {
message = error;
}

Expand Down
28 changes: 14 additions & 14 deletions app/components/AppPlatformDeveloperSettings.vue.ts
Expand Up @@ -7,31 +7,30 @@ import { PlatformAppsService } from 'services/platform-apps';
import { Inject } from 'util/injector';

@Component({
components: { VFormGroup, ValidatedForm }
components: { VFormGroup, ValidatedForm },
})
export default class AppPlatformDeveloperSettings extends Vue {

@Inject() platformAppsService: PlatformAppsService;

appPathMetadata = metadata.file({
title: 'Unpacked App Path',
description: 'This is the path to your unpacked app. ' +
description:
'This is the path to your unpacked app. ' +
'It should be a folder containing a valid manifest.json',
directory: true
directory: true,
});

appPathValue = this.currentlyLoadedUnpackedApp ?
this.currentlyLoadedUnpackedApp.appPath : '';
appPathValue = this.currentlyLoadedUnpackedApp ? this.currentlyLoadedUnpackedApp.appPath : '';

appTokenMetadata = metadata.text({
title: 'App Token',
description: 'This token allows you app to authenticate with the ' +
description:
'This token allows you app to authenticate with the ' +
'streamlabs API. Visit dev-platform.streamlabs.com to create a developer account ' +
'and get a test app token.'
'and get a test app token.',
});

appTokenValue = this.currentlyLoadedUnpackedApp ?
this.currentlyLoadedUnpackedApp.appToken : '';
appTokenValue = this.currentlyLoadedUnpackedApp ? this.currentlyLoadedUnpackedApp.appToken : '';

get currentlyLoadedUnpackedApp() {
if (this.platformAppsService.enabledApps.length === 0) return null;
Expand All @@ -55,11 +54,12 @@ export default class AppPlatformDeveloperSettings extends Vue {
try {
const error = await this.platformAppsService.installUnpackedApp(
this.appPathValue,
this.appTokenValue
this.appTokenValue,
);
this.error = error;
} catch (e) {
this.error = 'There was an error loading this app, please try again ' +
this.error =
'There was an error loading this app, please try again ' +
'or contact the Streamlabs development team for assistance.';
}

Expand All @@ -74,7 +74,8 @@ export default class AppPlatformDeveloperSettings extends Vue {
const error = await this.platformAppsService.reloadApp(this.currentlyLoadedUnpackedApp.id);
this.error = error;
} catch (e) {
this.error = 'There was an error loading this app, please try again ' +
this.error =
'There was an error loading this app, please try again ' +
'or contact the Streamlabs development team for assistance.';
}

Expand All @@ -84,5 +85,4 @@ export default class AppPlatformDeveloperSettings extends Vue {
unloadApp() {
this.platformAppsService.unloadApp(this.currentlyLoadedUnpackedApp);
}

}
28 changes: 14 additions & 14 deletions app/components/AppearanceSettings.vue.ts
Expand Up @@ -8,23 +8,20 @@ import { ICustomizationServiceApi, ICustomizationSettings } from 'services/custo
import { WindowsService } from 'services/windows';

@Component({
components: { GenericForm }
components: { GenericForm },
})
export default class AppearanceSettings extends Vue {

@Inject() private customizationService: ICustomizationServiceApi;
@Inject() private windowsService: WindowsService;

settingsFormData: TObsFormData = null;
enableFFZEmotes = false;


created() {
this.settingsFormData = this.customizationService.getSettingsFormData();
this.enableFFZEmotes = this.customizationService.getSettings().enableFFZEmotes;
}


saveSettings(formData: TObsFormData) {
const settings: Partial<ICustomizationSettings> = {};
formData.forEach(formInput => {
Expand All @@ -36,14 +33,17 @@ export default class AppearanceSettings extends Vue {
}

openFFZSettings() {
this.windowsService.createOneOffWindow({
componentName: 'FFZSettings',
title: $t('FrankerFaceZ Settings'),
queryParams: {},
size: {
width: 800,
height: 800
}
}, 'ffz-settings');
this.windowsService.createOneOffWindow(
{
componentName: 'FFZSettings',
title: $t('FrankerFaceZ Settings'),
queryParams: {},
size: {
width: 800,
height: 800,
},
},
'ffz-settings',
);
}
}
}
24 changes: 7 additions & 17 deletions app/components/AppsNav.vue.ts
Expand Up @@ -2,11 +2,7 @@ import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { Inject } from 'util/injector';
import { NavigationService } from 'services/navigation';
import {
PlatformAppsService,
EAppPageSlot,
ILoadedApp
} from 'services/platform-apps';
import { PlatformAppsService, EAppPageSlot, ILoadedApp } from 'services/platform-apps';
import VueResize from 'vue-resize';
Vue.use(VueResize);

Expand Down Expand Up @@ -36,22 +32,19 @@ export default class AppsNav extends Vue {
}

scrollLeft() {
this.appTabsContainer.scrollLeft =
this.appTabsContainer.scrollLeft - this.scrollIncrement;
this.appTabsContainer.scrollLeft = this.appTabsContainer.scrollLeft - this.scrollIncrement;
}

scrollRight() {
this.appTabsContainer.scrollLeft =
this.appTabsContainer.scrollLeft + this.scrollIncrement;
this.appTabsContainer.scrollLeft = this.appTabsContainer.scrollLeft + this.scrollIncrement;
}

handleResize() {
if (!this.isMounted) return false;

this.canScroll =
this.appTabsContainer.scrollWidth > this.appTabsContainer.clientWidth;
this.canScroll = this.appTabsContainer.scrollWidth > this.appTabsContainer.clientWidth;
this.hasPrev = this.appTabsContainer.scrollLeft > 0;
let scrollRight =
const scrollRight =
this.appTabsContainer.scrollWidth -
(this.appTabsContainer.scrollLeft + this.appTabsContainer.clientWidth);

Expand All @@ -60,8 +53,7 @@ export default class AppsNav extends Vue {

isSelectedApp(appId: string) {
return (
this.page === 'PlatformAppContainer' &&
this.navigationService.state.params.appId === appId
this.page === 'PlatformAppContainer' && this.navigationService.state.params.appId === appId
);
}

Expand All @@ -74,9 +66,7 @@ export default class AppsNav extends Vue {
}

isPopOutAllowed(app: ILoadedApp) {
const topNavPage = app.manifest.pages.find(
page => page.slot === EAppPageSlot.TopNav
);
const topNavPage = app.manifest.pages.find(page => page.slot === EAppPageSlot.TopNav);
if (!topNavPage) return false;

// Default result is true
Expand Down

0 comments on commit b94f0b5

Please sign in to comment.