diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b4ca637..1cfd5a9 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -35,6 +35,9 @@ jobs:
- name: Check Formatting
run: npm run check-format
+ - name: Lint
+ run: npm run lint
+
- name: Test
run: npm run coverage
diff --git a/package.json b/package.json
index 149a6eb..95353b6 100644
--- a/package.json
+++ b/package.json
@@ -52,7 +52,6 @@
"lodash.debounce": "^4.0.8",
"lodash.isequal": "^4.5.0",
"moment": "^2.24.0",
- "prop-types": "^15.7.2",
"react": "^16.13.1",
"react-app-polyfill": "^1.0.6",
"react-bootstrap-daterangepicker": "^4.1.0",
@@ -77,9 +76,10 @@
"test": "react-scripts test --env=jsdom",
"coverage": "react-scripts test --env=jsdom --coverage",
"codecov": "codecov",
+ "lint": "eslint --ignore-path .gitignore --ext js,ts,tsx .",
"eject": "react-scripts eject",
- "format": "prettier --write \"**/*.{js,tsx}\"",
- "check-format": "prettier --list-different \"**/*.{js,tsx}\""
+ "format": "prettier --write \"**/*.{js,tsx}\" --ignore-path .gitignore",
+ "check-format": "prettier --list-different \"**/*.{js,tsx}\" --ignore-path .gitignore"
},
"browserslist": [
"defaults",
@@ -92,5 +92,13 @@
"prettier": {
"arrowParens": "avoid",
"trailingComma": "none"
+ },
+ "eslintConfig": {
+ "root": true,
+ "extends": ["react-app"],
+ "rules": {
+ "react/display-name": "off",
+ "react/prop-types": "off"
+ }
}
}
diff --git a/src/components/common/__tests__/Header.test.tsx b/src/components/common/__tests__/Header.test.tsx
index b6cf852..c5d7c57 100644
--- a/src/components/common/__tests__/Header.test.tsx
+++ b/src/components/common/__tests__/Header.test.tsx
@@ -8,7 +8,7 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
-import React, { MouseEvent } from "react";
+import React from "react";
import api from "../../../util/api";
import { shallow } from "enzyme";
import Header from "../Header";
@@ -16,7 +16,7 @@ import { TimeRangeSelectorContainer } from "../../dashboard/TimeRangeSelector";
it("shows the time range selector on the dashboard", () => {
api.loggedIn = true;
- history.pushState({}, "", "/dashboard");
+ window.history.pushState({}, "", "/dashboard");
const wrapper = shallow();
@@ -25,7 +25,7 @@ it("shows the time range selector on the dashboard", () => {
it("does not show the time range selector when not logged in", () => {
api.loggedIn = false;
- history.pushState({}, "", "/dashboard");
+ window.history.pushState({}, "", "/dashboard");
const wrapper = shallow();
@@ -34,7 +34,7 @@ it("does not show the time range selector when not logged in", () => {
it("does not show the time range selector on non-dashboard pages", () => {
api.loggedIn = true;
- history.pushState({}, "", "/whitelist");
+ window.history.pushState({}, "", "/whitelist");
const wrapper = shallow();
diff --git a/src/components/dashboard/ClientsGraph.tsx b/src/components/dashboard/ClientsGraph.tsx
index 441917e..30320a3 100644
--- a/src/components/dashboard/ClientsGraph.tsx
+++ b/src/components/dashboard/ClientsGraph.tsx
@@ -207,7 +207,7 @@ export const transformData = (
// Fill in data & labels
for (let step of overTime) {
for (let destination in datasets) {
- if (datasets.hasOwnProperty(destination))
+ if (Object.prototype.hasOwnProperty.call(datasets, destination))
(datasets[destination].data as Array).push(
step.data[destination]
);
diff --git a/src/components/dashboard/__tests__/TopBlockedClients.test.tsx b/src/components/dashboard/__tests__/TopBlockedClients.test.tsx
index 2b0e178..477918a 100644
--- a/src/components/dashboard/__tests__/TopBlockedClients.test.tsx
+++ b/src/components/dashboard/__tests__/TopBlockedClients.test.tsx
@@ -8,7 +8,6 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
-import React from "react";
import { generateRows, transformData } from "../TopBlockedClients";
const fakeData: ApiTopBlockedClients = {
diff --git a/src/components/dashboard/__tests__/TopBlockedDomains.test.tsx b/src/components/dashboard/__tests__/TopBlockedDomains.test.tsx
index 63012cd..8e5ed1e 100644
--- a/src/components/dashboard/__tests__/TopBlockedDomains.test.tsx
+++ b/src/components/dashboard/__tests__/TopBlockedDomains.test.tsx
@@ -8,7 +8,6 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
-import React from "react";
import { generateRows, transformData } from "../TopBlockedDomains";
const fakeData: ApiTopBlockedDomains = {
diff --git a/src/components/dashboard/__tests__/TopClients.test.tsx b/src/components/dashboard/__tests__/TopClients.test.tsx
index 972c83d..41fa50a 100644
--- a/src/components/dashboard/__tests__/TopClients.test.tsx
+++ b/src/components/dashboard/__tests__/TopClients.test.tsx
@@ -8,7 +8,6 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
-import React from "react";
import { generateRows, transformData } from "../TopClients";
const fakeData: ApiTopClients = {
diff --git a/src/components/dashboard/__tests__/TopDomains.test.tsx b/src/components/dashboard/__tests__/TopDomains.test.tsx
index eaf203c..7892db3 100644
--- a/src/components/dashboard/__tests__/TopDomains.test.tsx
+++ b/src/components/dashboard/__tests__/TopDomains.test.tsx
@@ -8,7 +8,6 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
-import React from "react";
import { generateRows, transformData } from "../TopDomains";
const fakeData: ApiTopDomains = {
diff --git a/src/components/settings/DnsOptionSettings.tsx b/src/components/settings/DnsOptionSettings.tsx
index 0b13fc0..688cf4b 100644
--- a/src/components/settings/DnsOptionSettings.tsx
+++ b/src/components/settings/DnsOptionSettings.tsx
@@ -9,7 +9,6 @@
* Please see LICENSE file for your rights under this license. */
import React, { Fragment } from "react";
-import PropTypes from "prop-types";
import { Col, FormGroup, Input, Label } from "reactstrap";
import { TFunction } from "i18next";
@@ -86,10 +85,4 @@ const DnsOptionSettings = ({
);
-DnsOptionSettings.propTypes = {
- settings: PropTypes.object.isRequired,
- onUpdate: PropTypes.func.isRequired,
- t: PropTypes.func.isRequired
-};
-
export default DnsOptionSettings;
diff --git a/src/types/global.d.ts b/src/types/global.d.ts
index f63b95c..0fdd34a 100644
--- a/src/types/global.d.ts
+++ b/src/types/global.d.ts
@@ -8,6 +8,7 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
namespace NodeJS {
import i18next from "i18next";
diff --git a/src/views/Login.tsx b/src/views/Login.tsx
index 6f01812..e460380 100644
--- a/src/views/Login.tsx
+++ b/src/views/Login.tsx
@@ -37,7 +37,7 @@ class Login extends Component {
cookiesEnabled: false
};
- componentWillMount() {
+ componentDidMount() {
// Check if cookies are enabled
if (navigator.cookieEnabled) this.setState({ cookiesEnabled: true });
}
diff --git a/src/views/Logout.tsx b/src/views/Logout.tsx
index ff1a84b..0f543ea 100644
--- a/src/views/Logout.tsx
+++ b/src/views/Logout.tsx
@@ -14,7 +14,7 @@ import api from "../util/api";
import config from "../config";
export default class Logout extends Component {
- componentWillMount() {
+ componentDidMount() {
api.loggedIn = false;
if (config.fakeAPI) {