Skip to content

Commit

Permalink
Upgrade typescript, prettier, et al to continue to modernise build en…
Browse files Browse the repository at this point in the history
…vironment (#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).
  • Loading branch information
smallsaucepan authored Oct 24, 2023
1 parent 14a2ac5 commit e5afd5c
Show file tree
Hide file tree
Showing 126 changed files with 692 additions and 574 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const rules = {
module.exports = {
root: true,
ignorePatterns: ["**/dist/**"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint",
"plugin:prettier/recommended",
],
parserOptions: {
ecmaVersion: 6,
Expand Down
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ packages/turf-directional-mean/test/in/bus_route_utm.json

# is actually output
packages/turf/turf.min.js

# Ignore test fixture json in case intentional line breaks help with coord
# readability.
packages/turf-*/test/in/**
packages/turf-*/test/out/**
packages/turf-*/test/true/**
packages/turf-*/test/false/**
4 changes: 3 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"trailingComma": "es5"
}
2 changes: 1 addition & 1 deletion examples/browser/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
2 changes: 1 addition & 1 deletion examples/create-react-app/public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
2 changes: 1 addition & 1 deletion examples/es-modules-single-module/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
2 changes: 1 addition & 1 deletion examples/es-modules/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
32 changes: 1 addition & 31 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"build",
"build:es",
"build:js",
"test",
"test:tape",
"test:types",
"last-checks",
"last-checks:example",
"last-checks:testjs"
]
"cacheableOperations": ["build", "test", "last-checks"]
}
}
},
Expand All @@ -22,31 +12,11 @@
"dependsOn": ["^build"],
"outputs": ["{projectRoot}/dist"]
},
"build:es": {
"dependsOn": ["^build:es"],
"outputs": ["{projectRoot}/dist"]
},
"build:js": {
"dependsOn": ["^build:js"],
"outputs": ["{projectRoot}/dist"]
},
"test": {
"dependsOn": ["^test"]
},
"test:tape": {
"dependsOn": ["^test:tape"]
},
"test:types": {
"dependsOn": ["^test:types"]
},
"last-checks": {
"dependsOn": ["^last-checks"]
},
"last-checks:example": {
"dependsOn": ["^last-checks:example"]
},
"last-checks:testjs": {
"dependsOn": ["^last-checks:testjs"]
}
}
}
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,19 @@
},
"devDependencies": {
"@types/geojson": "7946.0.8",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^4.8.0",
"@typescript-eslint/parser": "^4.8.0",
"@types/node": "18.11.9",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"acorn": "^7.4.1",
"camelcase": "*",
"d3-queue": "*",
"decamelize": "*",
"dependency-tree": "^8.1.2",
"documentation": "^14.0.2",
"es-check": "^7.1.1",
"eslint": "~7.13.0",
"eslint-config-prettier": "^6.15.0",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"esm": "^3.2.25",
"fs-extra": "*",
"husky": "^4.2.3",
Expand All @@ -60,13 +61,13 @@
"meow": "*",
"monorepolint": "^0.5.0-alpha.20",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"prettier": "^3.0.3",
"progress": "*",
"rollup": "^2.34.2",
"tape": "^5.7.0",
"ts-node": "^9.0.0",
"tsx": "^3.12.8",
"typescript": "^3.8.3",
"typescript": "^5.2.2",
"yamljs": "*"
}
}
1 change: 0 additions & 1 deletion packages/turf-along/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-angle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"
Expand Down
1 change: 0 additions & 1 deletion packages/turf-area/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"
Expand Down
2 changes: 1 addition & 1 deletion packages/turf-bbox-clip/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { lineclip, polygonclip } from "./lib/lineclip";
*/
export default function bboxClip<
G extends Polygon | MultiPolygon | LineString | MultiLineString,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(feature: Feature<G, P> | G, bbox: BBox) {
const geom = getGeom(feature);
const type = geom.type;
Expand Down
1 change: 0 additions & 1 deletion packages/turf-bbox-clip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"
Expand Down
4 changes: 3 additions & 1 deletion packages/turf-bbox-polygon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import { polygon, Id } from "@turf/helpers";
* //addToMap
* var addToMap = [poly]
*/
export default function bboxPolygon<P = GeoJsonProperties>(
export default function bboxPolygon<
P extends GeoJsonProperties = GeoJsonProperties,
>(
bbox: BBox,
options: {
properties?: P;
Expand Down
1 change: 0 additions & 1 deletion packages/turf-bbox-polygon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-bbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-bearing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"
Expand Down
2 changes: 1 addition & 1 deletion packages/turf-bezier-spline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Spline from "./lib/spline";
* var addToMap = [line, curved]
* curved.properties = { stroke: '#0F0' };
*/
function bezier<P = GeoJsonProperties>(
function bezier<P extends GeoJsonProperties = GeoJsonProperties>(
line: Feature<LineString> | LineString,
options: {
properties?: P;
Expand Down
1 change: 0 additions & 1 deletion packages/turf-bezier-spline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-clockwise/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-concave/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-contains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-crosses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-disjoint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-equal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-intersects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-overlap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-parallel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"
Expand Down
2 changes: 1 addition & 1 deletion packages/turf-boolean-point-in-polygon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { getCoord, getGeom } from "@turf/invariant";
*/
export default function booleanPointInPolygon<
G extends Polygon | MultiPolygon,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
point: Coord,
polygon: Feature<G, P> | G,
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-point-in-polygon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-point-on-line/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-touches/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-valid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-within/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/turf-center-mean/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { isNumber, point, Id } from "@turf/helpers";
* mean.properties['marker-size'] = 'large';
* mean.properties['marker-color'] = '#000';
*/
function centerMean<P = GeoJsonProperties>(
function centerMean<P extends GeoJsonProperties = GeoJsonProperties>(
geojson: any, // To-Do include Typescript AllGeoJSON
options: { properties?: P; bbox?: BBox; id?: Id; weight?: string } = {}
): Feature<Point, P> {
Expand Down
1 change: 0 additions & 1 deletion packages/turf-center-mean/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"
Expand Down
1 change: 0 additions & 1 deletion packages/turf-center-median/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"
Expand Down
2 changes: 1 addition & 1 deletion packages/turf-center-of-mass/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { coordEach } from "@turf/meta";
* //addToMap
* var addToMap = [polygon, center]
*/
function centerOfMass<P = GeoJsonProperties>(
function centerOfMass<P extends GeoJsonProperties = GeoJsonProperties>(
geojson: any,
options: {
properties?: P;
Expand Down
Loading

0 comments on commit e5afd5c

Please sign in to comment.