mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
fix flow and linter warnings
This commit is contained in:
@@ -1,29 +1,3 @@
|
|||||||
{
|
{
|
||||||
"parser": "babel-eslint",
|
"extends": "@scm-manager/eslint-config"
|
||||||
"extends": [
|
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:react/recommended",
|
|
||||||
"plugin:flowtype/recommended"
|
|
||||||
],
|
|
||||||
"plugins": [
|
|
||||||
"flowtype",
|
|
||||||
"react",
|
|
||||||
"jsx-a11y",
|
|
||||||
"import"
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"quotes": ["error", "double"]
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"browser": true
|
|
||||||
},
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": [ "*.test.js" ],
|
|
||||||
"env": {
|
|
||||||
"jest": true,
|
|
||||||
"browser": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,18 +42,11 @@
|
|||||||
"pre-commit": "jest && flow && eslint src"
|
"pre-commit": "jest && flow && eslint src"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@scm-manager/ui-bundler": "^0.0.7",
|
"@scm-manager/ui-bundler": "^0.0.9",
|
||||||
"babel-eslint": "^8.2.6",
|
|
||||||
"copyfiles": "^2.0.0",
|
"copyfiles": "^2.0.0",
|
||||||
"enzyme": "^3.3.0",
|
"enzyme": "^3.3.0",
|
||||||
"enzyme-adapter-react-16": "^1.1.1",
|
"enzyme-adapter-react-16": "^1.1.1",
|
||||||
"eslint": "^5.3.0",
|
|
||||||
"eslint-plugin-flowtype": "^2.50.0",
|
|
||||||
"eslint-plugin-import": "^2.14.0",
|
|
||||||
"eslint-plugin-jsx-a11y": "^6.1.1",
|
|
||||||
"eslint-plugin-react": "^7.10.0",
|
|
||||||
"fetch-mock": "^6.5.0",
|
"fetch-mock": "^6.5.0",
|
||||||
"flow-bin": "^0.77.0",
|
|
||||||
"flow-typed": "^2.5.1",
|
"flow-typed": "^2.5.1",
|
||||||
"jest": "^23.5.0",
|
"jest": "^23.5.0",
|
||||||
"node-sass-chokidar": "^1.3.0",
|
"node-sass-chokidar": "^1.3.0",
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ class PluginLoader extends React.Component<Props, State> {
|
|||||||
})
|
})
|
||||||
.then(script => {
|
.then(script => {
|
||||||
// TODO is this safe???
|
// TODO is this safe???
|
||||||
|
// eslint-disable-next-line no-eval
|
||||||
eval(script); // NOSONAR
|
eval(script); // NOSONAR
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
@@ -1,18 +1,26 @@
|
|||||||
|
// @flow
|
||||||
//modified from https://github.com/GA-MO/react-confirm-alert
|
//modified from https://github.com/GA-MO/react-confirm-alert
|
||||||
|
|
||||||
import React from "react";
|
import * as React from "react";
|
||||||
import { render, unmountComponentAtNode } from "react-dom";
|
import { render, unmountComponentAtNode } from "react-dom";
|
||||||
import "./ConfirmAlert.css";
|
import "./ConfirmAlert.css";
|
||||||
|
|
||||||
|
type Button = {
|
||||||
|
label: string,
|
||||||
|
onClick: () => void | null
|
||||||
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title: string,
|
title: string,
|
||||||
message: string,
|
message: string,
|
||||||
buttons: array
|
buttons: Button[]
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfirmAlert extends React.Component<Props> {
|
class ConfirmAlert extends React.Component<Props> {
|
||||||
handleClickButton = button => {
|
handleClickButton = (button: Button) => {
|
||||||
if (button.onClick) button.onClick();
|
if (button.onClick) {
|
||||||
|
button.onClick();
|
||||||
|
}
|
||||||
this.close();
|
this.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,20 +56,26 @@ class ConfirmAlert extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createElementReconfirm(properties) {
|
function createElementReconfirm(properties: Props) {
|
||||||
const divTarget = document.createElement("div");
|
const divTarget = document.createElement("div");
|
||||||
divTarget.id = "react-confirm-alert";
|
divTarget.id = "react-confirm-alert";
|
||||||
|
if (document.body) {
|
||||||
document.body.appendChild(divTarget);
|
document.body.appendChild(divTarget);
|
||||||
render(<ConfirmAlert {...properties} />, divTarget);
|
render(<ConfirmAlert {...properties} />, divTarget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeElementReconfirm() {
|
function removeElementReconfirm() {
|
||||||
const target = document.getElementById("react-confirm-alert");
|
const target = document.getElementById("react-confirm-alert");
|
||||||
|
if (target) {
|
||||||
unmountComponentAtNode(target);
|
unmountComponentAtNode(target);
|
||||||
|
if (target.parentNode) {
|
||||||
target.parentNode.removeChild(target);
|
target.parentNode.removeChild(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function confirmAlert(properties) {
|
export function confirmAlert(properties: Props) {
|
||||||
createElementReconfirm(properties);
|
createElementReconfirm(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import { Route } from "react-router";
|
import { Route } from "react-router";
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import Main from "./Main";
|
import Main from "./Main";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -15,6 +16,7 @@ import { PrimaryNavigation } from "../components/navigation";
|
|||||||
import Loading from "../components/Loading";
|
import Loading from "../components/Loading";
|
||||||
import ErrorPage from "../components/ErrorPage";
|
import ErrorPage from "../components/ErrorPage";
|
||||||
import { Footer, Header } from "../components/layout";
|
import { Footer, Header } from "../components/layout";
|
||||||
|
import type { Me } from "../types/Me";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
me: Me,
|
me: Me,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import React from 'react';
|
import React from "react";
|
||||||
import NavLink from "../../../components/navigation/NavLink";
|
import NavLink from "../../../components/navigation/NavLink";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import type { Group } from "../../types/Group";
|
import type { Group } from "../../types/Group";
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ describe("groups fetch()", () => {
|
|||||||
|
|
||||||
const callMe = () => {
|
const callMe = () => {
|
||||||
called = true;
|
called = true;
|
||||||
}
|
};
|
||||||
const store = mockStore({});
|
const store = mockStore({});
|
||||||
return store.dispatch(createGroup(humanGroup, callMe)).then(() => {
|
return store.dispatch(createGroup(humanGroup, callMe)).then(() => {
|
||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
@@ -254,9 +254,9 @@ describe("groups fetch()", () => {
|
|||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
expect(actions[0].type).toEqual(MODIFY_GROUP_PENDING);
|
expect(actions[0].type).toEqual(MODIFY_GROUP_PENDING);
|
||||||
expect(actions[1].type).toEqual(MODIFY_GROUP_SUCCESS);
|
expect(actions[1].type).toEqual(MODIFY_GROUP_SUCCESS);
|
||||||
expect(actions[1].payload).toEqual(humanGroup)
|
expect(actions[1].payload).toEqual(humanGroup);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})
|
|
||||||
|
|
||||||
it("should call the callback after modifying group", () => {
|
it("should call the callback after modifying group", () => {
|
||||||
fetchMock.putOnce("http://localhost:8081/api/rest/v2/groups/humanGroup", {
|
fetchMock.putOnce("http://localhost:8081/api/rest/v2/groups/humanGroup", {
|
||||||
@@ -266,7 +266,7 @@ describe("groups fetch()", () => {
|
|||||||
let called = false;
|
let called = false;
|
||||||
const callback = () => {
|
const callback = () => {
|
||||||
called = true;
|
called = true;
|
||||||
}
|
};
|
||||||
const store = mockStore({});
|
const store = mockStore({});
|
||||||
|
|
||||||
return store.dispatch(modifyGroup(humanGroup, callback)).then(() => {
|
return store.dispatch(modifyGroup(humanGroup, callback)).then(() => {
|
||||||
@@ -275,7 +275,7 @@ describe("groups fetch()", () => {
|
|||||||
expect(actions[1].type).toEqual(MODIFY_GROUP_SUCCESS);
|
expect(actions[1].type).toEqual(MODIFY_GROUP_SUCCESS);
|
||||||
expect(called).toBe(true);
|
expect(called).toBe(true);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
it("should fail modifying group on HTTP 500", () => {
|
it("should fail modifying group on HTTP 500", () => {
|
||||||
fetchMock.putOnce("http://localhost:8081/api/rest/v2/groups/humanGroup", {
|
fetchMock.putOnce("http://localhost:8081/api/rest/v2/groups/humanGroup", {
|
||||||
@@ -290,7 +290,7 @@ describe("groups fetch()", () => {
|
|||||||
expect(actions[1].type).toEqual(MODIFY_GROUP_FAILURE);
|
expect(actions[1].type).toEqual(MODIFY_GROUP_FAILURE);
|
||||||
expect(actions[1].payload).toBeDefined();
|
expect(actions[1].payload).toBeDefined();
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
it("should delete successfully group humanGroup", () => {
|
it("should delete successfully group humanGroup", () => {
|
||||||
fetchMock.deleteOnce("http://localhost:8081/api/rest/v2/groups/humanGroup", {
|
fetchMock.deleteOnce("http://localhost:8081/api/rest/v2/groups/humanGroup", {
|
||||||
@@ -493,7 +493,7 @@ describe("selector tests", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should return null when there are no groups in the state", () => {
|
it("should return null when there are no groups in the state", () => {
|
||||||
expect(getGroupsFromState({})).toBe(null)
|
expect(getGroupsFromState({})).toBe(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return true, when fetch groups is pending", () => {
|
it("should return true, when fetch groups is pending", () => {
|
||||||
@@ -563,23 +563,23 @@ describe("selector tests", () => {
|
|||||||
expect(isCreateGroupPending({pending: {
|
expect(isCreateGroupPending({pending: {
|
||||||
[CREATE_GROUP]: true
|
[CREATE_GROUP]: true
|
||||||
}})).toBeTruthy();
|
}})).toBeTruthy();
|
||||||
})
|
});
|
||||||
|
|
||||||
it("should return false if create group is not pending", () => {
|
it("should return false if create group is not pending", () => {
|
||||||
expect(isCreateGroupPending({})).toBe(false);
|
expect(isCreateGroupPending({})).toBe(false);
|
||||||
})
|
});
|
||||||
|
|
||||||
it("should return error if creating group failed", () => {
|
it("should return error if creating group failed", () => {
|
||||||
expect(getCreateGroupFailure({
|
expect(getCreateGroupFailure({
|
||||||
failure: {
|
failure: {
|
||||||
[CREATE_GROUP]: error
|
[CREATE_GROUP]: error
|
||||||
}
|
}
|
||||||
})).toEqual(error)
|
})).toEqual(error);
|
||||||
})
|
});
|
||||||
|
|
||||||
it("should return undefined if creating group did not fail", () => {
|
it("should return undefined if creating group did not fail", () => {
|
||||||
expect(getCreateGroupFailure({})).toBeUndefined()
|
expect(getCreateGroupFailure({})).toBeUndefined();
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
it("should return true, when delete group humanGroup is pending", () => {
|
it("should return true, when delete group humanGroup is pending", () => {
|
||||||
@@ -613,20 +613,20 @@ describe("selector tests", () => {
|
|||||||
pending: {
|
pending: {
|
||||||
[CREATE_GROUP]: true
|
[CREATE_GROUP]: true
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
expect(isCreateGroupPending(state)).toBe(true);
|
expect(isCreateGroupPending(state)).toBe(true);
|
||||||
})
|
});
|
||||||
|
|
||||||
it("should return false, if createGroup is not pending", () => {
|
it("should return false, if createGroup is not pending", () => {
|
||||||
expect(isCreateGroupPending({})).toBe(false)
|
expect(isCreateGroupPending({})).toBe(false);
|
||||||
})
|
});
|
||||||
|
|
||||||
it("should return error of createGroup failed", () => {
|
it("should return error of createGroup failed", () => {
|
||||||
const state = {
|
const state = {
|
||||||
failure: {
|
failure: {
|
||||||
[CREATE_GROUP]: error
|
[CREATE_GROUP]: error
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
expect(getCreateGroupFailure(state)).toEqual(error)
|
expect(getCreateGroupFailure(state)).toEqual(error);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable no-console */
|
||||||
// In production, we register a service worker to serve assets from local cache.
|
// In production, we register a service worker to serve assets from local cache.
|
||||||
|
|
||||||
// This lets the app load faster on subsequent visits in production, and gives
|
// This lets the app load faster on subsequent visits in production, and gives
|
||||||
@@ -9,9 +10,9 @@
|
|||||||
// This link also includes instructions on opting out of this behavior.
|
// This link also includes instructions on opting out of this behavior.
|
||||||
|
|
||||||
const isLocalhost = Boolean(
|
const isLocalhost = Boolean(
|
||||||
window.location.hostname === 'localhost' ||
|
window.location.hostname === "localhost" ||
|
||||||
// [::1] is the IPv6 localhost address.
|
// [::1] is the IPv6 localhost address.
|
||||||
window.location.hostname === '[::1]' ||
|
window.location.hostname === "[::1]" ||
|
||||||
// 127.0.0.1/8 is considered localhost for IPv4.
|
// 127.0.0.1/8 is considered localhost for IPv4.
|
||||||
window.location.hostname.match(
|
window.location.hostname.match(
|
||||||
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
||||||
@@ -19,7 +20,7 @@ const isLocalhost = Boolean(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export default function register() {
|
export default function register() {
|
||||||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
|
||||||
// The URL constructor is available in all browsers that support SW.
|
// The URL constructor is available in all browsers that support SW.
|
||||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
|
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
|
||||||
if (publicUrl.origin !== window.location.origin) {
|
if (publicUrl.origin !== window.location.origin) {
|
||||||
@@ -29,7 +30,7 @@ export default function register() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener("load", () => {
|
||||||
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||||
|
|
||||||
if (isLocalhost) {
|
if (isLocalhost) {
|
||||||
@@ -40,8 +41,8 @@ export default function register() {
|
|||||||
// service worker/PWA documentation.
|
// service worker/PWA documentation.
|
||||||
navigator.serviceWorker.ready.then(() => {
|
navigator.serviceWorker.ready.then(() => {
|
||||||
console.log(
|
console.log(
|
||||||
'This web app is being served cache-first by a service ' +
|
"This web app is being served cache-first by a service " +
|
||||||
'worker. To learn more, visit https://goo.gl/SC7cgQ'
|
"worker. To learn more, visit https://goo.gl/SC7cgQ"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -59,25 +60,25 @@ function registerValidSW(swUrl) {
|
|||||||
registration.onupdatefound = () => {
|
registration.onupdatefound = () => {
|
||||||
const installingWorker = registration.installing;
|
const installingWorker = registration.installing;
|
||||||
installingWorker.onstatechange = () => {
|
installingWorker.onstatechange = () => {
|
||||||
if (installingWorker.state === 'installed') {
|
if (installingWorker.state === "installed") {
|
||||||
if (navigator.serviceWorker.controller) {
|
if (navigator.serviceWorker.controller) {
|
||||||
// At this point, the old content will have been purged and
|
// At this point, the old content will have been purged and
|
||||||
// the fresh content will have been added to the cache.
|
// the fresh content will have been added to the cache.
|
||||||
// It's the perfect time to display a "New content is
|
// It's the perfect time to display a "New content is
|
||||||
// available; please refresh." message in your web app.
|
// available; please refresh." message in your web app.
|
||||||
console.log('New content is available; please refresh.');
|
console.log("New content is available; please refresh.");
|
||||||
} else {
|
} else {
|
||||||
// At this point, everything has been precached.
|
// At this point, everything has been precached.
|
||||||
// It's the perfect time to display a
|
// It's the perfect time to display a
|
||||||
// "Content is cached for offline use." message.
|
// "Content is cached for offline use." message.
|
||||||
console.log('Content is cached for offline use.');
|
console.log("Content is cached for offline use.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error during service worker registration:', error);
|
console.error("Error during service worker registration:", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ function checkValidServiceWorker(swUrl) {
|
|||||||
// Ensure service worker exists, and that we really are getting a JS file.
|
// Ensure service worker exists, and that we really are getting a JS file.
|
||||||
if (
|
if (
|
||||||
response.status === 404 ||
|
response.status === 404 ||
|
||||||
response.headers.get('content-type').indexOf('javascript') === -1
|
response.headers.get("content-type").indexOf("javascript") === -1
|
||||||
) {
|
) {
|
||||||
// No service worker found. Probably a different app. Reload the page.
|
// No service worker found. Probably a different app. Reload the page.
|
||||||
navigator.serviceWorker.ready.then(registration => {
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
@@ -103,15 +104,17 @@ function checkValidServiceWorker(swUrl) {
|
|||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
console.log(
|
console.log(
|
||||||
'No internet connection found. App is running in offline mode.'
|
"No internet connection found. App is running in offline mode."
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function unregister() {
|
export function unregister() {
|
||||||
if ('serviceWorker' in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
navigator.serviceWorker.ready.then(registration => {
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
registration.unregister();
|
registration.unregister();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-enable no-console */
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import type { Repository } from "../../types/Repositories";
|
|||||||
import DateFromNow from "../../../components/DateFromNow";
|
import DateFromNow from "../../../components/DateFromNow";
|
||||||
import RepositoryEntryLink from "./RepositoryEntryLink";
|
import RepositoryEntryLink from "./RepositoryEntryLink";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
|
||||||
import RepositoryAvatar from "./RepositoryAvatar";
|
import RepositoryAvatar from "./RepositoryAvatar";
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
|
|||||||
1252
scm-ui/yarn.lock
1252
scm-ui/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user