Skip to content

Commit e5afd5c

Browse files
Upgrade typescript, prettier, et al to continue to modernise build environment (#2519)
* Simplify nx config (no point separately caching es and js builds - they both need to be done for any code changes). Fix some no-op type definitions i.e. X extends any, and enforce templated property types as having to extend GeoJsonProperties throughout. * Upgrade typescript. Had to update topojson-* type defs to avoid the P = GeoJsonProperties problem in geojson-rbush. Also fix a couple of floating point precision related issues that eslint now apparently catches! * Retire tslint. * Upgrade eslint and prettier. Add minimal prettier config (defaults have changed) to avoid widespread, minor formatting changes (trailing commas mostly).
1 parent 14a2ac5 commit e5afd5c

File tree

126 files changed

+692
-574
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+692
-574
lines changed

.eslintrc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ const rules = {
1414
module.exports = {
1515
root: true,
1616
ignorePatterns: ["**/dist/**"],
17+
parser: "@typescript-eslint/parser",
1718
plugins: ["@typescript-eslint"],
1819
extends: [
1920
"eslint:recommended",
2021
"plugin:@typescript-eslint/recommended",
21-
"prettier",
22-
"prettier/@typescript-eslint",
22+
"plugin:prettier/recommended",
2323
],
2424
parserOptions: {
2525
ecmaVersion: 6,

.prettierignore

+7
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ packages/turf-directional-mean/test/in/bus_route_utm.json
1010

1111
# is actually output
1212
packages/turf/turf.min.js
13+
14+
# Ignore test fixture json in case intentional line breaks help with coord
15+
# readability.
16+
packages/turf-*/test/in/**
17+
packages/turf-*/test/out/**
18+
packages/turf-*/test/true/**
19+
packages/turf-*/test/false/**

.prettierrc.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"trailingComma": "es5"
3+
}

examples/browser/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />

examples/create-react-app/public/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />

examples/es-modules-single-module/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />

examples/es-modules/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />

nx.json

+1-31
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@
33
"default": {
44
"runner": "nx/tasks-runners/default",
55
"options": {
6-
"cacheableOperations": [
7-
"build",
8-
"build:es",
9-
"build:js",
10-
"test",
11-
"test:tape",
12-
"test:types",
13-
"last-checks",
14-
"last-checks:example",
15-
"last-checks:testjs"
16-
]
6+
"cacheableOperations": ["build", "test", "last-checks"]
177
}
188
}
199
},
@@ -22,31 +12,11 @@
2212
"dependsOn": ["^build"],
2313
"outputs": ["{projectRoot}/dist"]
2414
},
25-
"build:es": {
26-
"dependsOn": ["^build:es"],
27-
"outputs": ["{projectRoot}/dist"]
28-
},
29-
"build:js": {
30-
"dependsOn": ["^build:js"],
31-
"outputs": ["{projectRoot}/dist"]
32-
},
3315
"test": {
3416
"dependsOn": ["^test"]
3517
},
36-
"test:tape": {
37-
"dependsOn": ["^test:tape"]
38-
},
39-
"test:types": {
40-
"dependsOn": ["^test:types"]
41-
},
4218
"last-checks": {
4319
"dependsOn": ["^last-checks"]
44-
},
45-
"last-checks:example": {
46-
"dependsOn": ["^last-checks:example"]
47-
},
48-
"last-checks:testjs": {
49-
"dependsOn": ["^last-checks:testjs"]
5020
}
5121
}
5222
}

package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,19 @@
3939
},
4040
"devDependencies": {
4141
"@types/geojson": "7946.0.8",
42-
"@types/node": "^17.0.21",
43-
"@typescript-eslint/eslint-plugin": "^4.8.0",
44-
"@typescript-eslint/parser": "^4.8.0",
42+
"@types/node": "18.11.9",
43+
"@typescript-eslint/eslint-plugin": "^6.8.0",
44+
"@typescript-eslint/parser": "^6.8.0",
4545
"acorn": "^7.4.1",
4646
"camelcase": "*",
4747
"d3-queue": "*",
4848
"decamelize": "*",
4949
"dependency-tree": "^8.1.2",
5050
"documentation": "^14.0.2",
5151
"es-check": "^7.1.1",
52-
"eslint": "~7.13.0",
53-
"eslint-config-prettier": "^6.15.0",
52+
"eslint": "^8.51.0",
53+
"eslint-config-prettier": "^9.0.0",
54+
"eslint-plugin-prettier": "^5.0.1",
5455
"esm": "^3.2.25",
5556
"fs-extra": "*",
5657
"husky": "^4.2.3",
@@ -60,13 +61,13 @@
6061
"meow": "*",
6162
"monorepolint": "^0.5.0-alpha.20",
6263
"npm-run-all": "^4.1.5",
63-
"prettier": "^2.1.2",
64+
"prettier": "^3.0.3",
6465
"progress": "*",
6566
"rollup": "^2.34.2",
6667
"tape": "^5.7.0",
6768
"ts-node": "^9.0.0",
6869
"tsx": "^3.12.8",
69-
"typescript": "^3.8.3",
70+
"typescript": "^5.2.2",
7071
"yamljs": "*"
7172
}
7273
}

packages/turf-along/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"load-json-file": "*",
5454
"npm-run-all": "*",
5555
"tape": "*",
56-
"tslint": "*",
5756
"tsx": "*",
5857
"typescript": "*"
5958
},

packages/turf-angle/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"load-json-file": "*",
5858
"npm-run-all": "*",
5959
"tape": "*",
60-
"tslint": "*",
6160
"tsx": "*",
6261
"typescript": "*",
6362
"write-json-file": "*"

packages/turf-area/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"load-json-file": "*",
5353
"npm-run-all": "*",
5454
"tape": "*",
55-
"tslint": "*",
5655
"tsx": "*",
5756
"typescript": "*",
5857
"write-json-file": "*"

packages/turf-bbox-clip/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { lineclip, polygonclip } from "./lib/lineclip";
3737
*/
3838
export default function bboxClip<
3939
G extends Polygon | MultiPolygon | LineString | MultiLineString,
40-
P = GeoJsonProperties
40+
P extends GeoJsonProperties = GeoJsonProperties,
4141
>(feature: Feature<G, P> | G, bbox: BBox) {
4242
const geom = getGeom(feature);
4343
const type = geom.type;

packages/turf-bbox-clip/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"load-json-file": "*",
6060
"npm-run-all": "*",
6161
"tape": "*",
62-
"tslint": "*",
6362
"tsx": "*",
6463
"typescript": "*",
6564
"write-json-file": "*"

packages/turf-bbox-polygon/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import { polygon, Id } from "@turf/helpers";
1818
* //addToMap
1919
* var addToMap = [poly]
2020
*/
21-
export default function bboxPolygon<P = GeoJsonProperties>(
21+
export default function bboxPolygon<
22+
P extends GeoJsonProperties = GeoJsonProperties,
23+
>(
2224
bbox: BBox,
2325
options: {
2426
properties?: P;

packages/turf-bbox-polygon/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"benchmark": "*",
5353
"npm-run-all": "*",
5454
"tape": "*",
55-
"tslint": "*",
5655
"tsx": "*",
5756
"typescript": "*"
5857
},

packages/turf-bbox/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"benchmark": "*",
5454
"npm-run-all": "*",
5555
"tape": "*",
56-
"tslint": "*",
5756
"tsx": "*",
5857
"typescript": "*"
5958
},

packages/turf-bearing/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"benchmark": "*",
5151
"npm-run-all": "*",
5252
"tape": "*",
53-
"tslint": "*",
5453
"tsx": "*",
5554
"typescript": "*",
5655
"write-json-file": "*"

packages/turf-bezier-spline/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import Spline from "./lib/spline";
3333
* var addToMap = [line, curved]
3434
* curved.properties = { stroke: '#0F0' };
3535
*/
36-
function bezier<P = GeoJsonProperties>(
36+
function bezier<P extends GeoJsonProperties = GeoJsonProperties>(
3737
line: Feature<LineString> | LineString,
3838
options: {
3939
properties?: P;

packages/turf-bezier-spline/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"load-json-file": "*",
5454
"npm-run-all": "*",
5555
"tape": "*",
56-
"tslint": "*",
5756
"tsx": "*",
5857
"typescript": "*",
5958
"write-json-file": "*"

packages/turf-boolean-clockwise/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"load-json-file": "*",
5959
"npm-run-all": "*",
6060
"tape": "*",
61-
"tslint": "*",
6261
"tsx": "*",
6362
"typescript": "*"
6463
},

packages/turf-boolean-concave/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"load-json-file": "*",
5858
"npm-run-all": "*",
5959
"tape": "*",
60-
"tslint": "*",
6160
"tsx": "*",
6261
"typescript": "*"
6362
},

packages/turf-boolean-contains/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"load-json-file": "*",
6060
"npm-run-all": "*",
6161
"tape": "*",
62-
"tslint": "*",
6362
"tsx": "*",
6463
"typescript": "*"
6564
},

packages/turf-boolean-crosses/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"load-json-file": "*",
5959
"npm-run-all": "*",
6060
"tape": "*",
61-
"tslint": "*",
6261
"tsx": "*",
6362
"typescript": "*"
6463
},

packages/turf-boolean-disjoint/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"load-json-file": "*",
5858
"npm-run-all": "*",
5959
"tape": "*",
60-
"tslint": "*",
6160
"tsx": "*",
6261
"typescript": "*"
6362
},

packages/turf-boolean-equal/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"load-json-file": "*",
6363
"npm-run-all": "*",
6464
"tape": "*",
65-
"tslint": "*",
6665
"tsx": "*",
6766
"typescript": "*"
6867
},

packages/turf-boolean-intersects/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"load-json-file": "*",
5858
"npm-run-all": "*",
5959
"tape": "*",
60-
"tslint": "*",
6160
"tsx": "*",
6261
"typescript": "*"
6362
},

packages/turf-boolean-overlap/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"load-json-file": "*",
6262
"npm-run-all": "*",
6363
"tape": "*",
64-
"tslint": "*",
6564
"tsx": "*",
6665
"typescript": "*"
6766
},

packages/turf-boolean-parallel/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"load-json-file": "*",
5656
"npm-run-all": "*",
5757
"tape": "*",
58-
"tslint": "*",
5958
"tsx": "*",
6059
"typescript": "*",
6160
"write-json-file": "*"

packages/turf-boolean-point-in-polygon/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { getCoord, getGeom } from "@turf/invariant";
3838
*/
3939
export default function booleanPointInPolygon<
4040
G extends Polygon | MultiPolygon,
41-
P = GeoJsonProperties
41+
P extends GeoJsonProperties = GeoJsonProperties,
4242
>(
4343
point: Coord,
4444
polygon: Feature<G, P> | G,

packages/turf-boolean-point-in-polygon/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"benchmark": "*",
5454
"npm-run-all": "*",
5555
"tape": "*",
56-
"tslint": "*",
5756
"tsx": "*",
5857
"typescript": "*"
5958
},

packages/turf-boolean-point-on-line/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"load-json-file": "*",
5555
"npm-run-all": "*",
5656
"tape": "*",
57-
"tslint": "*",
5857
"tsx": "*",
5958
"typescript": "*",
6059
"write-json-file": "*"

packages/turf-boolean-touches/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"load-json-file": "*",
6262
"npm-run-all": "*",
6363
"tape": "*",
64-
"tslint": "*",
6564
"tsx": "*",
6665
"typescript": "*"
6766
},

