Skip to content

Commit 0dca7d3

Browse files
committed
Fixed eslint
1 parent cc7cb9d commit 0dca7d3

25 files changed

+106
-79
lines changed

.eslintrc.json

+17-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"multiline-ternary": 0,
3636
"new-cap": 0, // babel/new-cap
3737
"array-element-newline": [1, "consistent"],
38-
"comma-dangle": [1, "always-multiline"],
38+
"comma-dangle": 0, // using typescript-eslint/comma-dangle
3939
"function-call-argument-newline": [1, "consistent"],
4040
"max-len": [1, { "code": 120, "ignorePattern": "http?s:\/\/", "ignoreTrailingComments": true}], // override 80 that is too low
4141
"padded-blocks": [1, "never"],
@@ -68,13 +68,23 @@
6868
"enforceConst": true
6969
}
7070
],
71+
"@typescript-eslint/comma-dangle": [1, "always-multiline"],
72+
"@typescript-eslint/method-signature-style": [1, "method"],
73+
"@typescript-eslint/init-declarations": 0, // let a ; try {a = funct()} catch (e) throw e; if a.sdfsd . In this example we can't have instant init
74+
"@typescript-eslint/prefer-readonly-parameter-types": 0, // too many issues, we can't mofidy arguments, we can' use type like number[], because rule @typescript-eslint/array-type
75+
"@typescript-eslint/naming-convention": [1,
76+
{
77+
"selector": "property",
78+
"format": ["PascalCase", "camelCase"] // PascalCase for Vue-property-decorator components: {AppAlert}
79+
}
80+
],
7181
"babel/object-curly-spacing": 1,
7282
"babel/quotes": 1,
7383
"babel/semi": 1,
7484
"babel/no-unused-expressions": 1,
7585
"babel/valid-typeof": 1,
7686
"babel/new-cap": 1,
77-
"babel/camelcase": 1,
87+
"babel/camelcase": 0, // use typescript-eslint/naming-convention
7888
"babel/no-invalid-this": 1,
7989
"import/no-named-as-default": 1, //is not part of default sert
8090
"import/no-unresolved": 0,
@@ -154,21 +164,22 @@
154164
],
155165
"vuetify/grid-unknown-attributes": 1,
156166
"vuetify/no-legacy-grid": 0,
157-
"vuetify/no-deprecated-classes": 1
167+
"vuetify/no-deprecated-classes": 1,
168+
"class-methods-use-this": 0,
169+
"@typescript-eslint/no-unnecessary-condition": 0 // too many times we want to make sure that variable that is not null is present or not. Let's say window.RTPConnection is declaread as non-nullable but we still check it in runtime
158170
},
159171
"overrides": [
160172
{
161173
"files": ["*.vue", "*.d.ts"],
162174
"rules": {
163-
"import/no-default-export": 0,
164-
"class-methods-use-this": 0
175+
"import/no-default-export": 0
176+
165177
}
166178
},
167179
{
168180
"files": ["*.vue"],
169181
"rules": {
170182
"@typescript-eslint/prefer-readonly": 0, // can be used in template
171-
"class-methods-use-this": 0,
172183
"import/unambiguous": 0 // vue SFC can miss script tags
173184
}
174185
}

cypress/integration/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
declare namespace Cypress {
1+
declare namespace Cypress { // eslint-disable-line @typescript-eslint/no-unused-vars
22
interface cy {
33

44
/**

cypress/integration/pages/branches.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe("Branches page", (): void => {
2828
cy.visit("/branches");
2929
cy.get("[data-cy=hamburger-icon]").click();
3030
cy.contains("Home").click();
31-
cy.url().should("eq", `${Cypress.config().baseUrl}/`);
31+
cy.url().should("eq", `${String(Cypress.config().baseUrl)}/`);
3232
cy.get("[data-cy=hamburger-icon]").click();
3333
cy.contains("Branches").click();
3434
cy.assertCalledTimes("get-branches", 1);

cypress/integration/unit/xhr.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ describe("Xhr", (): void => {
9797
url: "/test",
9898
});
9999
cy.get("@test-get").should((req: JQuery) => {
100-
// @ts-ignore next-line
100+
// @ts-expect-error
101+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
101102
expect(req.request.headers).to.include({"app-version": "app-v1"});
102103
});
103104
});
@@ -120,7 +121,8 @@ describe("Xhr", (): void => {
120121
url: "/test",
121122
});
122123
cy.get("@test-get").should((req: JQuery) => {
123-
// @ts-ignore next-line
124+
// @ts-expect-error
125+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
124126
expect(req.request.body).to.be.deep.eq({aa: 1});
125127
});
126128
});

src/components/App.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
<script lang="ts">
1616
import {AlertsState, alertsModule} from "@/store/modules/alerts";
1717
import {Component, Vue} from "vue-property-decorator";
18-
import {AlertModel} from "@/types/model";
18+
import type {AlertModel} from "@/types/model";
1919
import AppAlert from "@/components/ui/AppAlert.vue";
2020
2121
@Component({
2222
components: {AppAlert},
2323
})
2424
export default class App extends Vue {
2525
@AlertsState
26-
public alerts!: AlertModel[];
26+
public readonly alerts!: AlertModel[];
2727
28-
private close(alert: AlertModel): void {
28+
private close(alert: Readonly<AlertModel>): void {
2929
alertsModule.removeAlert(alert);
3030
}
3131
}

src/components/pages/RepoBranchesPage.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<script lang="ts">
2727
import {Component, Vue} from "vue-property-decorator";
2828
import {GithubState, githubModule} from "@/store/modules/github";
29-
import {Branch} from "@/types/model";
30-
import ResourceLoader from "@/components/ui/ResourceLoader.vue";
29+
import type {Branch} from "@/types/model";
3130
import {ResolveHandler} from "@/utils/decorators";
31+
import ResourceLoader from "@/components/ui/ResourceLoader.vue";
3232
3333
/**
3434
* Represent list of github repositories

src/components/pages/RepoCommitPage.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525

2626
<script lang="ts">
2727
import {Component, Prop, Vue} from "vue-property-decorator";
28-
import {CommitResponse} from "@/types/gitCommit";
29-
import ResourceLoader from "@/components/ui/ResourceLoader.vue";
28+
import type {CommitResponse} from "@/types/gitCommit";
3029
import {ResolveHandler} from "@/utils/decorators";
30+
import ResourceLoader from "@/components/ui/ResourceLoader.vue";
31+
3132
@Component({
3233
components: {ResourceLoader},
3334
})

src/components/ui/AppAlert.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<script lang="ts">
1414
import {Component, Emit, Prop, Vue} from "vue-property-decorator";
15-
import {AlertModel} from "@/types/model";
15+
import type {AlertModel} from "@/types/model";
1616
1717
@Component
1818
export default class AppAlert extends Vue {

src/components/ui/ResourceLoader.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</template>
1414
<script lang="ts">
1515
import {Component, Prop, Vue} from "vue-property-decorator";
16-
import {AlertModel} from "@/types/model";
16+
import type {AlertModel} from "@/types/model";
1717
import AppAlert from "@/components/ui/AppAlert.vue";
1818
import {HandleLoading} from "vuex-module-decorators-state";
1919
@@ -49,21 +49,21 @@ import {HandleLoading} from "vuex-module-decorators-state";
4949
components: {AppAlert},
5050
})
5151
export default class ResourceLoader extends Vue {
52-
public serverError: AlertModel|null = null;
53-
54-
public loading: boolean = false;
55-
5652
@Prop({
5753
default: "Loading",
5854
})
5955
public readonly loadingTitle!: string;
6056
57+
public serverError: AlertModel|null = null;
58+
59+
public loading: boolean = false;
60+
6161
@HandleLoading({
6262
errPropNameOrCB: "serverError",
6363
loadingPropName: "loading",
6464
})
6565
private async created(): Promise<void> {
66-
await new Promise((resolve: Function, reject: Function) => {
66+
await new Promise((resolve: () => void, reject: () => void) => {
6767
this.$emit("load", {
6868
reject,
6969
resolve,

src/components/ui/SubmitForm.vue

+11-11
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
</template>
2222
<script lang="ts">
2323
import {Component, Emit, Prop, Ref, Vue} from "vue-property-decorator";
24-
import {AlertModel} from "@/types/model";
24+
import type {AlertModel} from "@/types/model";
2525
import AppAlert from "@/components/ui/AppAlert.vue";
26-
import {ResolveHandler} from "@/utils/decorators";
2726
import {HandleLoading} from "vuex-module-decorators-state";
2827
2928
/**
@@ -59,12 +58,6 @@ import {HandleLoading} from "vuex-module-decorators-state";
5958
components: {AppAlert},
6059
})
6160
export default class SubmitForm extends Vue {
62-
public serverError: AlertModel|null = null;
63-
64-
public loading: boolean = false;
65-
66-
public valid: boolean = false;
67-
6861
@Prop()
6962
public readonly value!: boolean;
7063
@@ -74,6 +67,12 @@ export default class SubmitForm extends Vue {
7467
@Ref()
7568
private readonly form!: HTMLFormElement;
7669
70+
public serverError: AlertModel|null = null;
71+
72+
public loading: boolean = false;
73+
74+
public valid: boolean = false;
75+
7776
@Emit()
7877
public input(valid: boolean): boolean {
7978
this.valid = valid;
@@ -84,12 +83,13 @@ export default class SubmitForm extends Vue {
8483
errPropNameOrCB: "serverError",
8584
loadingPropName: "loading",
8685
})
87-
private async handleClick(event: Event): Promise<void> {
86+
private async handleClick(event: Readonly<Event>): Promise<void> {
8887
event.preventDefault();
89-
if (!this.form.validate()) {
88+
// TODO eslint rule
89+
if (!this.form.validate()) { // eslint-disable-line @typescript-eslint/no-unsafe-call
9090
return;
9191
}
92-
await new Promise((resolve: Function, reject: Function) => {
92+
await new Promise((resolve: () => void, reject: () => void) => {
9393
this.$emit("submit", {
9494
reject,
9595
resolve,

src/main.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
import "@/assets/sass/globals.sass";
33
import "@/utils/classComponentHooks"; // eslint-disable-line import/no-unassigned-import
44
import "@/utils/mixins"; // eslint-disable-line import/no-unassigned-import
5+
import type {CreateElement, VNode} from "vue";
56
import {api, xhr} from "@/utils/singletons";
67
import {ApiConsts} from "@/utils/consts"; // eslint-disable-line import/no-namespace
78
import App from "@/components/App.vue";
8-
import Vue from "vue";
9+
// TODO https://github.com/typescript-eslint/typescript-eslint/issues/2315
10+
import Vue from "vue"; // eslint-disable-line no-duplicate-imports
911
import {router} from "@/utils/router";
1012
import {store} from "@/store/store";
1113
import {vuetify} from "@/utils/vuetify"; // eslint-disable-line import/max-dependencies
1214

13-
Vue.prototype.$api = api;
15+
Vue.prototype.$api = api; // eslint-disable-line @typescript-eslint/no-unsafe-member-access
1416

1517
window.consts = ApiConsts;
1618
window.router = router;
@@ -19,7 +21,7 @@ window.api = api;
1921
window.xhr = xhr;
2022

2123
const vue: Vue = new Vue({
22-
render: (createElement: Function): typeof Vue.prototype.$createElement => createElement(App),
24+
render: (createElement: CreateElement): VNode => createElement(App),
2325
router,
2426
store,
2527
vuetify,

src/store/modules/alerts.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {Action, Module, Mutation, VuexModule, getModule} from "vuex-module-decorators";
2-
import {AlertModel, AlertType} from "@/types/model";
2+
import type {AlertModel, AlertType} from "@/types/model";
33
import {getUniqueId, sleep} from "@/utils/helpers";
44
import {ApiConsts} from "@/utils/consts";
5-
import {IAlertsState} from "@/types/store";
5+
import type {IAlertsState} from "@/types/store";
66
import {stateDecoratorFactory} from "vuex-module-decorators-state";
77
import {store} from "@/store/store";
88

@@ -19,18 +19,18 @@ class AlertsModule extends VuexModule implements IAlertsState {
1919
public alerts: AlertModel[] = [];
2020

2121
@Mutation
22-
public addAlert(growlModel: AlertModel): void {
22+
public addAlert(growlModel: Readonly<AlertModel>): void {
2323
this.alerts.push(growlModel);
2424
}
2525

2626
@Mutation
27-
public removeAlert(growlModel: AlertModel): void {
27+
public removeAlert(growlModel: Readonly<AlertModel>): void {
2828
const index = this.alerts.indexOf(growlModel, 0);
2929
this.alerts.splice(index, 1);
3030
}
3131

3232
@Action({rawError: true})
33-
public async showAlert({text, type}: { text: string; type: AlertType}): Promise<void> {
33+
public async showAlert({text, type}: {readonly text: string; type: Readonly<AlertType>}): Promise<void> {
3434
const alert: AlertModel = {
3535
id: getUniqueId(),
3636
text,

src/store/modules/github.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Module, Mutation, VuexModule, getModule} from "vuex-module-decorators";
2-
import {Branch} from "@/types/model";
3-
import {IGithubState} from "@/types/store";
2+
import type {Branch} from "@/types/model";
3+
import type {IGithubState} from "@/types/store";
44
import {stateDecoratorFactory} from "vuex-module-decorators-state";
55
import {store} from "@/store/store";
66

src/store/store.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vuex, {Store} from "vuex";
2-
import {IRootState} from "@/types/store";
2+
import type {IRootState} from "@/types/store";
33
import Vue from "vue";
44

55
Vue.use(Vuex);

src/types/gitCommit.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint babel/camelcase: 0 */
1+
/* eslint @typescript-eslint/naming-convention: 0 */
22

33
interface Author {
44
name: string;

src/types/global.d.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {Api} from "@/utils/api";
2-
import {Consts} from "@/types/model";
3-
import {IRootState} from "@/types/store";
4-
import {Logger} from "lines-logger";
5-
import {Store} from "vuex";
6-
import Vue from "vue";
7-
import VueRouter from "vue-router";
8-
import {Xhr} from "@/utils/xhr";
1+
import type {Api} from "@/utils/api";
2+
import type {Consts} from "@/types/model";
3+
import type {IRootState} from "@/types/store";
4+
import type {Logger} from "lines-logger";
5+
import type {Store} from "vuex";
6+
import type Vue from "vue";
7+
import type VueRouter from "vue-router";
8+
import type {Xhr} from "@/utils/xhr";
99

1010
declare module "vue/types/vue" {
1111

src/types/model.ts

+3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ interface AlertModel {
1616
}
1717

1818
interface Consts {
19+
/* eslint-disable @typescript-eslint/naming-convention */
1920
IS_DEBUG: boolean;
2021
APP_VERSION?: string;
2122
API_URL: string;
2223
HELP_URL: string;
2324
ROUTER_HISTORY_MODE: "hash" | "history";
2425
DISPLAY_ALERTS_MS: number;
2526
MAX_ERROR_NUMBER: number;
27+
/* eslint-enable @typescript-eslint/naming-convention */
2628
}
29+
2730
interface RequestOptions<T> {
2831
url: string;
2932
method: "GET" | "POST";

src/types/store.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AlertModel, Branch} from "@/types/model";
1+
import type {AlertModel, Branch} from "@/types/model";
22

33
interface IGithubState {
44
branches: Branch[]|null;

src/utils/api.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {Branch} from "@/types/model";
2-
import {CommitResponse} from "@/types/gitCommit";
3-
import {Logger} from "lines-logger";
4-
import {Xhr} from "@/utils/xhr";
1+
import type {Branch} from "@/types/model";
2+
import type {CommitResponse} from "@/types/gitCommit";
3+
import type {Logger} from "lines-logger";
4+
import type {Xhr} from "@/utils/xhr";
55

66

77
export class Api {

0 commit comments

Comments
 (0)