From 8dc5b8a4b083e5f1132f8a7a38456007e17e1e82 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 14 Dec 2020 10:21:04 +0100 Subject: [PATCH] Fix lint issues Signed-off-by: Thomas Citharel --- js/.eslintrc.js | 24 +------------------ js/src/components/Editor.vue | 3 +++ js/src/components/Editor/Image.ts | 2 ++ js/src/components/Editor/MaxSize.ts | 3 +++ .../components/Event/AddressAutoComplete.vue | 2 ++ .../Event/FullAddressAutoComplete.vue | 2 ++ js/src/filters/index.ts | 1 + js/src/graphql/event.ts | 1 - js/src/router/guards/auth-guard.ts | 1 - js/src/router/guards/register-guard.ts | 1 - js/tests/e2e/.eslintrc.js | 8 +++++++ .../e2e/custom-assertions/elementCount.js | 1 + js/tests/e2e/specs/browser-language.js | 1 + js/tests/e2e/specs/event.js | 2 -- js/tests/e2e/specs/login.js | 3 --- js/tests/e2e/specs/register.js | 1 - js/tests/e2e/support/commands.js | 2 +- js/tests/unit/.eslintrc.js | 6 ----- js/tests/unit/svgTransform.js | 1 + js/vue.config.js | 4 ---- 20 files changed, 26 insertions(+), 43 deletions(-) create mode 100644 js/tests/e2e/.eslintrc.js diff --git a/js/.eslintrc.js b/js/.eslintrc.js index 2e51b634..a5dd51f7 100644 --- a/js/.eslintrc.js +++ b/js/.eslintrc.js @@ -32,7 +32,7 @@ module.exports = { "@typescript-eslint/no-explicit-any": "off", "cypress/no-unnecessary-waiting": "off", "vue/max-len": [ - "error", + "off", { ignoreStrings: true, ignoreHTMLTextContents: true, @@ -45,7 +45,6 @@ module.exports = { "prettier/prettier": "error", "@typescript-eslint/interface-name-prefix": "off", "@typescript-eslint/no-use-before-define": "off", - "import/prefer-default-export": "off", "import/extensions": "off", "import/no-unresolved": "off", "no-shadow": "off", @@ -53,25 +52,4 @@ module.exports = { }, ignorePatterns: ["src/typings/*.d.ts", "vue.config.js"], - - overrides: [ - { - files: [ - "**/__tests__/*.{j,t}s?(x)", - "**/tests/unit/**/*.spec.{j,t}s?(x)", - ], - env: { - mocha: true, - }, - }, - { - files: [ - "**/__tests__/*.{j,t}s?(x)", - "**/tests/unit/**/*.spec.{j,t}s?(x)", - ], - env: { - jest: true, - }, - }, - ], }; diff --git a/js/src/components/Editor.vue b/js/src/components/Editor.vue index 62ae4549..200b5176 100644 --- a/js/src/components/Editor.vue +++ b/js/src/components/Editor.vue @@ -407,6 +407,7 @@ export default class EditorComponent extends Vue { new Image(), new MaxSize({ maxSize: this.maxSize }), ], + // eslint-disable-next-line @typescript-eslint/ban-types onUpdate: ({ getHTML }: { getHTML: Function }) => { this.$emit("input", getHTML()); }, @@ -422,6 +423,7 @@ export default class EditorComponent extends Vue { } } + // eslint-disable-next-line @typescript-eslint/ban-types showLinkMenu(command: Function, active: boolean): Function | undefined { if (!this.editor) return undefined; if (active) return command({ href: null }); @@ -536,6 +538,7 @@ export default class EditorComponent extends Vue { * Show a file prompt, upload picture and insert it into editor * @param command */ + // eslint-disable-next-line @typescript-eslint/ban-types async showImagePrompt(command: Function): Promise { const image = await listenFileUpload(); try { diff --git a/js/src/components/Editor/Image.ts b/js/src/components/Editor/Image.ts index 93470cc1..fe73f656 100644 --- a/js/src/components/Editor/Image.ts +++ b/js/src/components/Editor/Image.ts @@ -13,6 +13,7 @@ import { EditorView } from "prosemirror-view"; /* eslint-disable class-methods-use-this */ export default class Image extends Node { + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types get name() { return "image"; } @@ -62,6 +63,7 @@ export default class Image extends Node { }; } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types get plugins() { return [ new Plugin({ diff --git a/js/src/components/Editor/MaxSize.ts b/js/src/components/Editor/MaxSize.ts index 3205263f..16b7dccb 100644 --- a/js/src/components/Editor/MaxSize.ts +++ b/js/src/components/Editor/MaxSize.ts @@ -4,17 +4,20 @@ import { Extension, Plugin } from "tiptap"; export default class MaxSize extends Extension { // eslint-disable-next-line class-methods-use-this + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types get name() { return "maxSize"; } // eslint-disable-next-line class-methods-use-this + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types get defaultOptions() { return { maxSize: null, }; } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types get plugins() { return [ new Plugin({ diff --git a/js/src/components/Event/AddressAutoComplete.vue b/js/src/components/Event/AddressAutoComplete.vue index 93c0e1d2..e98c2fbb 100644 --- a/js/src/components/Event/AddressAutoComplete.vue +++ b/js/src/components/Event/AddressAutoComplete.vue @@ -86,6 +86,7 @@ export default class AddressAutoComplete extends Vue { private gettingLocation = false; + // eslint-disable-next-line no-undef private location!: GeolocationPosition; private gettingLocationError: any; @@ -219,6 +220,7 @@ export default class AddressAutoComplete extends Vue { this.gettingLocation = false; } + // eslint-disable-next-line no-undef static async getLocation(): Promise { return new Promise((resolve, reject) => { if (!("geolocation" in navigator)) { diff --git a/js/src/components/Event/FullAddressAutoComplete.vue b/js/src/components/Event/FullAddressAutoComplete.vue index 22d360bf..35581015 100644 --- a/js/src/components/Event/FullAddressAutoComplete.vue +++ b/js/src/components/Event/FullAddressAutoComplete.vue @@ -137,6 +137,7 @@ export default class FullAddressAutoComplete extends Vue { private gettingLocation = false; + // eslint-disable-next-line no-undef private location!: GeolocationPosition; private gettingLocationError: any; @@ -277,6 +278,7 @@ export default class FullAddressAutoComplete extends Vue { return window.isSecureContext; } + // eslint-disable-next-line no-undef static async getLocation(): Promise { return new Promise((resolve, reject) => { if (!("geolocation" in navigator)) { diff --git a/js/src/filters/index.ts b/js/src/filters/index.ts index 4caa1e3b..941d69c7 100644 --- a/js/src/filters/index.ts +++ b/js/src/filters/index.ts @@ -6,6 +6,7 @@ import { } from "./datetime"; export default { + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types install(vue: any): void { vue.filter("formatDateString", formatDateString); vue.filter("formatTimeString", formatTimeString); diff --git a/js/src/graphql/event.ts b/js/src/graphql/event.ts index 357e28ce..834a25f8 100644 --- a/js/src/graphql/event.ts +++ b/js/src/graphql/event.ts @@ -1,5 +1,4 @@ import gql from "graphql-tag"; -import { GROUP_FIELDS_FRAGMENTS } from "./group"; const participantQuery = ` role, diff --git a/js/src/router/guards/auth-guard.ts b/js/src/router/guards/auth-guard.ts index 4dfa635e..402ca715 100644 --- a/js/src/router/guards/auth-guard.ts +++ b/js/src/router/guards/auth-guard.ts @@ -3,7 +3,6 @@ import { UserRouteName } from "@/router/user"; import { AUTH_ACCESS_TOKEN } from "@/constants"; import { LoginErrorCode } from "@/types/enums"; -// eslint-disable-next-line import/prefer-default-export export const authGuardIfNeeded: NavigationGuard = async (to, from, next) => { if (to.meta.requiredAuth !== true) return next(); diff --git a/js/src/router/guards/register-guard.ts b/js/src/router/guards/register-guard.ts index 879d67f8..0c455cf8 100644 --- a/js/src/router/guards/register-guard.ts +++ b/js/src/router/guards/register-guard.ts @@ -3,7 +3,6 @@ import { NavigationGuard } from "vue-router"; import { CONFIG } from "../../graphql/config"; import apolloProvider from "../../vue-apollo"; -// eslint-disable-next-line import/prefer-default-export export const beforeRegisterGuard: NavigationGuard = async (to, from, next) => { const { data } = await apolloProvider.defaultClient.query({ query: CONFIG, diff --git a/js/tests/e2e/.eslintrc.js b/js/tests/e2e/.eslintrc.js new file mode 100644 index 00000000..a653db11 --- /dev/null +++ b/js/tests/e2e/.eslintrc.js @@ -0,0 +1,8 @@ +module.exports = { + env: { + jest: true, + "cypress/globals": true, + }, + extends: ["plugin:cypress/recommended"], + plugins: ["cypress"], +}; diff --git a/js/tests/e2e/custom-assertions/elementCount.js b/js/tests/e2e/custom-assertions/elementCount.js index 8dabcc23..5ef217ee 100644 --- a/js/tests/e2e/custom-assertions/elementCount.js +++ b/js/tests/e2e/custom-assertions/elementCount.js @@ -1,4 +1,5 @@ export default class ElementCount { + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types constructor(selector, count) { this.message = `Testing if element <${selector}> has count: ${count}`; this.expected = count; diff --git a/js/tests/e2e/specs/browser-language.js b/js/tests/e2e/specs/browser-language.js index 9f7483cb..5df9d8d4 100644 --- a/js/tests/e2e/specs/browser-language.js +++ b/js/tests/e2e/specs/browser-language.js @@ -1,4 +1,5 @@ // Set the en-US language just in case +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export default function (window) { Object.defineProperty(window.navigator, "language", { value: "en-US" }); } diff --git a/js/tests/e2e/specs/event.js b/js/tests/e2e/specs/event.js index 405dd821..9088fde6 100644 --- a/js/tests/e2e/specs/event.js +++ b/js/tests/e2e/specs/event.js @@ -8,7 +8,6 @@ describe("Events", () => { cy.loginUser(); cy.visit("/events/me"); - cy.wait(1000); cy.contains(".message.is-danger", "No events found"); cy.contains(".navbar-item", "Create").click(); @@ -29,7 +28,6 @@ describe("Events", () => { .last() .find(".select select") .select("2021"); - cy.wait(1000); cy.get(".field").eq(3).contains(".datepicker-cell", "15").click(); cy.contains(".button.is-primary", "Create my event").click(); diff --git a/js/tests/e2e/specs/login.js b/js/tests/e2e/specs/login.js index 4727f04c..7f3b89b0 100644 --- a/js/tests/e2e/specs/login.js +++ b/js/tests/e2e/specs/login.js @@ -17,7 +17,6 @@ describe("Login", () => { cy.url().should("include", "/password-reset/send"); cy.go("back"); - cy.wait(1000); cy.get("form").contains(".control a.button", "Register").click(); cy.url().should("include", "/register/user"); @@ -55,7 +54,6 @@ describe("Login", () => { cy.get("input[type=email]").type("user@email.com"); cy.get("input[type=password]").type("some password"); cy.get("form").submit(); - cy.wait(1000); cy.get(".navbar-end .navbar-link span.icon i").should( "have.class", "mdi-account-circle" @@ -113,7 +111,6 @@ describe("Login", () => { cy.get("form .field input").eq(1).type("Not"); cy.get("form .field textarea").clear().type("This will now work"); cy.get("form").submit(); - cy.wait(1000); cy.get(".navbar-link span.icon i").should( "have.class", diff --git a/js/tests/e2e/specs/register.js b/js/tests/e2e/specs/register.js index a97f550b..80caa6ca 100644 --- a/js/tests/e2e/specs/register.js +++ b/js/tests/e2e/specs/register.js @@ -33,7 +33,6 @@ describe("Registration", () => { cy.get("form").contains("button.button.is-primary", "Register").click(); cy.url().should("include", "/register/profile"); - cy.wait(1000); cy.get("form > .field") .eq(1) .contains("label", "Username") diff --git a/js/tests/e2e/support/commands.js b/js/tests/e2e/support/commands.js index e830f15f..8268b7ee 100644 --- a/js/tests/e2e/support/commands.js +++ b/js/tests/e2e/support/commands.js @@ -138,7 +138,7 @@ Cypress.Commands.add("waitForFetches", () => { return; } - cy.wait(100).then(() => cy.waitForFetches()); + cy.waitForFetches(); }); Cypress.Commands.add("iframeLoaded", { prevSubject: "element" }, ($iframe) => { diff --git a/js/tests/unit/.eslintrc.js b/js/tests/unit/.eslintrc.js index 3c99f324..8c858ac2 100644 --- a/js/tests/unit/.eslintrc.js +++ b/js/tests/unit/.eslintrc.js @@ -6,10 +6,4 @@ module.exports = { expect: true, sinon: true, }, - rules: { - "import/no-extraneous-dependencies": [ - "error", - { devDependencies: ["**/*.test.js", "**/*.spec.js"] }, - ], - }, }; diff --git a/js/tests/unit/svgTransform.js b/js/tests/unit/svgTransform.js index afded764..f349f71a 100644 --- a/js/tests/unit/svgTransform.js +++ b/js/tests/unit/svgTransform.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires const vueJest = require("vue-jest/lib/template-compiler"); module.exports = { diff --git a/js/vue.config.js b/js/vue.config.js index 5dfdba8f..4ac29a74 100644 --- a/js/vue.config.js +++ b/js/vue.config.js @@ -2,11 +2,7 @@ const path = require("path"); const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); module.exports = { - devServer: { - proxy: "http://mobilizon1.com", - }, runtimeCompiler: true, - lintOnSave: process.env.NODE_ENV !== "production", filenameHashing: true, productionSourceMap: false, outputDir: path.resolve(__dirname, "../priv/static"),