diff --git a/src/client/app/actions/barReadings.ts b/src/client/app/actions/barReadings.ts index 9d2e8517e..a8fa5fc1c 100644 --- a/src/client/app/actions/barReadings.ts +++ b/src/client/app/actions/barReadings.ts @@ -120,9 +120,7 @@ function fetchGroupBarReadings(groupIDs: number[], timeInterval: TimeInterval): export function fetchNeededBarReadings(timeInterval: TimeInterval): Thunk { return (dispatch: Dispatch, getState: GetState) => { const state = getState(); - /* tslint:disable:array-type */ const promises: Array> = []; - /* tslint:enable:array-type */ // Determine which meters are missing data for this time interval const meterIDsToFetchForBar = state.graph.selectedMeters.filter( diff --git a/src/client/app/actions/compareReadings.ts b/src/client/app/actions/compareReadings.ts index 701a51458..221184e52 100644 --- a/src/client/app/actions/compareReadings.ts +++ b/src/client/app/actions/compareReadings.ts @@ -118,9 +118,7 @@ export function fetchNeededCompareReadings(comparePeriod: ComparePeriod): Thunk const state = getState(); const compareShift = calculateCompareShift(comparePeriod); const timeInterval = state.graph.compareTimeInterval; - /* tslint:disable:array-type */ const promises: Array> = []; - /* tslint:enable:array-type */ // Determine which meters are missing data for this time interval const meterIDsToFetchForCompare = state.graph.selectedMeters.filter( diff --git a/src/client/app/actions/graph.ts b/src/client/app/actions/graph.ts index 44147f2e3..ba162dfce 100644 --- a/src/client/app/actions/graph.ts +++ b/src/client/app/actions/graph.ts @@ -184,7 +184,6 @@ export interface LinkOptions { */ export function changeOptionsFromLink(options: LinkOptions) { const dispatchFirst: Thunk[] = [setHotlinkedAsync(true)]; - /* tslint:disable:array-type */ const dispatchSecond: Array = []; diff --git a/src/client/app/actions/lineReadings.ts b/src/client/app/actions/lineReadings.ts index 88c903cd3..3a9b234b8 100644 --- a/src/client/app/actions/lineReadings.ts +++ b/src/client/app/actions/lineReadings.ts @@ -86,9 +86,7 @@ function fetchGroupLineReadings(groupIDs: number[], timeInterval: TimeInterval): export function fetchNeededLineReadings(timeInterval: TimeInterval): Thunk { return (dispatch: Dispatch, getState: GetState) => { const state = getState(); - /* tslint:disable:array-type */ const promises: Array> = []; - /* tslint:enable:array-type */ // Determine which meters are missing data for this time interval const meterIDsToFetchForLine = state.graph.selectedMeters.filter( diff --git a/src/client/app/actions/map.ts b/src/client/app/actions/map.ts index 9fe9e5785..b1dd12ff1 100644 --- a/src/client/app/actions/map.ts +++ b/src/client/app/actions/map.ts @@ -168,8 +168,10 @@ function updateCalibrationSet(calibratedPoint: CalibratedPoint): t.AppendCalibra */ function isReadyForCalculation(state: State): boolean { const calibrationThreshold = 3; - // @ts-ignore - return state.maps.editedMaps[state.maps.calibratingMap].calibrationSet.length >= calibrationThreshold; + // assume calibrationSet is defined, as offerCurrentGPS indicates through point that the map is defined. + /* eslint-disable @typescript-eslint/no-non-null-assertion */ + return state.maps.editedMaps[state.maps.calibratingMap].calibrationSet!.length >= calibrationThreshold; + /* eslint-enable @typescript-eslint/no-non-null-assertion */ } /** @@ -182,9 +184,11 @@ function prepareDataToCalculation(state: State): CalibrationResult { width: mp.image.width, height: mp.image.height }; - // @ts-ignore - const result = calibrate(mp.calibrationSet, imageDimensions, mp.northAngle); + // Since mp is defined above, calibrationSet is defined. + /* eslint-disable @typescript-eslint/no-non-null-assertion */ + const result = calibrate(mp.calibrationSet!, imageDimensions, mp.northAngle); return result; + /* eslint-enable @typescript-eslint/no-non-null-assertion */ } function updateResult(result: CalibrationResult): t.UpdateCalibrationResultAction { diff --git a/src/client/app/components/MultiSelectComponent.tsx b/src/client/app/components/MultiSelectComponent.tsx index 1c0768f2e..c90d6f3ae 100644 --- a/src/client/app/components/MultiSelectComponent.tsx +++ b/src/client/app/components/MultiSelectComponent.tsx @@ -8,12 +8,10 @@ import { SelectOption } from '../types/items'; interface MultiSelectProps { placeholder: string; - /* tslint:disable:array-type */ options: Array; selectedOptions: Array | undefined; singleSelect?: boolean; onValuesChange(values: Array): void; - /* tslint:enable:array-type */ } interface MultiSelectState { @@ -50,9 +48,7 @@ export default class MultiSelectComponent extends React.Component) { - /* tslint:enable:array-type */ // Defer to the underlying MultiSelect when it has a state change // Note that the MSC state selectedOptions is in fact the canonical source of truth this.setState({ selectedOptions: items }); diff --git a/src/client/app/components/groups/DatasourceBoxComponent.tsx b/src/client/app/components/groups/DatasourceBoxComponent.tsx index c7c229de3..93c1d107f 100644 --- a/src/client/app/components/groups/DatasourceBoxComponent.tsx +++ b/src/client/app/components/groups/DatasourceBoxComponent.tsx @@ -21,7 +21,6 @@ type DatasourceBoxPropsWithIntl = DatasourceBoxProps & WrappedComponentProps; // This is just an alias, so it's ok to have it in this file. // Aliasing this specialization is required because the meaning of < and > conflict in TypeScript and JSX. -// tslint:disable max-classes-per-file class MultiSelectDatasourceComponent extends MultiSelectComponent { } class DatasourceBoxComponent extends React.Component { @@ -36,18 +35,14 @@ class DatasourceBoxComponent extends React.Component type = DataType.Meter; } - /* tslint:disable:array-type */ const options: Array = this.props.datasource.map((element: NamedIDItem) => ( - /* tslint:enable:array-type */ { label: element.name, type, value: element.id } )); - /* tslint:disable:array-type */ let selectedOptions: Array | undefined; - /* tslint:enable:array-type */ if (this.props.selectedOptions) { selectedOptions = this.props.selectedOptions.map((element: NamedIDItem) => ( { diff --git a/src/client/app/components/groups/GroupSidebarComponent.tsx b/src/client/app/components/groups/GroupSidebarComponent.tsx index 099236884..80f9646f5 100644 --- a/src/client/app/components/groups/GroupSidebarComponent.tsx +++ b/src/client/app/components/groups/GroupSidebarComponent.tsx @@ -9,10 +9,8 @@ import { ChangeDisplayedGroupsAction } from '../../types/redux/groups'; import { Link } from 'react-router-dom'; interface GroupSidebarProps { - /* tslint:disable:array-type */ groups: Array<{ id: number, name: string }>; loggedInAsAdmin: boolean; - /* tslint:enable:array-type */ selectGroups(groups: number[]): ChangeDisplayedGroupsAction; } @@ -58,7 +56,7 @@ export default class GroupSidebarComponent extends React.Component { - // @ts-ignore - resolve(fileReader.result); + if (typeof fileReader.result === 'string') { + resolve(fileReader.result); + } }; fileReader.onerror = reject; fileReader.readAsDataURL(file); diff --git a/src/client/app/containers/ExportContainer.ts b/src/client/app/containers/ExportContainer.ts index 45d1cdd5e..52c7825a6 100644 --- a/src/client/app/containers/ExportContainer.ts +++ b/src/client/app/containers/ExportContainer.ts @@ -40,12 +40,10 @@ function mapStateToProps(state: State) { throw new Error('Unacceptable condition: readingsData.readings is undefined.'); } - /* tslint:disable:array-type */ const dataPoints: Array<{ x: number, y: number, z: number }> = _.values(readingsData.readings) .map(transformLineReadingToLegacy) .map((v: [number, number, number]) => ({ x: v[0], y: v[1], z: v[2] }) ); - /* tslint:enable:array-type */ datasets.push({ label, id: state.groups.byGroupID[groupID].id, @@ -65,13 +63,11 @@ function mapStateToProps(state: State) { throw new Error('Unacceptable condition: readingsData.readings is undefined.'); } - /* tslint:disable:array-type */ const dataPoints: Array<{ x: number, y: number, z: number }> = _.values(readingsData.readings) .map(transformLineReadingToLegacy) .map( (v: [number, number, number]) => ({ x: v[0], y: v[1], z: v[2] }) ); - /* tslint:enable:array-type */ datasets.push({ label, id: state.meters.byMeterID[meterID].id, @@ -94,12 +90,10 @@ function mapStateToProps(state: State) { throw new Error('Unacceptable condition: readingsData.readings is undefined.'); } - /* tslint:disable:array-type */ const dataPoints: Array<{ x: number, y: number, z: number }> = _.values(readingsData.readings) .map(transformBarReadingToLegacy) .map((v: [number, number, number]) => ({ x: v[0], y: v[1], z: v[2] }) ); - /* tslint:enable:array-type */ datasets.push({ label, id: state.groups.byGroupID[groupID].id, @@ -122,12 +116,10 @@ function mapStateToProps(state: State) { throw new Error('Unacceptable condition: readingsData.readings is undefined.'); } - /* tslint:disable:array-type */ const dataPoints: Array<{ x: number, y: number, z: number }> = _.values(readingsData.readings) .map(transformBarReadingToLegacy) .map((v: [number, number, number]) => ({ x: v[0], y: v[1], z: v[2] }) ); - /* tslint:enable:array-type */ datasets.push({ label, id: state.meters.byMeterID[meterID].id, diff --git a/src/client/app/containers/LineChartContainer.ts b/src/client/app/containers/LineChartContainer.ts index d22466bd6..ed898aaa8 100644 --- a/src/client/app/containers/LineChartContainer.ts +++ b/src/client/app/containers/LineChartContainer.ts @@ -46,10 +46,8 @@ function mapStateToProps(state: State) { let minTimestamp: string = ''; let maxTimestamp: string = ''; if (readings.length > 0) { - /* tslint:disable:no-string-literal */ minTimestamp = readings[0]['startTimestamp'].toString(); maxTimestamp = readings[readings.length - 1]['startTimestamp'].toString(); - /* tslint:enable:no-string-literal */ } const root: any = document.getElementById('root'); root.setAttribute('min-timestamp', minTimestamp); diff --git a/src/client/app/containers/MultiCompareChartContainer.ts b/src/client/app/containers/MultiCompareChartContainer.ts index dcaeee521..a45de7bbc 100644 --- a/src/client/app/containers/MultiCompareChartContainer.ts +++ b/src/client/app/containers/MultiCompareChartContainer.ts @@ -50,11 +50,13 @@ function getDataForIDs(ids: number[], isGroup: boolean, state: State): CompareEn readingsData = getMeterReadingsData(state, id, timeInterval, compareShift); } if (isReadingsDataValid(readingsData)) { + /* eslint-disable @typescript-eslint/no-non-null-assertion */ const currUsage = readingsData!.curr_use!; const prevUsage = readingsData!.prev_use!; const change = calculateChange(currUsage, prevUsage); const entity: CompareEntity = {id, isGroup, name, change, currUsage, prevUsage}; entities.push(entity); + /* eslint-enable @typescript-eslint/no-non-null-assertion */ } } return entities; diff --git a/src/client/app/containers/maps/MapCalibrationChartDisplayContainer.ts b/src/client/app/containers/maps/MapCalibrationChartDisplayContainer.ts index 1ced99e2f..de58e0728 100644 --- a/src/client/app/containers/maps/MapCalibrationChartDisplayContainer.ts +++ b/src/client/app/containers/maps/MapCalibrationChartDisplayContainer.ts @@ -106,8 +106,8 @@ function mapStateToProps(state: State) { */ function createBackgroundTrace(imageDimensions: Dimensions, settings: CalibrationSettings) { // define the grid of heatmap - const x = []; - const y = []; + const x: number[] = []; + const y: number[] = []; // bound the grid to image dimensions to avoid clicking outside of the map for (let i = 0; i <= Math.ceil(imageDimensions.width); i = i + 1) { x.push(i); @@ -116,10 +116,10 @@ function createBackgroundTrace(imageDimensions: Dimensions, settings: Calibratio y.push(j); } // define the actual points of the graph, numbers in the array are used to designate different colors; - const z = []; - for (const {} of y) { + const z: number[][] = []; + for (let ind1 = 0; ind1 < y.length; ++ind1) { const temp = []; - for (const {} of x) { + for (let ind2 = 0; ind2 < x.length; ++ind2) { temp.push(0); } z.push(temp); diff --git a/src/client/app/index.tsx b/src/client/app/index.tsx index 1ed62dd7c..8b05ca7cd 100644 --- a/src/client/app/index.tsx +++ b/src/client/app/index.tsx @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react'; -import * as _ from 'lodash'; import thunkMiddleware from 'redux-thunk'; import { render } from 'react-dom'; import { createStore, applyMiddleware } from 'redux'; diff --git a/src/client/app/reducers/meters.ts b/src/client/app/reducers/meters.ts index bf8dee57c..57723fee4 100644 --- a/src/client/app/reducers/meters.ts +++ b/src/client/app/reducers/meters.ts @@ -48,7 +48,7 @@ export default function meters(state = defaultState, action: MetersAction) { ...state, submitting }; - case ActionType.ConfirmEditedMeter: + case ActionType.ConfirmEditedMeter: { submitting = state.submitting; submitting.splice(submitting.indexOf(action.meter)); @@ -63,6 +63,7 @@ export default function meters(state = defaultState, action: MetersAction) { editedMeters, byMeterID }; + } default: return state; } diff --git a/src/client/app/types/readings.ts b/src/client/app/types/readings.ts index 064d7243c..2b9a21fed 100644 --- a/src/client/app/types/readings.ts +++ b/src/client/app/types/readings.ts @@ -17,9 +17,7 @@ export interface LineReadings { * The type of bar readings in actions. */ export interface BarReadings { - /* tslint:disable:array-type */ [id: number]: Array<[number, number]>; - /* tslint:enable:array-type */ } export interface CompareReading { @@ -35,9 +33,7 @@ export interface ExportDataSet { label: string; id: number; currentChart: ChartTypes; - /* tslint:disable:array-type */ exportVals: Array<{ x: number, y: number, z: number }>; - /* tslint:enable:array-type */ } export interface RawReadings { diff --git a/src/client/app/utils/exportData.ts b/src/client/app/utils/exportData.ts index 14333b22a..b10e912ae 100644 --- a/src/client/app/utils/exportData.ts +++ b/src/client/app/utils/exportData.ts @@ -62,6 +62,8 @@ export default function graphExport(dataSets: ExportDataSet[], name: string) { * @param items list of readings directly from the database * @param defaultLanguage the preferred localization to use for date/time formatting */ +// below comment should be removed when we either remove defaultLanguage or implement it into the following function +/* eslint-disable @typescript-eslint/no-unused-vars */ export function downloadRawCSV(items: RawReadings[], defaultLanguage: string) { // note that utc() is not needed let csvOutput = 'Label,Readings,Start Timestamp,End Timestamp\n'; @@ -76,6 +78,8 @@ export function downloadRawCSV(items: RawReadings[], defaultLanguage: string) { const filename = `oedRawExport_line_${startTime}_to_${endTime}.csv`; downloadCSV(csvOutput, filename); } +/* eslint-enable @typescript-eslint/no-unused-vars */ +// as well as above comment /** * Function that adds a div to handle exporting raw data diff --git a/tslint.json b/tslint.json deleted file mode 100644 index af34ca630..000000000 --- a/tslint.json +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -{ - "defaultSeverity": "error", - "extends": [ - "tslint:recommended", - "tslint-react" - ], - // Rules for JavaScript code. - "jsRules": { - // We have to indent with tabs - "indent": [true, "tabs"], - // No lines longer than 150 are allowed - "max-line-length": [true, 150], - // In general, strings should be clean and single-quoted, with no templates where they aren't needed - "quotemark": [true, "single", "avoid-escape", "avoid-template"], - // No trailing commas allowed anywhere - "trailing-comma": [true, {"multiline": "never", "singleline": "never"}], - // Sometimes we want to seperate sections with multiple blank lines - "no-consecutive-blank-lines": [false], - // Arrow function style: arg => value or (arg1, arg2) => value - "arrow-parens": [true, "ban-single-arg-parens"], - // No need to put keys in alphabetical order - "object-literal-sort-keys": false, - // It's useless to specify radices in most cases - "radix": false, - // The order of imports is annoying and not useful - "ordered-imports": false - }, - "rules": { - // We have to indent with tabs - "indent": [true, "tabs"], - // No lines longer than 150 are allowed - "max-line-length": [true, 150], - // In general, strings should be clean and single-quoted, with no templates where they aren't needed - "quotemark": [true, "single", "avoid-escape", "avoid-template"], - // No trailing commas allowed anywhere - "trailing-comma": [true, {"multiline": "never", "singleline": "never"}], - // Sometimes we want to seperate sections with multiple blank lines - "no-consecutive-blank-lines": [false], - // Arrow function style: arg => value or (arg1, arg2) => value - "arrow-parens": [true, "ban-single-arg-parens"], - // No need to put keys in alphabetical order - "object-literal-sort-keys": false, - // It's useless to specify radices in most cases - "radix": false, - // The order of imports is annoying and not useful - "ordered-imports": false, - // Interfaces don't need to start with the letter I. - "interface-name": false, - // This rule is buggy. - "jsx-wrap-multiline": false, - // We shouldn't need to be explicit about the value of a true boolean option - "jsx-boolean-value": [true, "never"], - // Long JavaScript (and TypeScript) code should be allowed in JSX/TSX XML - "jsx-no-multiline-js": false, - // We don't have issue with performance here - "jsx-no-lambda": false - }, - "rulesDirectory": [] -} \ No newline at end of file