Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable some more @typescript-eslint rules #7287

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
}
},
"rules": {
/* ban-types is split in ESLint v8:
https://typescript-eslint.io/rules/ban-types/ */
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/unified-signatures": "error",
"react-hooks/exhaustive-deps": "error",
"react/jsx-boolean-value": ["error", "never", { "always": [] }],
"react/no-arrow-function-lifecycle": "error",
Expand Down Expand Up @@ -113,6 +117,10 @@
{
"files": ["**/*.ts", "**/*.tsx"],
"rules": {
/* The no-useless-constructor needs to be disabled for
the @typescript-eslint-rule. */
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "error",
// @TODO: revise these rules
"@typescript-eslint/consistent-type-assertions": "error",
"no-unused-vars": "off",
Expand Down
12 changes: 0 additions & 12 deletions lib/Models/Catalog/CatalogReferences/ThreddsItemReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ import { runInAction } from "mobx";
import ReferenceMixin from "../../../ModelMixins/ReferenceMixin";
import UrlMixin from "../../../ModelMixins/UrlMixin";
import ThreddsItemReferenceTraits from "../../../Traits/TraitsClasses/ThreddsItemReferenceTraits";
import ModelTraits from "../../../Traits/ModelTraits";
import ThreddsCatalogGroup, {
ThreddsDataset
} from "../CatalogGroups/ThreddsCatalogGroup";
import CatalogMemberFactory from "../CatalogMemberFactory";
import CreateModel from "../../Definition/CreateModel";
import LoadableStratum from "../../Definition/LoadableStratum";
import { BaseModel } from "../../Definition/Model";
import StratumFromTraits from "../../Definition/StratumFromTraits";
import StratumOrder from "../../Definition/StratumOrder";
import Terria from "../../Terria";
import WebMapServiceCatalogGroup from "../Ows/WebMapServiceCatalogGroup";

export class ThreddsDatasetStratum extends LoadableStratum(
Expand Down Expand Up @@ -71,15 +68,6 @@ export default class ThreddsItemReference extends UrlMixin(
_threddsDataset: ThreddsDataset | undefined = undefined;
_threddsCatalogGroup: ThreddsCatalogGroup | undefined = undefined;

constructor(
id: string | undefined,
terria: Terria,
sourceReference?: BaseModel,
strata?: Map<string, StratumFromTraits<ModelTraits>>
) {
super(id, terria, sourceReference, strata);
}

setDataset(dataset: ThreddsDataset) {
this._threddsDataset = dataset;
}
Expand Down
11 changes: 0 additions & 11 deletions lib/Models/Catalog/CatalogReferences/UrlReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import UrlMixin from "../../../ModelMixins/UrlMixin";
import CatalogMemberFactory from "../CatalogMemberFactory";
import CreateModel from "../../Definition/CreateModel";
import { BaseModel } from "../../Definition/Model";
import StratumFromTraits from "../../Definition/StratumFromTraits";
import Terria from "../../Terria";
import ModelTraits from "../../../Traits/ModelTraits";
import UrlReferenceTraits from "../../../Traits/TraitsClasses/UrlReferenceTraits";
import StratumOrder from "../../Definition/StratumOrder";
import CatalogMemberMixin from "../../../ModelMixins/CatalogMemberMixin";
Expand All @@ -23,15 +21,6 @@ export default class UrlReference extends UrlMixin(
return UrlReference.type;
}

constructor(
id: string | undefined,
terria: Terria,
sourceReference?: BaseModel,
strata?: Map<string, StratumFromTraits<ModelTraits>>
) {
super(id, terria, sourceReference, strata);
}

protected forceLoadReference(
_previousTarget: BaseModel | undefined
): Promise<BaseModel | undefined> {
Expand Down
4 changes: 0 additions & 4 deletions lib/Models/Catalog/Gtfs/GtfsRealtimeProtoBufReaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export class FeedMessageReader extends ProtobufMessageReader<FeedMessage> {
entity: []
};

constructor() {
super();
}

protected readField(tag: number, obj?: FeedMessage, pbf?: Pbf): void {
if (pbf === null || pbf === undefined) {
return;
Expand Down
9 changes: 3 additions & 6 deletions lib/Models/Definition/addModelStrataView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ import ModelPropertiesFromTraits from "./ModelPropertiesFromTraits";
export default function addModelStrataView<
T extends TraitsConstructor<ModelTraits>
>(
model: Stratified<InstanceType<T>>,
/* TODO: Use a more specific type than "Function". */
/* eslint-disable-next-line @typescript-eslint/ban-types */
model: Stratified<InstanceType<T>> | Function,
Traits: T
): ModelPropertiesFromTraits<InstanceType<T>>;
export default function addModelStrataView<
T extends TraitsConstructor<ModelTraits>
/* TODO: Fix this overload type */
/* eslint-disable-next-line @typescript-eslint/ban-types */
>(model: Function, Traits: T): ModelPropertiesFromTraits<InstanceType<T>>;
export default function addModelStrataView<
T extends TraitsConstructor<ModelTraits>
>(model: any, Traits: T): ModelPropertiesFromTraits<InstanceType<T>> {
Expand Down
2 changes: 1 addition & 1 deletion lib/ReactViews/Disclaimer.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";

declare class Disclaimer extends React.Component<{}> {}
declare class Disclaimer extends React.Component<object> {}

export default Disclaimer;
4 changes: 0 additions & 4 deletions lib/ReactViews/Disclaimer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ class Disclaimer extends React.Component {
t: PropTypes.func.isRequired
};

constructor(props) {
super(props);
}

confirm(confirmCallbackFn) {
if (confirmCallbackFn) {
confirmCallbackFn();
Expand Down
2 changes: 1 addition & 1 deletion lib/ReactViews/DragDropNotification.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";

declare class DragDropNotification extends React.Component<{}> {}
declare class DragDropNotification extends React.Component<object> {}

export default DragDropNotification;
4 changes: 0 additions & 4 deletions lib/ReactViews/Map/MapNavigation/Items/MapNavigationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ interface PropTypes {

@observer
class MapNavigationItemBase extends React.Component<PropTypes> {
constructor(props: PropTypes) {
super(props);
}

render() {
const { closeTool = true, item, expandInPlace, i18n } = this.props;
if (item.render)
Expand Down
4 changes: 0 additions & 4 deletions lib/ReactViews/Map/MapNavigation/Items/ZoomControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ export const ZOOM_CONTROL_ID = "zoom";
class ZoomControlBase extends React.Component<PropTypes> {
static displayName = "ZoomControl";

constructor(props: PropTypes) {
super(props);
}

flyToPosition(
scene: Scene,
position: Cartesian3,
Expand Down
2 changes: 1 addition & 1 deletion lib/ReactViews/Map/Panels/HelpPanel/HelpPanel.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";

declare class HelpPanel extends React.Component<{}> {}
declare class HelpPanel extends React.Component<object> {}
export default HelpPanel;
4 changes: 0 additions & 4 deletions lib/ReactViews/Map/Panels/HelpPanel/HelpPanelItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ class HelpPanelItem extends React.Component {
i18n: PropTypes.object.isRequired
};

constructor(props) {
super(props);
}

render() {
const { i18n } = this.props;

Expand Down
4 changes: 0 additions & 4 deletions lib/ReactViews/Map/Panels/HelpPanel/HelpVideoPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ class HelpVideoPanel extends React.Component {
i18n: PropTypes.object.isRequired
};

constructor(props) {
super(props);
}

render() {
const helpItemType = this.props.paneMode || "videoAndContent"; // default is video panel
const itemSelected =
Expand Down
4 changes: 0 additions & 4 deletions lib/ReactViews/Map/Panels/HelpPanel/StyledHtml.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ export class StyledHtmlRaw extends React.Component {
injectTooltips: true
};

constructor(props) {
super(props);
}

render() {
const { viewState, injectTooltips, i18n } = this.props;
const styledTextProps = this.props.styledTextProps || {};
Expand Down
4 changes: 0 additions & 4 deletions lib/ReactViews/Map/Panels/HelpPanel/TrainerPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ class TrainerPane extends React.Component {
i18n: PropTypes.object.isRequired
};

constructor(props) {
super(props);
}

render() {
const { content, i18n, viewState } = this.props;
const { trainerItems, markdownText } = content;
Expand Down
4 changes: 0 additions & 4 deletions lib/ReactViews/Map/Panels/HelpPanel/VideoGuide.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ class VideoGuide extends React.Component {
t: PropTypes.func
};

constructor(props) {
super(props);
}

render() {
const backgroundOpacity = this.props.backgroundOpacity;
const backgroundBlackOverlay =
Expand Down
2 changes: 1 addition & 1 deletion lib/ReactViews/Notification/terriaErrorNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const terriaErrorNotification = (error: TerriaError) =>
bodyBoxProps={{ padded: true }}
isOpen={error.showDetails}
onToggle={(show) => {
runInAction(() => (error.showDetails = show));
return runInAction(() => (error.showDetails = show));
}}
>
<ErrorsBox errors={detailedErrors} viewState={viewState} />
Expand Down
7 changes: 0 additions & 7 deletions lib/ReactViews/RelatedMaps/RelatedMaps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ type PropTypes = WithViewState &

@observer
class RelatedMaps extends React.Component<PropTypes> {
/**
* @param {Props} props
*/
constructor(props: PropTypes) {
super(props);
}

render() {
const t = this.props.t;
const dropdownTheme = {
Expand Down
6 changes: 4 additions & 2 deletions lib/ReactViews/SelectableDimensions/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ export const SelectableDimensionGroup: React.FC<{
onToggle={
dim.type === "group"
? dim.onToggle
: (isOpen) =>
: (isOpen) => {
dim.setDimensionValue(
CommonStrata.user,
isOpen ? "true" : "false"
)
);
return true;
}
}
btnStyle={dim.type === "checkbox-group" ? "checkbox" : undefined}
btnRight={dim.type === "group"}
Expand Down
2 changes: 1 addition & 1 deletion lib/ReactViews/Tour/TourPortal.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export declare const TourExplanation: React.FC<unknown>;
export declare const TourPreface: React.FC<unknown>;

declare const TourPortal: React.FC<{}>;
declare const TourPortal: React.FC<object>;

export default TourPortal;
2 changes: 1 addition & 1 deletion lib/ReactViews/WelcomeMessage/WelcomeMessage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ interface WelcomeMessagePurePropsType {

export declare const WelcomeMessagePure: React.FC<WelcomeMessagePurePropsType>;

declare class WelcomeMessage extends React.Component<{}> {}
declare class WelcomeMessage extends React.Component<object> {}
export default WelcomeMessage;
2 changes: 0 additions & 2 deletions lib/Table/createLongitudeLatitudeFeaturePerId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ class PreSampledPositionProperty {

private allValuesAreTheSame = true;

constructor() {}

getProperty() {
if (this.allValuesAreTheSame) {
return new ConstantPositionProperty(this.values[0]);
Expand Down
4 changes: 0 additions & 4 deletions lib/Traits/Decorators/anyTrait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export default function anyTrait(options: TraitOptions) {
export class AnyTrait extends Trait {
readonly decoratorForFlattened = computed.struct;

constructor(id: string, options: AnyTraitOptions, parent: any) {
super(id, options, parent);
}

getValue(model: BaseModel): any {
for (const stratum of model.strataTopToBottom.values()) {
const stratumAny: any = stratum;
Expand Down
4 changes: 0 additions & 4 deletions test/ModelMixins/SearchProviders/SearchProviderMixinSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ class TestSearchProvider extends SearchProviderMixin(
) {
type = "test";

constructor(uniqueId: string | undefined, terria: Terria) {
super(uniqueId, terria);
}

public override logEvent = jasmine.createSpy();
public override doSearch = jasmine
.createSpy()
Expand Down
Loading