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

add linting to improve maintainability #123

Merged
merged 7 commits into from
Jan 23, 2024
Merged
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
228 changes: 228 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"source": "src/index.ts",
"types": "dist/index.d.ts",
"devDependencies": {
"@biomejs/biome": "^1.5.3",
"@types/mapbox__point-geometry": "^0.1.2",
"@types/mapbox__vector-tile": "^1.3.0",
"@types/node": "^16.18.74",
Expand Down
24 changes: 12 additions & 12 deletions src/attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class StringAttr<T extends string = string> {

constructor(c: AttrOption<T> | undefined, defaultValue: T) {
this.str = c ?? defaultValue;
this.per_feature = typeof this.str == "function" && this.str.length == 2;
this.per_feature = typeof this.str === "function" && this.str.length === 2;
}

public get(z: number, f?: Feature): T {
Expand All @@ -24,14 +24,14 @@ export class NumberAttr {
value: AttrOption<number>;
per_feature: boolean;

constructor(c: AttrOption<number> | undefined, defaultValue: number = 1) {
constructor(c: AttrOption<number> | undefined, defaultValue = 1) {
this.value = c ?? defaultValue;
this.per_feature =
typeof this.value == "function" && this.value.length == 2;
typeof this.value === "function" && this.value.length === 2;
}

public get(z: number, f?: Feature): number {
if (typeof this.value == "function") {
if (typeof this.value === "function") {
return this.value(z, f);
} else {
return this.value;
Expand All @@ -57,12 +57,12 @@ export class TextAttr {
let retval: string | undefined;

let label_props: string[];
if (typeof this.label_props == "function") {
if (typeof this.label_props === "function") {
label_props = this.label_props(z, f);
} else {
label_props = this.label_props;
}
for (let property of label_props) {
for (const property of label_props) {
if (
f.props.hasOwnProperty(property) &&
typeof f.props[property] === "string"
Expand Down Expand Up @@ -124,7 +124,7 @@ export class FontAttr {
return this.font;
}
} else {
var style = "";
let style = "";
if (this.style) {
if (typeof this.style === "function") {
style = this.style(z, f) + " ";
Expand All @@ -133,7 +133,7 @@ export class FontAttr {
}
}

var weight = "";
let weight = "";
if (this.weight) {
if (typeof this.weight === "function") {
weight = this.weight(z, f) + " ";
Expand All @@ -142,14 +142,14 @@ export class FontAttr {
}
}

var size;
let size;
if (typeof this.size === "function") {
size = this.size(z, f);
} else {
size = this.size;
}

var family;
let family;
if (typeof this.family === "function") {
family = this.family(z, f);
} else {
Expand All @@ -168,11 +168,11 @@ export class ArrayAttr<T = number> {
constructor(c: AttrOption<T[]>, defaultValue: T[] = []) {
this.value = c ?? defaultValue;
this.per_feature =
typeof this.value == "function" && this.value.length == 2;
typeof this.value === "function" && this.value.length === 2;
}

public get(z: number, f?: Feature): T[] {
if (typeof this.value == "function") {
if (typeof this.value === "function") {
return this.value(z, f);
} else {
return this.value;
Expand Down
Loading
Loading