Skip to content

Commit

Permalink
House cleaning (#4021)
Browse files Browse the repository at this point in the history
* Fix formatting

* Remove unused imports

* Remove unused assignments

* Fix linter ignore

This was ignored before already, but it didn’t apply because the comment wasn’t actually placed on the preceding line. It would be better to fix this properly, but that’s not possible without backend changes.

* Use strict type comparisons

* Fix typo (Ctl/Ctrl)

I think `Ctl` is occasionally used as well, but `Ctrl` is much more common and what you’ll find on most keyboards

* Use strict comparisons in table editor

* Use `forEach` instead of `map`

This caused a linter warning. `map` is only used here to iterate over the arrays, so `forEach` is the proper replacement.

* Remove unused files

These are leftovers from the time when react-ftm was a separate package

* Remove useless constructors

* Remove unused network diagram layout helper

The code in this file has been commented out for a long time, the file isn’t imported anywhere else, so I assume it’s safe to remove.

* Configure ESLint to fail if there are warnings

Now that all linter warnings are resolved, let’s make sure we don’t introduce any new ones.
  • Loading branch information
tillprochaska authored Dec 2, 2024
1 parent 1276d40 commit e0fa3f6
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 94 deletions.
10 changes: 2 additions & 8 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"scripts": {
"start": "craco start",
"build": "craco build",
"lint": "eslint --ext js,jsx,ts,tsx src",
"lint": "eslint --ext js,jsx,ts,tsx src --max-warnings 0",
"test": "craco test",
"eject": "craco eject",
"format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,css,scss}'",
Expand All @@ -72,13 +72,7 @@
},
"proxy": "http://api:5000/",
"eslintConfig": {
"extends": "react-app",
"rules": {
"no-console": "error",
"no-debugger": "error",
"react/no-unknown-property": "error",
"react/jsx-key": "error"
}
"extends": "react-app"
},
"jest": {
"transformIgnorePatterns": []
Expand Down
5 changes: 4 additions & 1 deletion ui/src/actions/entitySetActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export const createEntitySetNoMutate = asyncActionCreator(createEntitySet, {

export const updateEntitySet = asyncActionCreator(
(entitySetId, entitySet) => async () => {
const response = await endpoint.post(`entitysets/${entitySetId}`, entitySet);
const response = await endpoint.post(
`entitysets/${entitySetId}`,
entitySet
);
return { entitySetId, data: response.data };
},
{ name: 'UPDATE_ENTITYSET' }
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/Entity/EntityViews.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class EntityViews extends React.Component {
}

renderPdfSearchMode() {
const { entity, isPreview, activeMode } = this.props;
const { entity, isPreview } = this.props;

if (!this.hasPdfSearchMode()) {
return;
Expand All @@ -364,7 +364,7 @@ class EntityViews extends React.Component {
}

renderPdfSearchForm() {
const { location, isPreview, activeMode } = this.props;
const { location, isPreview } = this.props;

if (!this.hasPdfSearchMode()) {
return;
Expand Down
1 change: 0 additions & 1 deletion ui/src/components/common/BookmarksDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FC } from 'react';
import { FormattedMessage } from 'react-intl';
import { useSelector } from 'react-redux';
import { Classes, Drawer, DrawerSize } from '@blueprintjs/core';
import BookmarksList from './BookmarksList';

Expand Down
1 change: 0 additions & 1 deletion ui/src/react-ftm/__mocks__/fileMock.js

This file was deleted.

Empty file.
10 changes: 5 additions & 5 deletions ui/src/react-ftm/components/EntityTable/TableEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class TableEditorBase extends React.Component<
this.getHeaderCell(property)
);
const entityLinkPlaceholder =
visitEntity != undefined ? [this.getEntityLinkCell()] : [];
visitEntity !== undefined ? [this.getEntityLinkCell()] : [];

if (writeable) {
const addEntityCell = this.getAddEntityCell();
Expand Down Expand Up @@ -288,7 +288,7 @@ class TableEditorBase extends React.Component<
});

const entityLinkCell =
visitEntity != undefined ? [this.getEntityLinkCell(entity)] : [];
visitEntity !== undefined ? [this.getEntityLinkCell(entity)] : [];

if (!writeable) {
return [...entityLinkCell, ...propCells];
Expand Down Expand Up @@ -335,7 +335,7 @@ class TableEditorBase extends React.Component<

const skeletonRowCount = 8;
const entityLinkPlaceholder =
visitEntity != undefined ? [this.getEntityLinkCell()] : [];
visitEntity !== undefined ? [this.getEntityLinkCell()] : [];
const actionCellPlaceholder = writeable
? [{ ...getCellBase('checkbox') }]
: [];
Expand All @@ -356,7 +356,7 @@ class TableEditorBase extends React.Component<
const { visibleProps } = this.state;

const entityLinkPlaceholder =
visitEntity != undefined ? [this.getEntityLinkCell()] : [];
visitEntity !== undefined ? [this.getEntityLinkCell()] : [];

const addRowCells = visibleProps.map((property) => ({
...getCellBase('property'),
Expand Down Expand Up @@ -591,7 +591,7 @@ class TableEditorBase extends React.Component<

renderEntityLinkButton = ({ entity }: { entity: FTMEntity }) => {
const { visitEntity } = this.props;
if (visitEntity == undefined) return null;
if (visitEntity === undefined) return null;

return (
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ const getForceData = ({
let groupingLinks: Array<any> = [];
groupings.forEach((grouping) => {
const gVerts = grouping.getVertexIds();
gVerts.map((v1) => {
gVerts.map((v2) => {
gVerts.forEach((v1) => {
gVerts.forEach((v2) => {
groupingLinks.push({
source: nodes.find((n) => n.id === v1),
target: nodes.find((n) => n.id === v2),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ interface IToolbarButtonGroupProps {
}

export class ToolbarButtonGroup extends React.PureComponent<IToolbarButtonGroupProps> {
constructor(props: Readonly<IToolbarButtonGroupProps>) {
super(props);
}

renderVisible(items: any) {
const { editorTheme } = this.props;

Expand Down
4 changes: 0 additions & 4 deletions ui/src/react-ftm/editors/EdgeTypeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ interface IEdgeTypeSelectProps {
}

class EdgeTypeSelect extends React.PureComponent<IEdgeTypeSelectProps> {
constructor(props: any) {
super(props);
}

getEdgeTypeIcon(type?: EdgeType) {
if (type?.schema) {
return <Schema.Icon schema={type.schema} />;
Expand Down
3 changes: 2 additions & 1 deletion ui/src/react-ftm/types/Transliterate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class Transliterate extends React.PureComponent<ITransliterateProps> {
if (!lookup || !lookup[value]) {
return truncate ? truncateText(value, truncate) : value;
}
const symbol = navigator.userAgent.indexOf('Mac OS X') != -1 ? '⌘' : 'Ctl';
const symbol =
navigator.userAgent.indexOf('Mac OS X') !== -1 ? '⌘' : 'Ctrl';

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/screens/GroupScreen/GroupScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export class GroupScreen extends Component {
id="group.page.search.description"
defaultMessage="If you would like to search for specific entities or documents within the datasets that this group has access to, <link>click here</link> instead."
values={{
// eslint-disable-next-line
link: (chunks) => (
// eslint-disable-next-line
<a role="button" onClick={this.goToEntitySearch}>
{chunks}
</a>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/screens/OAuthScreen/OAuthScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FormattedMessage } from 'react-intl';
import { loginWithToken } from 'actions/sessionActions';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { Dialog, DialogBody, AnchorButton, Intent } from '@blueprintjs/core';
import { Dialog, DialogBody } from '@blueprintjs/core';
import { RoleBlockedMessage } from 'components/common';

import withRouter from 'app/withRouter';
Expand Down
22 changes: 2 additions & 20 deletions ui/src/viewers/PdfViewer.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { defineMessages, injectIntl } from 'react-intl';
import { injectIntl } from 'react-intl';
import { throttle } from 'lodash';
import queryString from 'query-string';
import { compose } from 'redux';
Expand All @@ -12,19 +12,11 @@ import { SectionLoading, Skeleton } from 'components/common';
import { queryEntities } from 'actions';
import { selectEntitiesResult } from 'selectors';
import normalizeDegreeValue from 'util/normalizeDegreeValue';
import EntityActionBar from 'components/Entity/EntityActionBar';
import PdfViewerPage from 'viewers/PdfViewerPage';

import './PdfViewer.scss';
import 'react-pdf/dist/esm/Page/TextLayer.css';

const messages = defineMessages({
placeholder: {
id: 'entity.viewer.search_placeholder',
defaultMessage: 'Search in {label}',
},
});

export class PdfViewer extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -220,17 +212,7 @@ export class PdfViewer extends Component {
}

render() {
const {
document,
dir,
activeMode,
pageQuery,
searchQuery,
intl,
page,
numPages,
shouldRenderSearch,
} = this.props;
const { document, dir, activeMode, pageQuery, page, numPages } = this.props;

if (document.isPending || numPages === undefined || numPages === null) {
return <SectionLoading />;
Expand Down
4 changes: 1 addition & 3 deletions ui/src/viewers/PdfViewerSearch.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { FormattedMessage } from 'react-intl';
import classNames from 'classnames';
import { compose } from 'redux';
import { connect } from 'react-redux';
import queryString from 'query-string';
Expand Down Expand Up @@ -38,7 +36,7 @@ class PdfViewerSearch extends Component {
}

getResultLink(result) {
const { query, document, location, isPreview } = this.props;
const { query, location, isPreview } = this.props;
const parsedHash = queryString.parse(location.hash);

if (isPreview) {
Expand Down

0 comments on commit e0fa3f6

Please sign in to comment.