Skip to content

Commit

Permalink
ESLint: enable @typescript-eslint/no-useless-constructor
Browse files Browse the repository at this point in the history
Remove constructors that just call
super() wtih their arguments and
enable @typescript-eslint/no-useless-constructor.
  • Loading branch information
pjonsson committed Oct 1, 2024
1 parent 803e50d commit d8a5e28
Show file tree
Hide file tree
Showing 16 changed files with 4 additions and 76 deletions.
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
/* ban-types is split in ESLint v8:
https://typescript-eslint.io/rules/ban-types/ */
"@typescript-eslint/ban-types": "error",
/* The no-useless-constructor needs to be disabled for
the @typescript-eslint-rule. */
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/unified-signatures": "error",
"react-hooks/exhaustive-deps": "error",
"react/jsx-boolean-value": ["error", "never", { "always": [] }],
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
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
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
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
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
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

0 comments on commit d8a5e28

Please sign in to comment.