diff --git a/src/client/applications/turnilo-application/turnilo-application.mocha.tsx b/src/client/applications/turnilo-application/turnilo-application.mocha.tsx index e2c7a8c95..8aa80f5d1 100644 --- a/src/client/applications/turnilo-application/turnilo-application.mocha.tsx +++ b/src/client/applications/turnilo-application/turnilo-application.mocha.tsx @@ -24,7 +24,7 @@ import { TurniloApplication } from "./turnilo-application"; describe.skip("TurniloApplication", () => { it("adds the correct class", () => { - var renderedComponent = renderIntoDocument( + const renderedComponent = renderIntoDocument( { it("adds the correct class", () => { - var renderedComponent = renderIntoDocument( + const renderedComponent = renderIntoDocument( ); } - for (let tick of ticks) { - let x = roundToHalfPx(scale(tick)); + for (const tick of ticks) { + const x = roundToHalfPx(scale(tick)); addLine(x, "_" + tick); } if (ticks.length) { - let x = roundToHalfPx(scale(ticks[ticks.length - 1]) + scale.bandwidth()); + const x = roundToHalfPx(scale(ticks[ticks.length - 1]) + scale.bandwidth()); addLine(x, "last"); } diff --git a/src/client/components/button-group/button-group.mocha.tsx b/src/client/components/button-group/button-group.mocha.tsx index 2e28c492d..3a732d30c 100644 --- a/src/client/components/button-group/button-group.mocha.tsx +++ b/src/client/components/button-group/button-group.mocha.tsx @@ -26,7 +26,7 @@ import { ButtonGroup } from "./button-group"; describe("ButtonGroup", () => { it("adds the correct class", () => { - var renderedComponent = renderIntoDocument( + const renderedComponent = renderIntoDocument( { it("adds the correct class", () => { - var renderedComponent = renderIntoDocument( + const renderedComponent = renderIntoDocument( ; diff --git a/src/client/components/svg-icon/svg-icon.mocha.tsx b/src/client/components/svg-icon/svg-icon.mocha.tsx index f5d76fe2a..917f7397e 100644 --- a/src/client/components/svg-icon/svg-icon.mocha.tsx +++ b/src/client/components/svg-icon/svg-icon.mocha.tsx @@ -28,7 +28,7 @@ describe("SvgIcon", () => { )).to.equal(``); - var svg = ` + const svg = ` diff --git a/src/client/components/svg-icon/svg-icon.tsx b/src/client/components/svg-icon/svg-icon.tsx index 7da6516cf..04f23262b 100644 --- a/src/client/components/svg-icon/svg-icon.tsx +++ b/src/client/components/svg-icon/svg-icon.tsx @@ -32,15 +32,15 @@ export interface SvgIconState { export class SvgIcon extends React.Component { render() { - var { className, style, svg } = this.props; + const { className, style, svg } = this.props; - var viewBox: string = null; - var svgInsides: string = null; + let viewBox: string = null; + let svgInsides: string = null; if (typeof svg === "string") { svgInsides = svg .substr(0, svg.length - 6) // remove trailing "" .replace(/^]+>\s*/i, (svgDec: string) => { - var vbMatch = svgDec.match(/viewBox="([\d ]+)"/); + const vbMatch = svgDec.match(/viewBox="([\d ]+)"/); if (vbMatch) viewBox = vbMatch[1]; return ""; }); diff --git a/src/client/components/tile-header/tile-header.mocha.tsx b/src/client/components/tile-header/tile-header.mocha.tsx index 0aef03a4e..d3fcabdad 100644 --- a/src/client/components/tile-header/tile-header.mocha.tsx +++ b/src/client/components/tile-header/tile-header.mocha.tsx @@ -24,7 +24,7 @@ import { TileHeader } from "./tile-header"; describe("TileHeader", () => { it("adds the correct class", () => { - var renderedComponent = renderIntoDocument( + const renderedComponent = renderIntoDocument( { + const iconElements = icons.map(icon => { return
{ it("adds the correct class", () => { - var renderedComponent = renderIntoDocument( + const renderedComponent = renderIntoDocument( >): string { - var classes: string[] = []; + const classes: string[] = []; - for (var arg of args) { + for (const arg of args) { if (!arg) continue; - var argType = typeof arg; + const argType = typeof arg; if (argType === "string") { classes.push(arg as string); } else if (argType === "object") { - for (var key in (arg as Record)) { + for (const key in (arg as Record)) { if (hasOwnProperty(arg, key) && (arg as any)[key]) classes.push(key); } } diff --git a/src/client/utils/function-slot/function-slot.ts b/src/client/utils/function-slot/function-slot.ts index 1179a6d23..1a3990fd8 100644 --- a/src/client/utils/function-slot/function-slot.ts +++ b/src/client/utils/function-slot/function-slot.ts @@ -23,8 +23,8 @@ export interface FunctionSlot { } export function createFunctionSlot(): FunctionSlot { - var myFn: (...args: any[]) => T; - var slot: FunctionSlot = (...args: any[]) => { + let myFn: (...args: any[]) => T; + const slot: FunctionSlot = (...args: any[]) => { if (myFn) return myFn.apply(this, args); return undefined; }; diff --git a/src/client/utils/immutable-form-delegate/immutable-form-delegate.tsx b/src/client/utils/immutable-form-delegate/immutable-form-delegate.tsx index 9bfca4e34..9ed358335 100644 --- a/src/client/utils/immutable-form-delegate/immutable-form-delegate.tsx +++ b/src/client/utils/immutable-form-delegate/immutable-form-delegate.tsx @@ -47,18 +47,18 @@ export class ImmutableFormDelegate { } updateErrors = (path: string, isValid: boolean, error: string): { errors: any, canSave: boolean } => { - var { errors } = this.form.state; + const { errors } = this.form.state; errors[path] = isValid ? false : error; - var canSave = true; - for (let key in errors) canSave = canSave && (errors[key] === false); + let canSave = true; + for (const key in errors) canSave = canSave && (errors[key] === false); return { errors, canSave }; }; onChange = (newItem: any, isValid: boolean, path: string, error: string) => { - var { errors, canSave } = this.updateErrors(path, isValid, error); + const { errors, canSave } = this.updateErrors(path, isValid, error); if (isValid) { this.setState({ diff --git a/src/client/utils/sizing/sizing.ts b/src/client/utils/sizing/sizing.ts index ac4289160..30a18c40e 100644 --- a/src/client/utils/sizing/sizing.ts +++ b/src/client/utils/sizing/sizing.ts @@ -21,12 +21,12 @@ export interface Positioning { } export function getVisibleSegments(segmentWidths: number[], offset: number, visibleSize: number): Positioning { - var startIndex = 0; - var shownColumns = 0; + let startIndex = 0; + let shownColumns = 0; - var curWidth = 0; + let curWidth = 0; for (const segmentWidth of segmentWidths) { - let afterWidth = curWidth + segmentWidth; + const afterWidth = curWidth + segmentWidth; if (afterWidth < offset) { startIndex++; } else if (curWidth < offset + visibleSize) { diff --git a/src/client/utils/test-utils/find-dom-node.ts b/src/client/utils/test-utils/find-dom-node.ts index c38a6f227..c2f1f4c39 100644 --- a/src/client/utils/test-utils/find-dom-node.ts +++ b/src/client/utils/test-utils/find-dom-node.ts @@ -21,6 +21,6 @@ import * as TestUtils from "react-dom/test-utils"; import { BodyPortal } from "../../components/body-portal/body-portal"; export function findDOMNode(element: React.Component | Element): Element { - var portal: any = TestUtils.scryRenderedComponentsWithType(element as React.Component, BodyPortal)[0]; + const portal: any = TestUtils.scryRenderedComponentsWithType(element as React.Component, BodyPortal)[0]; return portal ? portal.target.childNodes[0] : ReactDOM.findDOMNode(element) as Element; } diff --git a/src/client/utils/test-utils/get-caller-file.ts b/src/client/utils/test-utils/get-caller-file.ts index a58fedf44..30dbc2548 100644 --- a/src/client/utils/test-utils/get-caller-file.ts +++ b/src/client/utils/test-utils/get-caller-file.ts @@ -16,14 +16,14 @@ */ function getStack(): any[] { - let ErrorConstructor = Error; + const ErrorConstructor = Error; - var origPrepareStackTrace = ErrorConstructor.prepareStackTrace; + const origPrepareStackTrace = ErrorConstructor.prepareStackTrace; ErrorConstructor.prepareStackTrace = (_: any, stack: any) => stack; - var err = new Error() as any; - var stack = err["stack"] as any[]; + const err = new Error() as any; + const stack = err["stack"] as any[]; ErrorConstructor.prepareStackTrace = origPrepareStackTrace; stack.shift(); // getStack --> Error @@ -31,7 +31,7 @@ function getStack(): any[] { } export function getCallerFile() { - var stack = getStack(); + const stack = getStack(); stack.shift(); // getCaller --> getStack stack.shift(); // caller of getCaller --> getCaller diff --git a/src/client/utils/test-utils/index.ts b/src/client/utils/test-utils/index.ts index 3c3396325..09f3029cc 100644 --- a/src/client/utils/test-utils/index.ts +++ b/src/client/utils/test-utils/index.ts @@ -16,7 +16,7 @@ */ // This needs to be required, otherwise React doesn't play nice with jsdom... -var ExecutionEnvironment = require("../../../../node_modules/fbjs/lib/ExecutionEnvironment"); +const ExecutionEnvironment = require("../../../../node_modules/fbjs/lib/ExecutionEnvironment"); ExecutionEnvironment.canUseDOM = true; import "./require-extensions"; diff --git a/src/client/utils/test-utils/jsdom-setup.ts b/src/client/utils/test-utils/jsdom-setup.ts index 379f9be18..748bea134 100644 --- a/src/client/utils/test-utils/jsdom-setup.ts +++ b/src/client/utils/test-utils/jsdom-setup.ts @@ -17,9 +17,9 @@ import * as jsdom from "jsdom"; -var kickstart = () => { - let g: any = global; - let document = jsdom.jsdom(""); +const kickstart = () => { + const g: any = global; + const document = jsdom.jsdom(""); g.document = document; g.window = ( document).defaultView; g.navigator = { @@ -27,8 +27,8 @@ var kickstart = () => { }; }; -var cleanup = () => { - let g: any = global; +const cleanup = () => { + const g: any = global; delete g.document; delete g.window; delete g.navigator; diff --git a/src/client/utils/test-utils/mock-react-component.mocha.ts b/src/client/utils/test-utils/mock-react-component.mocha.ts index 197de34ae..1ba45dd79 100644 --- a/src/client/utils/test-utils/mock-react-component.mocha.ts +++ b/src/client/utils/test-utils/mock-react-component.mocha.ts @@ -32,7 +32,7 @@ describe("mockReactComponent", () => { it("should stub render and componentDidMount", () => { mockReactComponent(TestClass); - let myInstance = new TestClass(); + const myInstance = new TestClass(); expect(myInstance.render()).to.equal(null); expect(myInstance.componentDidMount()).to.equal(undefined); @@ -45,7 +45,7 @@ describe("mockReactComponent", () => { it("should restore render and componentDidMount", () => { (TestClass as any).restore(); - let myInstance = new TestClass(); + const myInstance = new TestClass(); expect(() => myInstance.render()) .to.throw("Hey, render is supposed to be stubbed !"); diff --git a/src/client/utils/test-utils/mock-react-component.ts b/src/client/utils/test-utils/mock-react-component.ts index 2fb15f7d2..ca889d156 100644 --- a/src/client/utils/test-utils/mock-react-component.ts +++ b/src/client/utils/test-utils/mock-react-component.ts @@ -16,11 +16,11 @@ */ export function mockReactComponent(_class: any) { - let prototype = _class.prototype; - let toUndo: Array<() => void> = []; + const prototype = _class.prototype; + const toUndo: Array<() => void> = []; if (prototype.hasOwnProperty("componentDidMount") === true) { - let oldComponentDidMount = prototype.componentDidMount; + const oldComponentDidMount = prototype.componentDidMount; toUndo.push(() => { prototype.componentDidMount = oldComponentDidMount; }); @@ -28,7 +28,7 @@ export function mockReactComponent(_class: any) { } if (prototype.hasOwnProperty("render") === true) { - let oldRender = prototype.render; + const oldRender = prototype.render; toUndo.push(() => { prototype.render = oldRender; }); diff --git a/src/client/utils/test-utils/mock-require-ensure.ts b/src/client/utils/test-utils/mock-require-ensure.ts index ddc258ff5..54fe268a4 100644 --- a/src/client/utils/test-utils/mock-require-ensure.ts +++ b/src/client/utils/test-utils/mock-require-ensure.ts @@ -24,9 +24,9 @@ export function mockRequireEnsure(path: string): any { // Gets the absolute path based on the caller's path path = resolve(dirname(getCallerFile()), path); - let mod = rewire(path); + const mod = rewire(path); - let mockedRequire = mod.__get__("require"); + const mockedRequire = mod.__get__("require"); mockedRequire.ensure = (path: any, callback: any) => callback(mockedRequire); return mod; diff --git a/src/client/visualizations/bar-chart/bar-chart.tsx b/src/client/visualizations/bar-chart/bar-chart.tsx index cdcac3c94..57c795771 100644 --- a/src/client/visualizations/bar-chart/bar-chart.tsx +++ b/src/client/visualizations/bar-chart/bar-chart.tsx @@ -128,7 +128,7 @@ function padDataset(originalDataset: Dataset, dimension: Dimension, measures: Me const filledData: Datum[] = []; data.forEach(d => { - let segmentValue = d[dimensionName]; + const segmentValue = d[dimensionName]; const segmentStart = (segmentValue as PlywoodRange).start; while (i < segmentStart) { filledData[j] = {}; @@ -178,7 +178,7 @@ class BarChart extends React.Component { componentDidUpdate() { const { scrollerYPosition, scrollerXPosition } = this.state; - let scrollerComponent = this.scroller.current; + const scrollerComponent = this.scroller.current; if (!scrollerComponent) return; const rect = scrollerComponent.scroller.current.getBoundingClientRect(); @@ -220,7 +220,7 @@ class BarChart extends React.Component { const path: Datum[] = []; let currentData: Dataset = mySplitDataset; indices.forEach(i => { - let datum = currentData.data[i]; + const datum = currentData.data[i]; path.push(datum); currentData = (datum[SPLIT] as Dataset); }); @@ -312,7 +312,7 @@ class BarChart extends React.Component { } hasValidYExtent(series: ConcreteSeries, data: Datum[]): boolean { - let [yMin, yMax] = this.getYExtent(data, series); + const [yMin, yMax] = this.getYExtent(data, series); return !isNaN(yMin) && !isNaN(yMax); } @@ -492,32 +492,32 @@ class BarChart extends React.Component { const { essence } = this.props; const { timezone } = essence; - let bars: JSX.Element[] = []; + const bars: JSX.Element[] = []; let highlight: JSX.Element; const dimension = findDimensionByName(essence.dataCube.dimensions, essence.splits.splits.get(splitIndex).reference); const splitLength = essence.splits.length(); data.forEach((d, i) => { - let segmentValue = d[dimension.name]; - let segmentValueStr = formatValue(segmentValue, timezone); - let subPath = path.concat(d); + const segmentValue = d[dimension.name]; + const segmentValueStr = formatValue(segmentValue, timezone); + const subPath = path.concat(d); let bar: any; let bubble: JSX.Element = null; - let subCoordinates = coordinates[i]; - let { x, y, height, barWidth, barOffset } = coordinates[i]; + const subCoordinates = coordinates[i]; + const { x, y, height, barWidth, barOffset } = coordinates[i]; if (splitIndex < splitLength - 1) { - let subData: Datum[] = (d[SPLIT] as Dataset).data; - let subRender = this.renderBars(subData, series, chartIndex, chartStage, xAxisStage, subCoordinates.children, splitIndex + 1, subPath); + const subData: Datum[] = (d[SPLIT] as Dataset).data; + const subRender = this.renderBars(subData, series, chartIndex, chartStage, xAxisStage, subCoordinates.children, splitIndex + 1, subPath); bar = subRender.bars; if (!highlight && subRender.highlight) highlight = subRender.highlight; } else { - let bubbleInfo: BubbleInfo = { + const bubbleInfo: BubbleInfo = { series, chartIndex, path: subPath, @@ -526,13 +526,13 @@ class BarChart extends React.Component { splitIndex }; - let isHovered = this.isHovered(subPath, series); + const isHovered = this.isHovered(subPath, series); if (isHovered) { bubble = this.renderHoverBubble(bubbleInfo); } - let selected = this.isSelected(subPath, series.definition); - let faded = this.isFaded(); + const selected = this.isSelected(subPath, series.definition); + const faded = this.isFaded(); if (selected) { bubble = this.renderSelectionBubble(bubbleInfo); if (bubble) highlight = this.renderSelectionHighlight(chartStage, subCoordinates, chartIndex); @@ -594,9 +594,9 @@ class BarChart extends React.Component { const leftThing = ascending ? "start" : "end"; const rightThing = ascending ? "end" : "start"; data.forEach((d, i) => { - let segmentValue = d[dimension.name]; + const segmentValue = d[dimension.name]; let segmentValueStr = String(Range.isRange(segmentValue) ? (segmentValue as any)[leftThing] : ""); - let coordinate = coordinates[i]; + const coordinate = coordinates[i]; labels.push(
{ }); } else { data.forEach((d, i) => { - let segmentValueStr = String(d[dimension.name]); - let coordinate = coordinates[i]; + const segmentValueStr = String(d[dimension.name]); + const coordinate = coordinates[i]; labels.push(
{ }; } - let { xAxisStage } = this.getAxisStages(chartStage); + const { xAxisStage } = this.getAxisStages(chartStage); const { yAxis, yGridLines } = this.getYAxisStuff(mySplitDataset, series, chartStage, chartIndex); let bars: JSX.Element[]; let highlight: JSX.Element; if (this.isChartVisible(chartIndex, xAxisStage)) { - let renderedChart = this.renderBars(mySplitDataset.data, series, chartIndex, chartStage, xAxisStage, coordinates); + const renderedChart = this.renderBars(mySplitDataset.data, series, chartIndex, chartStage, xAxisStage, coordinates); bars = renderedChart.bars; highlight = renderedChart.highlight; } @@ -766,7 +766,7 @@ class BarChart extends React.Component { maxima[level] = Math.max(maxima[level], data.length); if (data[0] && data[0][SPLIT] !== undefined) { - let n = data.length; + const n = data.length; for (let i = 0; i < n; i++) { this.maxNumberOfLeaves((data[i][SPLIT] as Dataset).data, maxima, level + 1); } @@ -868,9 +868,9 @@ class BarChart extends React.Component { const { stepWidth, barWidth, barOffset } = this.getBarDimensions(xScale.bandwidth()); const coordinates: BarCoordinates[] = data.map((d, i) => { - let x = xScale(getX(d, i)); - let y = scaleY(series.selectValue(d)); - let h = scaleY(0) - y; + const x = xScale(getX(d, i)); + const y = scaleY(series.selectValue(d)); + const h = scaleY(0) - y; const children: BarCoordinates[] = []; const coordinate = new BarCoordinates({ x, @@ -884,10 +884,10 @@ class BarChart extends React.Component { }); if (splitIndex < essence.splits.length()) { - let subStage: Stage = new Stage({ x, y: chartStage.y, width: barWidth, height: chartStage.height }); - let subGetX: any = (d: Datum, i: number) => String(i); - let subData: Datum[] = (d[SPLIT] as Dataset).data; - let subxScale = d3.scaleBand() + const subStage: Stage = new Stage({ x, y: chartStage.y, width: barWidth, height: chartStage.height }); + const subGetX: any = (d: Datum, i: number) => String(i); + const subData: Datum[] = (d[SPLIT] as Dataset).data; + const subxScale = d3.scaleBand() .domain(d3.range(0, maxNumberOfLeaves[splitIndex]).map(String)) .range([x + barOffset, x + subStage.width]); @@ -937,7 +937,7 @@ class BarChart extends React.Component { if (splits.length()) { const xScale = this.getPrimaryXScale(); - let yAxes: JSX.Element[] = []; + const yAxes: JSX.Element[] = []; const series = essence.getConcreteSeries(); const chartStage = this.getSingleChartStage(); diff --git a/src/client/visualizations/scatterplot/heatmap.tsx b/src/client/visualizations/scatterplot/heatmap.tsx index 651a79acb..88af89a82 100644 --- a/src/client/visualizations/scatterplot/heatmap.tsx +++ b/src/client/visualizations/scatterplot/heatmap.tsx @@ -80,7 +80,7 @@ interface GetCounts { type Counts = number[][]; function getCounts({ xBinCount, yBinCount, xSeries, ySeries, xQuantile, yQuantile, data }: GetCounts): Counts { - let counts = Array.from({ length: xBinCount }, () => Array.from({ length: yBinCount }, () => 0)); + const counts = Array.from({ length: xBinCount }, () => Array.from({ length: yBinCount }, () => 0)); data.forEach(datum => { const i = xQuantile(xSeries.selectValue(datum)); diff --git a/src/common/models/data-cube/data-cube.mocha.ts b/src/common/models/data-cube/data-cube.mocha.ts index e0354f560..11601a3cb 100644 --- a/src/common/models/data-cube/data-cube.mocha.ts +++ b/src/common/models/data-cube/data-cube.mocha.ts @@ -220,7 +220,7 @@ describe("DataCube", () => { } }; - var dataCube = fromConfig(legacyDataCubeJS, druidCluster); + const dataCube = fromConfig(legacyDataCubeJS, druidCluster); expect(dataCube).to.deep.equal({ attributeOverrides: [ @@ -283,7 +283,7 @@ describe("DataCube", () => { describe("#deduceAttributes", () => { it("works in a generic case", () => { - var dataCube = fromConfig({ + const dataCube = fromConfig({ name: "wiki", clusterName: "druid", source: "wiki", @@ -353,7 +353,7 @@ describe("DataCube", () => { }); it("omits unsupported expressions", () => { - var dataCube = fromConfig({ + const dataCube = fromConfig({ name: "wiki", clusterName: "druid", source: "wiki", diff --git a/src/common/models/data-cube/queryable-data-cube.ts b/src/common/models/data-cube/queryable-data-cube.ts index 64d9fdc3d..254347fa5 100644 --- a/src/common/models/data-cube/queryable-data-cube.ts +++ b/src/common/models/data-cube/queryable-data-cube.ts @@ -52,7 +52,8 @@ export interface QueryableDataCube extends DataCube { } export function addAttributes(dataCube: DataCube, newAttributes: Attributes): DataCube { - let { dimensions, measures, attributes, introspection } = dataCube; + const { attributes, introspection } = dataCube; + let { dimensions, measures } = dataCube; if (introspection === "none") return dataCube; const autofillDimensions = introspection === "autofill-dimensions-only" || introspection === "autofill-all"; @@ -60,7 +61,7 @@ export function addAttributes(dataCube: DataCube, newAttributes: Attributes): Da const $main = $("main"); - for (let newAttribute of newAttributes) { + for (const newAttribute of newAttributes) { const { name, type, nativeType } = newAttribute; // Already exists as a current attribute diff --git a/src/common/models/dimension/dimensions.ts b/src/common/models/dimension/dimensions.ts index 0a0cfb133..718f49a8e 100644 --- a/src/common/models/dimension/dimensions.ts +++ b/src/common/models/dimension/dimensions.ts @@ -60,7 +60,7 @@ export interface Dimensions { } export function fromConfig(config: DimensionOrGroupJS[]): Dimensions { - let byName: Record = {}; + const byName: Record = {}; function readDimensionOrGroup(dimOrGroup: DimensionOrGroupJS): DimensionOrGroup { if (isDimensionGroupJS(dimOrGroup)) { diff --git a/src/common/models/drag-position/drag-position.ts b/src/common/models/drag-position/drag-position.ts index 7bead5fc3..dbe372bf3 100644 --- a/src/common/models/drag-position/drag-position.ts +++ b/src/common/models/drag-position/drag-position.ts @@ -28,7 +28,7 @@ export interface DragPositionJS { replace?: number; } -var check: Class; +let check: Class; export class DragPosition implements Instance { @@ -49,15 +49,15 @@ export class DragPosition implements Instance }); } - var sectionWidth = itemWidth + itemGap; - var sectionNumber = Math.floor(offset / sectionWidth); + const sectionWidth = itemWidth + itemGap; + const sectionNumber = Math.floor(offset / sectionWidth); if (numItems <= sectionNumber) { return new DragPosition({ replace: numItems }); } - var offsetWithinSection = offset - sectionWidth * sectionNumber; + const offsetWithinSection = offset - sectionWidth * sectionNumber; if (offsetWithinSection < itemWidth) { return new DragPosition({ replace: sectionNumber @@ -98,7 +98,7 @@ export class DragPosition implements Instance } public toJS(): DragPositionJS { - var js: DragPositionJS = {}; + const js: DragPositionJS = {}; if (this.insert != null) js.insert = this.insert; if (this.replace != null) js.replace = this.replace; return js; diff --git a/src/common/models/external-view/external-view.ts b/src/common/models/external-view/external-view.ts index 7d5bb83a3..d314ccf08 100644 --- a/src/common/models/external-view/external-view.ts +++ b/src/common/models/external-view/external-view.ts @@ -30,7 +30,7 @@ export interface ExternalViewValue { sameWindow?: boolean; } -var check: Class; +let check: Class; export class ExternalView implements Instance { @@ -39,7 +39,7 @@ export class ExternalView implements Instance = {}; + const byName: Record = {}; function readMeasureOrGroup(measureOrGroup: MeasureOrGroupJS): MeasureOrGroup { if (isMeasureGroupJS(measureOrGroup)) { diff --git a/src/common/models/refresh-rule/refresh-rule.ts b/src/common/models/refresh-rule/refresh-rule.ts index 876887459..74dfb33a2 100644 --- a/src/common/models/refresh-rule/refresh-rule.ts +++ b/src/common/models/refresh-rule/refresh-rule.ts @@ -27,7 +27,7 @@ export interface RefreshRuleJS { time?: Date | string; } -var check: Class; +let check: Class; export class RefreshRule implements Instance { @@ -46,7 +46,7 @@ export class RefreshRule implements Instance { } static fromJS(parameters: RefreshRuleJS): RefreshRule { - var value: RefreshRuleValue = { + const value: RefreshRuleValue = { rule: parameters.rule }; if (parameters.time) { @@ -59,7 +59,7 @@ export class RefreshRule implements Instance { public time: Date; constructor(parameters: RefreshRuleValue) { - var rule = parameters.rule; + const rule = parameters.rule; if (rule !== RefreshRule.FIXED && rule !== RefreshRule.QUERY && rule !== RefreshRule.REALTIME) { throw new Error(`rule must be on of: ${RefreshRule.FIXED}, ${RefreshRule.QUERY}, or ${RefreshRule.REALTIME}`); } @@ -68,7 +68,7 @@ export class RefreshRule implements Instance { } public valueOf(): RefreshRuleValue { - var value: RefreshRuleValue = { + const value: RefreshRuleValue = { rule: this.rule }; if (this.time) { @@ -78,7 +78,7 @@ export class RefreshRule implements Instance { } public toJS(): RefreshRuleJS { - var js: RefreshRuleJS = { + const js: RefreshRuleJS = { rule: this.rule }; if (this.time) { diff --git a/src/common/models/stage/stage.ts b/src/common/models/stage/stage.ts index 321d31ef2..d74f59801 100644 --- a/src/common/models/stage/stage.ts +++ b/src/common/models/stage/stage.ts @@ -39,7 +39,7 @@ export interface StageJS { height: number; } -var check: Class; +let check: Class; export class Stage implements Instance { static isStage(candidate: any): candidate is Stage { @@ -160,22 +160,22 @@ export class Stage implements Instance { } public changeY(y: number): Stage { - var value = this.valueOf(); + const value = this.valueOf(); value.y = y; return Stage.fromJS(value); } public changeHeight(height: number): Stage { - var value = this.valueOf(); + const value = this.valueOf(); value.height = height; return Stage.fromJS(value); } public within(param: MarginParameters): Stage { - var value = this.sizeOnlyValue(); - var { left, right, top, bottom } = param; + const value = this.sizeOnlyValue(); + const { left, right, top, bottom } = param; if (left) { value.x = left; diff --git a/src/common/utils/external/datacube-to-external.ts b/src/common/utils/external/datacube-to-external.ts index 99784519d..f2d902212 100644 --- a/src/common/utils/external/datacube-to-external.ts +++ b/src/common/utils/external/datacube-to-external.ts @@ -55,7 +55,7 @@ export function deduceAttributes(dataCube: DataCube): Attributes { const expression = dimension.expression; if (expression.equals(timeAttribute)) return; const references = expression.getFreeReferences(); - for (let reference of references) { + for (const reference of references) { if (NamedArray.findByName(attributes, reference)) continue; attributes.push(AttributeInfo.fromJS({ name: reference, type: "STRING" })); } @@ -63,7 +63,7 @@ export function deduceAttributes(dataCube: DataCube): Attributes { allMeasures(measures).forEach(measure => { const references = getReferences(measure.expression); - for (let reference of references) { + for (const reference of references) { if (NamedArray.findByName(attributes, reference)) continue; if (isApproximate(measure)) continue; attributes.push(AttributeInfo.fromJS({ name: reference, type: "NUMBER" })); @@ -82,7 +82,7 @@ export default function dataCubeToExternal(dataCube: DataCube): External { const { cluster, options } = dataCube; if (!cluster) throw new Error("must have a cluster"); - let externalValue: ExternalValue = { + const externalValue: ExternalValue = { engine: cluster.type, suppress: true, source: dataCube.source, diff --git a/src/common/utils/general/general.ts b/src/common/utils/general/general.ts index d8f1724ec..c426b487b 100644 --- a/src/common/utils/general/general.ts +++ b/src/common/utils/general/general.ts @@ -52,10 +52,10 @@ export function isFiniteNumber(n: number): boolean { } export function moveInList(list: List, itemIndex: number, insertPoint: number): List { - var n = list.size; + const n = list.size; if (itemIndex < 0 || itemIndex >= n) throw new Error("itemIndex out of range"); if (insertPoint < 0 || insertPoint > n) throw new Error("insertPoint out of range"); - var newArray: T[] = []; + const newArray: T[] = []; list.forEach((value, i) => { if (i === insertPoint) newArray.push(list.get(itemIndex)); if (i !== itemIndex) newArray.push(value); @@ -76,8 +76,8 @@ export function makeTitle(name: string): string { } export function collect(wait: number, fn: Fn): Fn { - var timeout: any; - var later = () => { + let timeout: any; + const later = () => { timeout = null; fn(); }; @@ -97,7 +97,7 @@ export function makeUrlSafeName(name: string): string { export function verifyUrlSafeName(name: string): void { if (typeof name !== "string") throw new TypeError("name must be a string"); if (!name.length) throw new Error("can not have empty name"); - var urlSafeName = makeUrlSafeName(name); + const urlSafeName = makeUrlSafeName(name); if (name !== urlSafeName) { throw new Error(`'${name}' is not a URL safe name. Try '${urlSafeName}' instead?`); } @@ -113,8 +113,8 @@ export function findFirstBiggerIndex(array: T[], elementToFind: T, valueOf: ( } export function findBiggerClosestToIdeal(array: T[], elementToFind: T, ideal: T, valueOf: (input: T) => number) { - var biggerOrEqualIndex = List(array).findIndex(g => valueOf(g) >= valueOf(elementToFind)); - var biggerArrayOrEqual = array.slice(biggerOrEqualIndex); + const biggerOrEqualIndex = List(array).findIndex(g => valueOf(g) >= valueOf(elementToFind)); + const biggerArrayOrEqual = array.slice(biggerOrEqualIndex); return biggerArrayOrEqual.reduce((pV, cV) => Math.abs(valueOf(pV) - valueOf(ideal)) < Math.abs(valueOf(cV) - valueOf(ideal)) ? pV : cV); } @@ -139,7 +139,7 @@ export function integerDivision(x: number, y: number): number { } export function toSignificantDigits(n: number, digits: number) { - var multiplier = Math.pow(10, digits - Math.floor(Math.log(n) / Math.LN10) - 1); + const multiplier = Math.pow(10, digits - Math.floor(Math.log(n) / Math.LN10) - 1); return Math.round(n * multiplier) / multiplier; } diff --git a/src/common/utils/immutable-utils/immutable-utils.ts b/src/common/utils/immutable-utils/immutable-utils.ts index 057eda4b4..34198f584 100644 --- a/src/common/utils/immutable-utils/immutable-utils.ts +++ b/src/common/utils/immutable-utils/immutable-utils.ts @@ -20,11 +20,11 @@ import { isObject } from "../general/general"; export class ImmutableUtils { public static setProperty(instance: any, path: string, newValue: any): any { - var bits = path.split("."); - var lastObject = newValue; - var currentObject: any; + const bits = path.split("."); + let lastObject = newValue; + let currentObject: any; - var getLastObject = () => { + const getLastObject = () => { let o: any = instance; for (const bit of bits) { @@ -35,13 +35,13 @@ export class ImmutableUtils { }; while (bits.length) { - let bit = bits.pop(); + const bit = bits.pop(); currentObject = getLastObject(); if (currentObject.change instanceof Function) { lastObject = currentObject.change(bit, lastObject); } else { - let message = "Can't find \`change()\` method on " + currentObject.constructor.name; + const message = "Can't find \`change()\` method on " + currentObject.constructor.name; console.error(message); // Leaving this console statement because the error might be caught and obfuscated throw new Error(message); } @@ -51,16 +51,16 @@ export class ImmutableUtils { } public static getProperty(instance: any, path: string): any { - var value = instance; - var bits = path.split("."); - var bit: string; + let value = instance; + const bits = path.split("."); + let bit: string; while (bit = bits.shift()) value = value[bit]; return value as any; } public static change(instance: T, propertyName: string, newValue: any): T { - var v = instance.valueOf(); + const v = instance.valueOf(); if (!v.hasOwnProperty(propertyName)) { throw new Error(`Unknown property : ${propertyName}`); @@ -71,7 +71,7 @@ export class ImmutableUtils { } public static addInArray(instance: T, propertyName: string, newItem: any, index = -1): T { - var newArray = (instance as any)[propertyName]; + const newArray = (instance as any)[propertyName]; if (index === -1) { newArray.push(newItem); diff --git a/src/common/utils/object/object.ts b/src/common/utils/object/object.ts index 8b34fec1b..beb1194a1 100644 --- a/src/common/utils/object/object.ts +++ b/src/common/utils/object/object.ts @@ -19,7 +19,7 @@ import { assoc, Unary } from "../functional/functional"; import { isTruthy } from "../general/general"; export function extend(source: any, target: any): any { - for (let key in source) { + for (const key in source) { target[key] = source[key]; } diff --git a/src/common/utils/rules/predicates.mocha.ts b/src/common/utils/rules/predicates.mocha.ts index fe17b1f97..7b62a5808 100644 --- a/src/common/utils/rules/predicates.mocha.ts +++ b/src/common/utils/rules/predicates.mocha.ts @@ -20,10 +20,10 @@ import { expect } from "chai"; import { Predicates } from "./predicates"; describe("dimension kind matcher", () => { - let strictCompare = Predicates.strictCompare; + const strictCompare = Predicates.strictCompare; it("should work in various cases", () => { - var cases: any[] = [ + const cases: any[] = [ [[], [], true], [["time"], ["time"], true], [["time", "*"], ["pouet", "time"], false], diff --git a/src/common/utils/rules/predicates.ts b/src/common/utils/rules/predicates.ts index b5e6c504a..dae093e2a 100644 --- a/src/common/utils/rules/predicates.ts +++ b/src/common/utils/rules/predicates.ts @@ -52,10 +52,10 @@ export class Predicates { return true; } - var bareSelector = selector.replace(/^!/, ""); + const bareSelector = selector.replace(/^!/, ""); // This can be enriched later, right now it's just a 1-1 match - var result = kind === bareSelector; + const result = kind === bareSelector; if (selector.charAt(0) === "!") { return !result; @@ -66,7 +66,7 @@ export class Predicates { public static haveAtLeastSplitKinds(...kinds: DimensionKind[]): VisualizationDependentPredicate { return ({ splits, dataCube }) => { - let getKind = (split: Split) => findDimensionByName(dataCube.dimensions, split.reference).kind; + const getKind = (split: Split) => findDimensionByName(dataCube.dimensions, split.reference).kind; const actualKinds = splits.splits.map(getKind); diff --git a/src/common/utils/rules/rules-evaluator-builder.ts b/src/common/utils/rules/rules-evaluator-builder.ts index 067239350..c5016e94a 100644 --- a/src/common/utils/rules/rules-evaluator-builder.ts +++ b/src/common/utils/rules/rules-evaluator-builder.ts @@ -93,7 +93,7 @@ export class RulesEvaluatorBuilder build(): RulesEvaluator { return (variables: PredicateVars & ActionVars): Resolve => { - for (let rule of this.rules) { + for (const rule of this.rules) { const { predicates, action } = rule; if (predicates.some(predicate => predicate(variables))) { return action(variables); diff --git a/src/common/utils/string/string.ts b/src/common/utils/string/string.ts index 5b5b129b0..80982877d 100644 --- a/src/common/utils/string/string.ts +++ b/src/common/utils/string/string.ts @@ -26,7 +26,7 @@ export function firstUp(str: string): string { } export function pad(n: number, padding = 3): string { - var str = String(n); + let str = String(n); if (str.length > padding) return str; @@ -36,9 +36,9 @@ export function pad(n: number, padding = 3): string { } export function generateUniqueName(prefix: string, isUnique: (name: string) => boolean) { - var i = 0; + let i = 0; - var name = prefix + pad(i); + let name = prefix + pad(i); while (!isUnique(name)) { name = prefix + pad(++i); diff --git a/src/common/utils/yaml-helper/yaml-helper.ts b/src/common/utils/yaml-helper/yaml-helper.ts index 754705240..921a68d26 100644 --- a/src/common/utils/yaml-helper/yaml-helper.ts +++ b/src/common/utils/yaml-helper/yaml-helper.ts @@ -36,7 +36,7 @@ function spaces(n: number) { } function extend(a: any, b: any): any { - for (let key in a) { + for (const key in a) { b[key] = a[key]; } @@ -94,7 +94,7 @@ function yamlPropAdder(lines: string[], withComments: boolean, options: PropAdde function getYamlPropAdder(object: any, labels: any, lines: string[], withComments = false) { const adder = (propName: string, additionalOptions?: { defaultValue?: any }) => { - let propVerbiage = labels[propName]; + const propVerbiage = labels[propName]; let comment: string; if (!propVerbiage) { @@ -118,7 +118,7 @@ function getYamlPropAdder(object: any, labels: any, lines: string[], withComment function customizationToYAML(customization: Customization, withComments: boolean): string[] { const { timezones, externalViews, cssVariables } = customization; - let lines: string[] = []; + const lines: string[] = []; getYamlPropAdder(customization, CUSTOMIZATION, lines, withComments) .add("customLogoSvg") @@ -154,11 +154,11 @@ function customizationToYAML(customization: Customization, withComments: boolean } function clusterToYAML(cluster: Cluster, withComments: boolean): string[] { - let lines: string[] = [ + const lines: string[] = [ `name: ${cluster.name}` ]; - let props = getYamlPropAdder(cluster, CLUSTER, lines, withComments); + const props = getYamlPropAdder(cluster, CLUSTER, lines, withComments); props .add("url") @@ -191,7 +191,7 @@ function clusterToYAML(cluster: Cluster, withComments: boolean): string[] { } function attributeToYAML(attribute: AttributeInfo): string[] { - let lines: string[] = [ + const lines: string[] = [ `name: ${attribute.name}`, `type: ${attribute.type}` ]; @@ -205,7 +205,7 @@ function attributeToYAML(attribute: AttributeInfo): string[] { } function dimensionToYAML(dimension: Dimension): string[] { - let lines: string[] = [ + const lines: string[] = [ `name: ${dimension.name}`, `title: ${dimension.title}` ]; @@ -226,7 +226,7 @@ function dimensionToYAML(dimension: Dimension): string[] { } function measureToYAML(measure: Measure): string[] { - let lines: string[] = [ + const lines: string[] = [ `name: ${measure.name}`, `title: ${measure.title}` ]; @@ -281,7 +281,7 @@ function dataCubeToYAML(dataCube: DataCube, withComments: boolean): string[] { } lines.push(""); - let addProps = getYamlPropAdder(dataCube, DATA_CUBE, lines, withComments); + const addProps = getYamlPropAdder(dataCube, DATA_CUBE, lines, withComments); addProps .add("defaultTimezone", { defaultValue: DEFAULT_DEFAULT_TIMEZONE }) diff --git a/src/common/visualization-manifests/line-chart/line-chart.ts b/src/common/visualization-manifests/line-chart/line-chart.ts index a388c1f4b..f13b4db53 100644 --- a/src/common/visualization-manifests/line-chart/line-chart.ts +++ b/src/common/visualization-manifests/line-chart/line-chart.ts @@ -129,7 +129,7 @@ const rulesEvaluator = visualizationDependentEvaluatorBuilder .when(Predicates.haveAtLeastSplitKinds("time")) .then(({ splits, dataCube }) => { - let timeSplit = splits.splits.find(split => findDimensionByName(dataCube.dimensions, split.reference).kind === "time"); + const timeSplit = splits.splits.find(split => findDimensionByName(dataCube.dimensions, split.reference).kind === "time"); return Resolve.manual(NORMAL_PRIORITY_ACTION, "Too many splits on the line chart", [ { description: "Remove all but the time split", @@ -141,7 +141,7 @@ const rulesEvaluator = visualizationDependentEvaluatorBuilder }) .otherwise(({ dataCube }) => { - let continuousDimensions = getDimensionsByKind(dataCube, "time").concat(getDimensionsByKind(dataCube, "number")); + const continuousDimensions = getDimensionsByKind(dataCube, "time").concat(getDimensionsByKind(dataCube, "number")); return Resolve.manual(NORMAL_PRIORITY_ACTION, "The Line Chart needs one continuous dimension split", continuousDimensions.map(continuousDimension => { return { diff --git a/src/server/app.ts b/src/server/app.ts index fabed025c..6e4278c5b 100644 --- a/src/server/app.ts +++ b/src/server/app.ts @@ -43,7 +43,7 @@ declare module "express" { export default function createApp(serverSettings: ServerSettings, settingsManager: SettingsManager, version: string): Express { - let app = express(); + const app = express(); app.disable("x-powered-by"); const isDev = app.get("env") === "development"; diff --git a/src/server/routes/mkurl/mkurl.mocha.ts b/src/server/routes/mkurl/mkurl.mocha.ts index a534ff400..0eca618cd 100644 --- a/src/server/routes/mkurl/mkurl.mocha.ts +++ b/src/server/routes/mkurl/mkurl.mocha.ts @@ -25,7 +25,7 @@ import { mkurlRouter } from "./mkurl"; const mkurlPath = "/mkurl"; -let app = express(); +const app = express(); app.use(bodyParser.json()); diff --git a/src/server/routes/plyql/plyql.mocha.ts b/src/server/routes/plyql/plyql.mocha.ts index 7fa89ee04..3da154c1d 100644 --- a/src/server/routes/plyql/plyql.mocha.ts +++ b/src/server/routes/plyql/plyql.mocha.ts @@ -22,7 +22,7 @@ import supertest from "supertest"; import { wikiSourcesWithExecutor } from "../../../common/models/sources/sources.fixtures"; import { plyqlRouter } from "./plyql"; -let app = express(); +const app = express(); app.use(bodyParser.json()); diff --git a/src/server/routes/plywood/plywood.mocha.ts b/src/server/routes/plywood/plywood.mocha.ts index 29c5348ff..0d5487687 100644 --- a/src/server/routes/plywood/plywood.mocha.ts +++ b/src/server/routes/plywood/plywood.mocha.ts @@ -27,7 +27,7 @@ const settingsManagerFixture = { anchorPath: "." }; -let app = express(); +const app = express(); app.use(bodyParser.json()); diff --git a/src/server/utils/cluster-manager/cluster-manager.ts b/src/server/utils/cluster-manager/cluster-manager.ts index eb0cae733..ded23c4f9 100644 --- a/src/server/utils/cluster-manager/cluster-manager.ts +++ b/src/server/utils/cluster-manager/cluster-manager.ts @@ -357,7 +357,7 @@ export class ClusterManager { (sources: string[]) => { if (verbose) logger.log(`For cluster '${cluster.name}' got sources: [${sources.join(", ")}]`); // For every un-accounted source: make an external and add it to the managed list. - let introspectionTasks: Array> = []; + const introspectionTasks: Array> = []; this.managedExternals.forEach(ex => { if (sources.find(src => src === String(ex.external.source)) == null) { @@ -412,7 +412,7 @@ export class ClusterManager { return (External.getConstructorFor(cluster.type) as any).getSourceList(this.requester) .then( (sources: string[]) => { - let introspectionTasks: Array> = []; + const introspectionTasks: Array> = []; sources.forEach(source => { const existingExternalsForSource = this.managedExternals.filter(managedExternal => externalContainsSource(managedExternal.external, source)); diff --git a/src/server/utils/datacube-guard/datacube-guard.mocha.ts b/src/server/utils/datacube-guard/datacube-guard.mocha.ts index 3a5cabe71..e15d37f5e 100644 --- a/src/server/utils/datacube-guard/datacube-guard.mocha.ts +++ b/src/server/utils/datacube-guard/datacube-guard.mocha.ts @@ -31,7 +31,7 @@ describe("Guard test", () => { }); it("Guard off -> access to all dataCubes", () => { - let dataCube = customCubeWithGuard(null, false); + const dataCube = customCubeWithGuard(null, false); expect(checkAccess(dataCube, mockHeaders(""))).to.equal(true); }); @@ -44,12 +44,12 @@ describe("Guard test", () => { }); it("Guard on -> access allowed: wildchar", () => { - let dataCube = customCubeWithGuard(); + const dataCube = customCubeWithGuard(); expect(checkAccess(dataCube, mockHeaders("*,some-other-name"))).to.equal(true); }); it("Guard on -> access allowed: datacube allowed", () => { - let dataCube = customCubeWithGuard(); + const dataCube = customCubeWithGuard(); expect(checkAccess(dataCube, mockHeaders("some-name,some-other-name"))).to.equal(true); }); }); diff --git a/src/server/utils/datacube-guard/datacube-guard.ts b/src/server/utils/datacube-guard/datacube-guard.ts index 223d7665e..7fea8dd37 100644 --- a/src/server/utils/datacube-guard/datacube-guard.ts +++ b/src/server/utils/datacube-guard/datacube-guard.ts @@ -20,7 +20,7 @@ import { DataCube } from "../../../common/models/data-cube/data-cube"; export const allowDataCubesHeaderName = "x-turnilo-allow-datacubes"; export function checkAccess(dataCube: DataCube, headers: Request["headers"]) { - var guard = dataCube && dataCube.cluster && dataCube.cluster.guardDataCubes || false; + const guard = dataCube && dataCube.cluster && dataCube.cluster.guardDataCubes || false; if (!guard) { return true; diff --git a/src/server/utils/file-manager/file-manager.ts b/src/server/utils/file-manager/file-manager.ts index 41aa15190..aacc5a905 100644 --- a/src/server/utils/file-manager/file-manager.ts +++ b/src/server/utils/file-manager/file-manager.ts @@ -78,7 +78,7 @@ export class FileManager { .then( rawData => { logger.log(`Loaded file ${filePath} (rows = ${rawData.length})`); - var dataset = Dataset.fromJS(rawData).hide(); + let dataset = Dataset.fromJS(rawData).hide(); if (this.subsetExpression) { dataset = dataset.filter(this.subsetExpression); diff --git a/src/server/utils/parser/parser.ts b/src/server/utils/parser/parser.ts index a4a4ad4ca..0ab80166e 100644 --- a/src/server/utils/parser/parser.ts +++ b/src/server/utils/parser/parser.ts @@ -27,7 +27,7 @@ export function parseTSV(text: string): any[] { export function parseJSON(text: string): any[] { text = text.trim(); - var firstChar = text[0]; + const firstChar = text[0]; if (firstChar[0] === "[") { try { diff --git a/src/server/utils/settings-manager/settings-manager.ts b/src/server/utils/settings-manager/settings-manager.ts index 1a8404a21..0dc57e945 100644 --- a/src/server/utils/settings-manager/settings-manager.ts +++ b/src/server/utils/settings-manager/settings-manager.ts @@ -238,7 +238,7 @@ export class SettingsManager { logger.log(`Got external dataset removal for ${dataCubeName} in cluster ${cluster.name}`); - let dataCube = getDataCube(sources, dataCubeName); + const dataCube = getDataCube(sources, dataCubeName); if (dataCube) { this.sources = deleteDataCube(sources, dataCube); this.timeMonitor.removeCheck(dataCube); diff --git a/src/server/utils/updater/updater.mocha.ts b/src/server/utils/updater/updater.mocha.ts index f51223f41..230b35501 100644 --- a/src/server/utils/updater/updater.mocha.ts +++ b/src/server/utils/updater/updater.mocha.ts @@ -24,7 +24,7 @@ function valueEqual(a: any, b: any) { describe("updater", () => { it("one enter", () => { - var ops: string[] = []; + const ops: string[] = []; updater( [], @@ -47,7 +47,7 @@ describe("updater", () => { }); it("one exit", () => { - var ops: string[] = []; + const ops: string[] = []; updater( [{ name: "A" }], @@ -70,7 +70,7 @@ describe("updater", () => { }); it("enter / exit", () => { - var ops: string[] = []; + const ops: string[] = []; updater( [{ name: "A" }], @@ -93,7 +93,7 @@ describe("updater", () => { }); it("enter / update / exit", () => { - var ops: string[] = []; + const ops: string[] = []; updater( [{ name: "A", value: 1 }, { name: "B", value: 2 }], diff --git a/src/server/utils/updater/updater.ts b/src/server/utils/updater/updater.ts index bfe7f2acf..73b91d860 100644 --- a/src/server/utils/updater/updater.ts +++ b/src/server/utils/updater/updater.ts @@ -38,16 +38,16 @@ export function updater(oldThings: T[], newThings: T[], upd const onUpdate = updatedOptions.onUpdate || noop; const onExit = updatedOptions.onExit || noop; - var initialByKey: Record = {}; + const initialByKey: Record = {}; for (const initialThing of oldThings) { - var initialThingKey = key(initialThing); + const initialThingKey = key(initialThing); if (initialByKey[initialThingKey]) throw new Error(`duplicate key '${initialThingKey}'`); initialByKey[initialThingKey] = initialThing; } for (const newThing of newThings) { - var newThingKey = key(newThing); - var oldThing = initialByKey[newThingKey]; + const newThingKey = key(newThing); + const oldThing = initialByKey[newThingKey]; if (oldThing) { if (!equals(newThing, oldThing)) { onUpdate(newThing, oldThing); @@ -58,7 +58,7 @@ export function updater(oldThings: T[], newThings: T[], upd } } - for (var k in initialByKey) { + for (const k in initialByKey) { if (!hasOwnProperty(initialByKey, k)) continue; onExit(initialByKey[k]); } diff --git a/tslint.json b/tslint.json index 362d1b912..d5c067747 100644 --- a/tslint.json +++ b/tslint.json @@ -81,8 +81,6 @@ "no-empty-interface": false, // disallow empty named interfaces, replace with {} "no-shadowed-variable": false, // disallow variable shadowing "no-unused-expression": false, // disallow unused expressions, currently many "to.be.true" expectations trigger it - "no-var-keyword": false, - "prefer-const": false, // prefer consts where possible instead of lets "variable-name": false, // enforce consistent variable naming "array-type": false // use either T[] or Array for arrays }