Skip to content

Commit 7997ffe

Browse files
committed
Simplified MRL config significantly by treating almost all TS and JS packages the same. Only exception now is @turf/turf.
Run tsc static type checking in all packages (except @turf/turf), even the JS ones. It's a no-op for JS, though standardises our package structure somewhat. Added a bunch of standard devDependencies to all projects including typescript, tslib, bench, tape, npm-run-all. Same rationale as above. Upgraded to typescript 5.5.4. Retired types.ts tests as most of them weren't adding much value any more now that we use tsc --noEmit to type check TS code.
1 parent 2fde264 commit 7997ffe

File tree

136 files changed

+244
-1049
lines changed

Some content is hidden

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

136 files changed

+244
-1049
lines changed

.monorepolint.config.mjs

Lines changed: 21 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
// @ts-check
2-
import * as path from "node:path";
3-
import { glob } from "glob";
4-
import * as fs from "node:fs";
52
import {
63
alphabeticalDependencies,
74
alphabeticalScripts,
@@ -12,62 +9,19 @@ import {
129
requireDependency,
1310
} from "@monorepolint/rules";
1411

15-
const TS_PACKAGES = []; // projects that use typescript to build
16-
const JS_PACKAGES = []; // projects that use javascript/rollup to build
1712
const MAIN_PACKAGE = "@turf/turf";
1813

19-
const TAPE_PACKAGES = []; // projects that have tape tests
20-
const BENCH_PACKAGES = []; // projects that have benchmarks
21-
22-
// iterate all the packages and figure out what buckets everything falls into
23-
const __dirname = new URL(".", import.meta.url).pathname;
24-
glob.sync(path.join(__dirname, "packages", "turf-*")).forEach((pk) => {
25-
const name = JSON.parse(
26-
fs.readFileSync(path.join(pk, "package.json"), "utf8")
27-
).name;
28-
29-
if (fs.existsSync(path.join(pk, "index.ts"))) {
30-
TS_PACKAGES.push(name);
31-
} else {
32-
JS_PACKAGES.push(name);
33-
}
34-
35-
if (fs.existsSync(path.join(pk, "test.js"))) {
36-
TAPE_PACKAGES.push(name);
37-
}
38-
});
39-
40-
const TS_TAPE_PACKAGES = TAPE_PACKAGES.filter(
41-
(pkg) => -1 !== TS_PACKAGES.indexOf(pkg)
42-
);
43-
const JS_TAPE_PACKAGES = TAPE_PACKAGES.filter(
44-
(pkg) => -1 !== JS_PACKAGES.indexOf(pkg)
45-
);
46-
4714
export default {
4815
rules: [
49-
fileContents({
50-
options: {
51-
file: "tsconfig.testTypes.json",
52-
templateFile: "./templates/tsconfig.testTypes.json",
53-
},
54-
includePackages: JS_PACKAGES,
55-
}),
5616
fileContents({
5717
options: {
5818
file: "tsconfig.json",
5919
template: `{
60-
"extends": "../../tsconfig.shared.json",
61-
"files": ["index.ts"]
20+
"extends": "../../tsconfig.shared.json"
6221
}
6322
`,
6423
},
65-
includePackages: TS_PACKAGES.filter(
66-
(elem) =>
67-
!["@turf/isobands", "@turf/isolines", "@turf/tesselate"].includes(
68-
elem
69-
)
70-
),
24+
excludePackages: ["@turf/isobands", "@turf/isolines", "@turf/tesselate"],
7125
}),
7226

7327
// Special treatment for three packages with locally defined .d.ts files for
@@ -132,41 +86,8 @@ export default {
13286
}),
13387
alphabeticalDependencies({ includeWorkspaceRoot: true }),
13488
alphabeticalScripts({ includeWorkspaceRoot: true }),
135-
packageEntry({
136-
options: {
137-
entries: {
138-
type: "module",
139-
main: "dist/cjs/index.cjs",
140-
module: "dist/esm/index.js",
141-
types: "dist/esm/index.d.ts",
142-
sideEffects: false,
143-
publishConfig: {
144-
access: "public",
145-
},
146-
// @turf/turf is commonly consumed through CDNs, moving this output file is a breaking change for anyone
147-
// who has a hardcoded reference to this specific file, instead of letting the CDN pick the path.
148-
// Example of a URL that will break: https://unpkg.com/@turf/turf/dist/turf.min.js
149-
// Example of a URL that will keep working: https://unpkg.com/@turf/turf
150-
browser: "turf.min.js",
151-
files: ["dist", "turf.min.js"],
152-
exports: {
153-
"./package.json": "./package.json",
154-
".": {
155-
import: {
156-
types: "./dist/esm/index.d.ts",
157-
default: "./dist/esm/index.js",
158-
},
159-
require: {
160-
types: "./dist/cjs/index.d.cts",
161-
default: "./dist/cjs/index.cjs",
162-
},
163-
},
164-
},
165-
},
166-
},
167-
includePackages: [MAIN_PACKAGE],
168-
}),
16989

90+
// All packages ...
17091
packageEntry({
17192
options: {
17293
entries: {
@@ -175,6 +96,7 @@ export default {
17596
module: "dist/esm/index.js",
17697
types: "dist/esm/index.d.ts",
17798
sideEffects: false,
99+
funding: "https://opencollective.com/turf",
178100
publishConfig: {
179101
access: "public",
180102
},
@@ -193,97 +115,67 @@ export default {
193115
},
194116
},
195117
},
196-
includePackages: [...TS_PACKAGES, ...JS_PACKAGES],
197118
}),
198-
119+
// All except @turf/turf
199120
packageEntry({
200121
options: {
201122
entries: {
202123
files: ["dist"],
203124
},
204125
},
205-
includePackages: [...TS_PACKAGES, ...JS_PACKAGES],
126+
excludePackages: [MAIN_PACKAGE],
206127
}),
207-
128+
// @turf/turf only
208129
packageEntry({
209130
options: {
210131
entries: {
211-
funding: "https://opencollective.com/turf",
132+
// @turf/turf is commonly consumed through CDNs, moving this output file is a breaking change for anyone
133+
// who has a hardcoded reference to this specific file, instead of letting the CDN pick the path.
134+
// Example of a URL that will break: https://unpkg.com/@turf/turf/dist/turf.min.js
135+
// Example of a URL that will keep working: https://unpkg.com/@turf/turf
136+
browser: "turf.min.js",
137+
files: ["dist", "turf.min.js"],
212138
},
213139
},
140+
includePackages: [MAIN_PACKAGE],
214141
}),
215142

216143
packageScript({
217144
options: {
218145
scripts: {
219146
docs: "tsx ../../scripts/generate-readmes.ts",
220147
test: "npm-run-all --npm-path npm test:*",
221-
},
222-
},
223-
excludePackages: [MAIN_PACKAGE],
224-
}),
225-
226-
packageScript({
227-
options: {
228-
scripts: {
229-
build: "tsup --config ../../tsup.config.ts",
230-
},
231-
},
232-
includePackages: [MAIN_PACKAGE, ...TS_PACKAGES, ...JS_PACKAGES],
233-
}),
234-
235-
packageScript({
236-
options: {
237-
scripts: {
238-
bench: "tsx bench.ts",
239148
"test:tape": "tsx test.ts",
240-
},
241-
},
242-
includePackages: [...TS_TAPE_PACKAGES, ...JS_TAPE_PACKAGES],
243-
}),
244-
245-
packageScript({
246-
options: {
247-
scripts: {
248149
"test:types": "tsc --noEmit",
249150
},
250151
},
251-
includePackages: TS_PACKAGES,
152+
excludePackages: [MAIN_PACKAGE],
252153
}),
253154

254155
packageScript({
255156
options: {
256157
scripts: {
257-
"test:types": "tsc -p ./tsconfig.testTypes.json",
258-
},
259-
},
260-
includePackages: JS_PACKAGES,
261-
}),
262-
263-
requireDependency({
264-
options: {
265-
devDependencies: {
266-
benchmark: "^2.1.4",
267-
"npm-run-all": "^4.1.5",
268-
tape: "^5.7.2",
269-
tsx: "^4.6.2",
158+
build: "tsup --config ../../tsup.config.ts",
270159
},
271160
},
272-
includePackages: [...TS_PACKAGES, ...JS_PACKAGES],
273161
}),
274162

275163
requireDependency({
276164
options: {
277165
dependencies: {
166+
"@types/geojson": "^7946.0.10",
278167
tslib: "^2.6.2",
279168
},
280169
devDependencies: {
281170
"@types/benchmark": "^2.1.5",
282171
"@types/tape": "^4.2.32",
172+
benchmark: "^2.1.4",
173+
"npm-run-all": "^4.1.5",
174+
tape: "^5.7.2",
175+
tsx: "^4.6.2",
283176
typescript: "^5.5.4",
284177
},
285178
},
286-
includePackages: TS_PACKAGES,
287179
}),
288180

289181
requireDependency({
@@ -294,14 +186,5 @@ export default {
294186
},
295187
includePackages: [MAIN_PACKAGE],
296188
}),
297-
298-
requireDependency({
299-
options: {
300-
dependencies: {
301-
"@types/geojson": "^7946.0.10",
302-
},
303-
},
304-
includePackages: [MAIN_PACKAGE, ...TS_PACKAGES, ...JS_PACKAGES],
305-
}),
306189
],
307190
};

packages/turf-along/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}

packages/turf-angle/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}

packages/turf-area/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}

packages/turf-bbox-clip/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}

packages/turf-bbox/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}

packages/turf-bearing/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "../../tsconfig.shared.json",
3-
"files": ["index.ts"]
2+
"extends": "../../tsconfig.shared.json"
43
}

0 commit comments

Comments
 (0)