Skip to content

Commit

Permalink
Merge pull request #94 from anime-skip/lint-cleanup
Browse files Browse the repository at this point in the history
Lint Cleanup
  • Loading branch information
aklinker1 authored Sep 16, 2020
2 parents f1ef7f4 + 74bafd3 commit cca0c5f
Show file tree
Hide file tree
Showing 32 changed files with 134 additions and 206 deletions.
8 changes: 4 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ module.exports = {
},
},
env: {
node: true,
browser: true,
webextensions: true,
},
globals: {
global: false,
},
extends: [
'eslint:recommended',
'@vue/typescript/recommended',
'@vue/prettier',
'@vue/prettier/@typescript-eslint',
],
// required to lint *.vue files
plugins: ['vue', '@typescript-eslint', 'prettier'],
plugins: ['vue', '@typescript-eslint', 'prettier', 'only-warn'],
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"compile": "tsc -p . --noEmit",
"lint": "eslint --ext .js,.ts,.vue src",
"lint": "eslint --ext .js,.ts,.vue src --max-warnings=0",
"prettier": "prettier --check \"src/**/*.{js,ts,vue}\"",
"prettier:write": "yarn prettier --write",
"check-manifest": "yarn build:prod && yarn web-ext --config=.web-ext.config.js lint && yarn build:chrome:prod && yarn web-ext --config=.web-ext.config.js lint",
Expand Down Expand Up @@ -69,6 +69,7 @@
"eslint-loader": "^3.0.2",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-only-warn": "^1.0.2",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
Expand Down
4 changes: 1 addition & 3 deletions scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ title "Pre-package"
run "Install dependencies" "yarn install"
run "Check for type errors" "yarn compile"
run "Check formatting" "yarn prettier"
# run "Lint" "yarn lint"
run "Lint" "yarn lint"
run "Run Tests" "yarn test --ci"
run "Run Integration Tests" "yarn test:integration --ci"
run "Run E2E Tests" "yarn test:e2e --ci"
Expand All @@ -102,8 +102,6 @@ SOURCES="$SOURCES webpack.config.js"
SOURCES="$SOURCES yarn.lock"
run "Creating ${CODE}sources.zip" "zip -r '$OUTPUT_NAME/sources.zip' $SOURCES"

# TODO - Create source.zip

# Firefox
run "Building for ${CODE}firefox" "yarn build:prod"
run "Create ${CODE}firefox.zip" "(cd dist && zip -r '../$OUTPUT_NAME/firefox.zip' .)"
Expand Down
6 changes: 6 additions & 0 deletions src/@types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ type BrowserType =
| 'edgechromium'
| 'unsupported';

interface AutocompleteItem {
id?: string;
title: string;
subtitle?: string;
}

/**
* Episode data pulled from the parent webpage
*/
Expand Down
1 change: 0 additions & 1 deletion src/background/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import AxiosApi from '@/common/api/AxiosApi';
import Messenger from '@/common/utils/Messenger';
import { url } from 'inspector';

// Setup Globals

Expand Down
81 changes: 0 additions & 81 deletions src/common/.test-data/timestamps.ts

This file was deleted.

13 changes: 7 additions & 6 deletions src/common/api/AxiosApi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import Axios, { AxiosError } from 'axios';
import Utils from '@/common/utils/Utils';
import Browser from '@/common/utils/Browser';
Expand Down Expand Up @@ -130,12 +131,6 @@ const episodeUrlData = `
`;

/* eslint-disable no-console */
async function sendUnauthorizedGraphql<Q extends string, D>(
data: any
): Promise<{ data: { [field in Q]: D } }> {
return await sendGraphql(data, true);
}

async function sendGraphql<Q extends string, D>(
data: any,
skipAuth = false
Expand Down Expand Up @@ -170,6 +165,12 @@ async function sendGraphql<Q extends string, D>(
throw err;
}
}

async function sendUnauthorizedGraphql<Q extends string, D>(
data: any
): Promise<{ data: { [field in Q]: D } }> {
return await sendGraphql(data, true);
}
/* eslint-enable no-console */