packages/turf-boolean-valid/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"load-json-file": "*",
6060
"npm-run-all": "*",
6161
"tape": "*",
62-
"tslint": "*",
6362
"tsx": "*",
6463
"typescript": "*"
6564
},

packages/turf-boolean-within/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"load-json-file": "*",
6262
"npm-run-all": "*",
6363
"tape": "*",
64-
"tslint": "*",
6564
"tsx": "*",
6665
"typescript": "*"
6766
},

packages/turf-center-mean/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { isNumber, point, Id } from "@turf/helpers";
2828
* mean.properties['marker-size'] = 'large';
2929
* mean.properties['marker-color'] = '#000';
3030
*/
31-
function centerMean<P = GeoJsonProperties>(
31+
function centerMean<P extends GeoJsonProperties = GeoJsonProperties>(
3232
geojson: any, // To-Do include Typescript AllGeoJSON
3333
options: { properties?: P; bbox?: BBox; id?: Id; weight?: string } = {}
3434
): Feature<Point, P> {

packages/turf-center-mean/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"load-json-file": "*",
6363
"npm-run-all": "*",
6464
"tape": "*",
65-
"tslint": "*",
6665
"tsx": "*",
6766
"typescript": "*",
6867
"write-json-file": "*"

packages/turf-center-median/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"load-json-file": "*",
5858
"npm-run-all": "*",
5959
"tape": "*",
60-
"tslint": "*",
6160
"tsx": "*",
6261
"typescript": "*",
6362
"write-json-file": "*"

packages/turf-center-of-mass/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { coordEach } from "@turf/meta";
2121
* //addToMap
2222
* var addToMap = [polygon, center]
2323
*/
24-
function centerOfMass<P = GeoJsonProperties>(
24+
function centerOfMass<P extends GeoJsonProperties = GeoJsonProperties>(
2525
geojson: any,
2626
options: {
2727
properties?: P;

0 commit comments

Comments
 (0)