Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Switch to eslint.
Browse files Browse the repository at this point in the history
Remove tslint configuration and directives.

Signed-off-by: Roberto Raggi <roberto.raggi@here.com>
  • Loading branch information
robertoraggi committed Aug 18, 2020
1 parent 095dcdd commit be5144e
Show file tree
Hide file tree
Showing 254 changed files with 214 additions and 963 deletions.
17 changes: 17 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-function-return-type": "off",

"import/order": ["error", { "alphabetize": { "order": "asc", "caseInsensitive": true } }],

"max-len": [
"error",
{
"code": 100,
"tabWidth": 4,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true,
"ignoreUrls": true,
"ignoreComments": true
}
],

"no-console": ["error"],

"accessor-pairs": "off",
"generator-star-spacing": "off",
"handle-callback-err": "off",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
- name: Reset git settings (Windows)
# Global git config on windows has autocrlf enabled.
# This breaks lot of checks, including tslint.
# This breaks lot of checks, including eslint.
run: git config --global core.autocrlf false
if: matrix.os == 'windows-latest'
- uses: actions/checkout@v1
Expand Down
6 changes: 0 additions & 6 deletions @here/harp-atlas-tools/src/ColorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class ColorUtils {
* @returns color red component value in between 0 to 255.
*/
static red(value: number): number {
// tslint:disable-next-line: no-bitwise
return value >> 24 >= 0 ? value >> 24 : 256 + (value >> 24);
}

Expand All @@ -35,7 +34,6 @@ export class ColorUtils {
* @returns color green component value in between 0 to 255.
*/
static green(value: number): number {
// tslint:disable-next-line: no-bitwise
return (value >> 16) & 255;
}

Expand All @@ -46,7 +44,6 @@ export class ColorUtils {
* @returns color blue component value in between 0 to 255.
*/
static blue(value: number): number {
// tslint:disable-next-line: no-bitwise
return (value >> 8) & 255;
}

Expand All @@ -57,7 +54,6 @@ export class ColorUtils {
* @returns color alpha component value in between 0 to 255.
*/
static alpha(value: number): number {
// tslint:disable-next-line: no-bitwise
return value & 255;
}

Expand All @@ -68,7 +64,6 @@ export class ColorUtils {
* @returns 32-bit coded integer color value.
*/
static rgbaToInt(c: RGBA): number {
// tslint:disable-next-line: no-bitwise
return ((c.a & 255) << 24) + (((c.b & 255) << 16) + ((c.g & 255) << 8) + (c.r & 255));
}

Expand Down Expand Up @@ -135,7 +130,6 @@ export class ColorUtils {
const factor = ColorUtils.alpha(fg) / 255;
const color: RGBA = {
r: Math.min(Math.floor(ColorUtils.red(bg) * (1 - factor) + ColorUtils.red(fg)), 255),
// tslint:disable-next-line: max-line-length
g: Math.min(
Math.floor(ColorUtils.green(bg) * (1 - factor) + ColorUtils.green(fg)),
255
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-atlas-tools/src/FileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

import * as fileSystem from "fs";
import * as mkpath from "mkpath";
import * as path from "path";
import * as mkpath from "mkpath";

/**
* Describes possible image formats.
Expand Down
4 changes: 1 addition & 3 deletions @here/harp-atlas-tools/src/ImageVectorCoders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class ImageVectorDecoderConstructor implements ImageDecoderConstructor {

async load(filePath: string): Promise<ImageDecoder> {
// No @types for this module
// tslint:disable:no-var-requires
const svg2png = require("svg2png");
const fileBuffer: Buffer = await FileSystem.readFile(filePath);
const pngBuffer: Buffer = await svg2png(
Expand All @@ -45,8 +44,7 @@ export class ImageVectorEncoderConstructor implements ImageEncoderConstructor {
create(width: number, height: number): Promise<ImageEncoder> {
// We do not support writing to blank vector file so use bitmap encoder
// instead as fallback support.
// tslint:disable-next-line: max-line-length
const bitmapEncoderCtor: ImageBitmapEncoderConstructor = new ImageBitmapEncoderConstructor();
const bitmapEncoderCtor = new ImageBitmapEncoderConstructor();
return bitmapEncoderCtor.create(width, height);
}
}
Expand Down
9 changes: 2 additions & 7 deletions @here/harp-atlas-tools/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

/* eslint-disable no-console */

export enum LogLevel {
DEBUG,
INFO,
Expand All @@ -28,19 +30,15 @@ class LoggerVerbose implements Logger {
const paramsToShow = optionalParams.length ? optionalParams : "";
switch (level) {
case LogLevel.DEBUG:
// tslint:disable-next-line: no-console
console.debug(msg, paramsToShow);
break;
case LogLevel.WARN:
// tslint:disable-next-line: no-console
console.warn(msg, paramsToShow);
break;
case LogLevel.ERROR:
// tslint:disable-next-line: no-console
console.error(msg, paramsToShow);
break;
default:
// tslint:disable-next-line: no-console
console.info(msg, paramsToShow);
break;
}
Expand All @@ -51,13 +49,10 @@ class LoggerCritical implements Logger {
log(level: LogLevel, msg?: any, ...optionalParams: any[]) {
const paramsToShow = optionalParams.length ? optionalParams : "";
if (level === LogLevel.INFO) {
// tslint:disable-next-line: no-console
console.info(msg, paramsToShow);
} else if (level === LogLevel.WARN) {
// tslint:disable-next-line: no-console
console.warn(msg, paramsToShow);
} else if (level === LogLevel.ERROR) {
// tslint:disable-next-line: no-console
console.error(msg, paramsToShow);
}
}
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-atlas-tools/src/cli-atlas-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

import * as program from "commander";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import * as program from "commander";
import { AtlasOptions, generateSpritesAtlas } from "./AtlasGenerator";
import { getLogger, Logger, LogLevel } from "./Logger";

Expand Down
2 changes: 1 addition & 1 deletion @here/harp-atlas-tools/src/cli-sprites-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

import * as program from "commander";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import * as program from "commander";
import { generateSprites, ProcessingOptions } from "./AtlasGenerator";
import { getLogger, Logger, LogLevel } from "./Logger";

Expand Down
2 changes: 0 additions & 2 deletions @here/harp-datasource-protocol/lib/ColorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ const SHIFT_RED: number = 16;
const SHIFT_GREEN: number = 8;
const SHIFT_BLUE: number = 0;

// tslint:disable: no-bitwise
// Allow bitwise operations for colors decoding

// tslint:disable-next-line: no-bitwise
const HEX_FULL_CHANNEL: number = 0xff;
const HEX_RGB_MASK: number = 0xffffff;
const HEX_TRGB_MASK: number = 0xffffffff;
Expand Down
4 changes: 0 additions & 4 deletions @here/harp-datasource-protocol/lib/DecodedTile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,17 +423,13 @@ export function getFeatureText(
if (technique.text !== undefined) {
return evaluateTechniqueAttr(context, technique.text);
}
// tslint:disable-next-line: deprecation
if (technique.label !== undefined) {
// tslint:disable-next-line: deprecation
propName = evaluateTechniqueAttr(context, technique.label)!;
if (typeof propName !== "string") {
return undefined;
}
}
// tslint:disable-next-line: deprecation
useAbbreviation = technique.useAbbreviation;
// tslint:disable-next-line: deprecation
useIsoCode = technique.useIsoCode;
}

Expand Down
8 changes: 2 additions & 6 deletions @here/harp-datasource-protocol/lib/Expr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import * as THREE from "three";
import { Env, Value } from "./Env";
import { ExprEvaluator, ExprEvaluatorContext, OperatorDescriptor } from "./ExprEvaluator";
import { ExprInstantiator, InstantiationContext } from "./ExprInstantiator";
Expand All @@ -13,11 +14,10 @@ import {
interpolatedPropertyDefinitionToJsonExpr,
isInterpolatedPropertyDefinition
} from "./InterpolatedPropertyDefs";
import { Definitions } from "./Theme";

import * as THREE from "three";
import { Pixels } from "./Pixels";
import { RGBA } from "./RGBA";
import { Definitions } from "./Theme";

export * from "./Env";

Expand Down Expand Up @@ -216,13 +216,11 @@ export enum ExprScope {
Dynamic
}

// tslint:disable:max-line-length
/**
* Abstract class representing the
* {@link https://github.com/heremaps/harp.gl/blob/master/%40here/harp-datasource-protocol/StyleExpressions.md | style expressions}
* used in {@link Theme}.
*/
// tslint:enable:max-line-length
export abstract class Expr {
/**
* Tests of given value is an {@link Expr}.
Expand All @@ -246,7 +244,6 @@ export abstract class Expr {
return expr;
}

// tslint:disable:max-line-length
/**
* Creates a style expression from JSON.
*
Expand All @@ -266,7 +263,6 @@ export abstract class Expr {
* ]);
* ```
*/
// tslint:enable:max-line-length
static fromJSON(
json: JsonValue,
definitions?: Definitions,
Expand Down
7 changes: 2 additions & 5 deletions @here/harp-datasource-protocol/lib/ExprEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import * as THREE from "three";
import {
BooleanLiteralExpr,
CallExpr,
Expand Down Expand Up @@ -38,10 +39,8 @@ import { ObjectOperators } from "./operators/ObjectOperators";
import { StringOperators } from "./operators/StringOperators";
import { TypeOperators } from "./operators/TypeOperators";
import { VectorOperators } from "./operators/VectorOperators";
import { RGBA } from "./RGBA";

import * as THREE from "three";
import { Pixels } from "./Pixels";
import { RGBA } from "./RGBA";

export interface OperatorDescriptor {
/**
Expand Down Expand Up @@ -326,7 +325,6 @@ export class ExprEvaluator implements ExprVisitor<Value, ExprEvaluatorContext> {
if (firstDynamicCondition !== -1) {
let branches: Array<[Expr, Expr]> | undefined;

// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < match.branches.length; ++i) {
const [condition, body] = match.branches[i];

Expand Down Expand Up @@ -413,7 +411,6 @@ export class ExprEvaluator implements ExprVisitor<Value, ExprEvaluatorContext> {
return new StepExpr(
context.wrapValue(input),
context.wrapValue(defaultValue),
// tslint:disable-next-line: no-shadowed-variable
expr.stops.map(([key, value]) => {
const v = context.evaluate(value);
return [key, context.wrapValue(v)];
Expand Down
3 changes: 1 addition & 2 deletions @here/harp-datasource-protocol/lib/ExprInstantiator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Env } from "./Env";
import {
BooleanLiteralExpr,
CallExpr,
Expand All @@ -24,8 +25,6 @@ import {
VarExpr
} from "./Expr";

import { Env } from "./Env";

export interface InstantiationContext {
/**
* The {@link Env} used to lookup for names.
Expand Down
3 changes: 1 addition & 2 deletions @here/harp-datasource-protocol/lib/ExprPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Value } from "./Env";
import {
BooleanLiteralExpr,
CallExpr,
Expand All @@ -21,8 +22,6 @@ import {
VarExpr
} from "./Expr";

import { Value } from "./Env";

/**
* [[ExprPool]] maintains a set of unique interned {@link Expr} objects.
*
Expand Down
1 change: 0 additions & 1 deletion @here/harp-datasource-protocol/lib/RGBA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export class RGBA {
* Returns this color encoded as JSON literal.
*/
toJSON() {
// tslint:disable-next-line: no-bitwise
return `rgba(${(this.r * 255) << 0}, ${(this.g * 255) << 0}, ${(this.b * 255) << 0}, ${
this.a
})`;
Expand Down
3 changes: 1 addition & 2 deletions @here/harp-datasource-protocol/lib/StringEncodedNumeral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { assert } from "@here/harp-utils";
import { ColorUtils } from "./ColorUtils";

//@ts-ignore
import { parseCSSColor } from "csscolorparser";
import { ColorUtils } from "./ColorUtils";

/**
* Enumeration of supported string encoded numerals.
Expand Down
4 changes: 1 addition & 3 deletions @here/harp-datasource-protocol/lib/StyleSetEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ class OptimizedSubSetKey {

private updateKey() {
if (this.layer !== undefined) {
// tslint:disable-next-line:prefer-conditional-expression
if (this.geometryType !== undefined) {
this.key = `${this.layer}:${this.geometryType}`;
} else {
Expand Down Expand Up @@ -530,8 +529,7 @@ export class StyleSetEvaluator {
try {
style._whenExpr = Array.isArray(style.when)
? Expr.fromJSON(style.when, this.m_definitions, this.m_definitionExprCache)
: // tslint:disable-next-line: deprecation
Expr.parse(style.when);
: Expr.parse(style.when);

// search for usages of '$layer' and any other
// special symbol that can be used to speed up the evaluation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@
* SPDX-License-Identifier: Apache-2.0
*/

import * as THREE from "three";
import { CallExpr } from "../Expr";
import { ExprEvaluatorContext, OperatorDescriptorMap } from "../ExprEvaluator";

import * as THREE from "three";

const operators = {
"^": {
call: (context: ExprEvaluatorContext, call: CallExpr) => {
const a = context.evaluate(call.args[0]);
const b = context.evaluate(call.args[1]);
if (typeof a !== "number" || typeof b !== "number") {
// tslint:disable-next-line: max-line-length
throw new Error(
`invalid operands '${typeof a}' and '${typeof b}' for operator '^'`
);
Expand Down Expand Up @@ -51,7 +49,6 @@ const operators = {
const a = context.evaluate(call.args[0]);
const b = context.evaluate(call.args[1]);
if (typeof a !== "number" || typeof b !== "number") {
// tslint:disable-next-line: max-line-length
throw new Error(
`invalid operands '${typeof a}' and '${typeof b}' for operator '/'`
);
Expand All @@ -65,7 +62,6 @@ const operators = {
const a = context.evaluate(call.args[0]);
const b = context.evaluate(call.args[1]);
if (typeof a !== "number" || typeof b !== "number") {
// tslint:disable-next-line: max-line-length
throw new Error(
`invalid operands '${typeof a}' and '${typeof b}' for operator '%'`
);
Expand Down
Loading

0 comments on commit be5144e

Please sign in to comment.