export default as<Api.Implementation>({
Expand Down
17 changes: 6 additions & 11 deletions src/common/components/AutocompleteTextInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
import TextInput from './TextInput.vue';
interface AutocompleteItem {
id?: string;
title: string;
subtitle?: string;
}
@Component({
components: { TextInput },
})
Expand All @@ -73,11 +67,12 @@ export default class AutocompleteTextInput extends Vue {
}
private searchValue = '';
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
private searchTimeout?: any;
private isFocused: boolean = false;
private isMouseOver: boolean = false;
private wasEscPressed: boolean = false;
private highlightedIndex: number = -1;
private isFocused = false;
private isMouseOver = false;
private wasEscPressed = false;
private highlightedIndex = -1;
public mounted(): void {
if (this.value) {
Expand Down Expand Up @@ -147,7 +142,7 @@ export default class AutocompleteTextInput extends Vue {
public onPressEsc() {
this.wasEscPressed = true;
(document.activeElement as any).blur();
(document.activeElement as HTMLElement | undefined)?.blur();
}
public selectHightlightedOption() {
Expand Down
11 changes: 2 additions & 9 deletions src/common/components/PlaybackRatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class PlaybackRatePicker extends Vue {
@Prop(Boolean) public showLess?: string;
public customRate = '';
public PLAYBACK_SPEEDS = PLAYBACK_SPEEDS.filter(speed => !speed.hideWhenSmall || !this.showLess);
@Getter() public playbackRate!: number;
Expand All @@ -51,16 +52,8 @@ export default class PlaybackRatePicker extends Vue {
}
}
public data() {
return {
PLAYBACK_SPEEDS: PLAYBACK_SPEEDS.filter(speed => !speed.hideWhenSmall || !this.showLess),
};
}
public isConstantSelected(): boolean {
return !!(this as any).PLAYBACK_SPEEDS.find(
(speed: PlaybackRate) => speed.value === this.playbackRate
);
return !!this.PLAYBACK_SPEEDS.find((speed: PlaybackRate) => speed.value === this.playbackRate);
}
public get isCustomError(): boolean {
Expand Down
6 changes: 3 additions & 3 deletions src/common/components/TextInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@ export default class TextInput extends Vue {
this.inputValue = value ?? '';
}
private isFocused: boolean = false;
private isFocused = false;
public onFocus() {
this.$emit('focus');
this.isFocused = true;
}
public focus() {
(this.$refs.input as HTMLInputElement).focus();
(this.$refs.input as HTMLInputElement | undefined)?.focus();
}
public onBlur() {
this.$emit('blur');
this.isFocused = false;
}
public blur() {
(this.$refs.input as HTMLInputElement).blur();
(this.$refs.input as HTMLInputElement | undefined)?.blur();
}
public get inputValue(): string {
Expand Down
16 changes: 10 additions & 6 deletions src/common/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import RequestState from '../utils/RequestState';
import { AssertionError } from 'assert';
import mutationTypes from './mutationTypes';
import Utils from '../utils/Utils';
import actionTypes from './actionTypes';

// TODO make everything async

Expand All @@ -25,6 +24,7 @@ function assertLoggedIn(
}
}

/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
async function callApi<A extends any[], R>(
commit: ActionContext<VuexState, VuexState>['commit'],
apiMethod: (...args: A) => Promise<R>,
Expand Down Expand Up @@ -61,7 +61,7 @@ export default as<{ [type in ValueOf<typeof types>]: Action<VuexState, VuexState
commit(mutations.activeDialog, dialogName);
}
},
async [types.startEditing]({ state, commit, dispatch, getters }) {
async [types.startEditing]({ commit, dispatch, getters }) {
global.getVideo().pause();

if (!getters.isLoggedIn) {
Expand All @@ -80,7 +80,7 @@ export default as<{ [type in ValueOf<typeof types>]: Action<VuexState, VuexState
async [types.stopEditing]({ state, commit, dispatch }, discardChanges?: boolean) {
console.log('stopEditing', { discardChanges });
if (!discardChanges) {
const oldTimestamps = state.episodeUrl!.episode.timestamps;
const oldTimestamps = state.episodeUrl?.episode.timestamps ?? [];
const newTimestamps = state.draftTimestamps;
dispatch(types.updateTimestamps, {
oldTimestamps,
Expand Down Expand Up @@ -187,7 +187,9 @@ export default as<{ [type in ValueOf<typeof types>]: Action<VuexState, VuexState
if (episodeUrlData.create) {
try {
await callApi(commit, global.Api.deleteEpisodeUrl, episodeUrlData.data.url);
} catch (err) {}
} catch (err) {
// Do nothing
}
episodeUrl = await callApi(
commit,
global.Api.createEpisodeUrl,
Expand All @@ -207,7 +209,9 @@ export default as<{ [type in ValueOf<typeof types>]: Action<VuexState, VuexState
newTimestamps,
episodeUrl,
});
} catch (err) {}
} catch (err) {
// Do nothing
}
}

// Update the data
Expand Down Expand Up @@ -245,7 +249,7 @@ export default as<{ [type in ValueOf<typeof types>]: Action<VuexState, VuexState
await dispatch(types.fetchThirdPartyEpisode, state.inferredEpisodeInfo.name);
}
},
async [types.fetchEpisodeByUrl]({ commit, dispatch }, url) {
async [types.fetchEpisodeByUrl]({ commit }, url) {
console.log('actions.fetchEpisodeByUrl', { url });
try {
commit(mutationTypes.episodeRequestState, RequestState.LOADING);
Expand Down
3 changes: 2 additions & 1 deletion src/common/store/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default as<
{ changes, callback }: { changes: Partial<VuexState>; callback?: () => void }
) {
for (const field in changes) {
/* eslint-disable-next-line no-prototype-builtins */
if (state.hasOwnProperty(field)) {
if (field === 'playbackRate') {
const playbackRate = (changes[field] as number) || 1;
Expand Down Expand Up @@ -115,7 +116,7 @@ export default as<
},

// Preferences
[types.togglePref](state, change: { pref: keyof Api.Preferences; value: any }) {
[types.togglePref](state, change: { pref: keyof Api.Preferences; value: boolean }) {
if (!state.account) {
console.warn('togglePref() called without account in the store');
return;
Expand Down
1 change: 1 addition & 0 deletions src/common/utils/Browser.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
persistedKeys,
REFRESH_TOKEN_DURATION,
Expand Down
1 change: 1 addition & 0 deletions src/common/utils/GlobalUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export async function sleep(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}

/* eslint-disable @typescript-eslint/no-explicit-any */
export function clone(data: any): any {
try {
return JSON.parse(JSON.stringify(data));
Expand Down
1 change: 1 addition & 0 deletions src/common/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default class Utils {
console.warn('Not in full screen mode, tried to exit');
return;
}
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
const d = document as any;
if (document.exitFullscreen) {
document.exitFullscreen();
Expand Down
1 change: 1 addition & 0 deletions src/common/utils/VuexDecorators.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { createDecorator, VueDecorator } from 'vue-class-component';
import mutationTypes from '@/common/store/mutationTypes';
import actionTypes from '@/common/store/actionTypes';
Expand Down
Loading

0 comments on commit cca0c5f

Please sign in to comment.