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

Introduced new developer experience efficiencies #2702

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 11 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
74 changes: 59 additions & 15 deletions .monorepolint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as fs from "node:fs";
import {
alphabeticalDependencies,
alphabeticalScripts,
fileContents,
packageOrder,
packageEntry,
packageScript,
Expand All @@ -16,7 +17,6 @@ const JS_PACKAGES = []; // projects that use javascript/rollup to build
const MAIN_PACKAGE = "@turf/turf";

const TAPE_PACKAGES = []; // projects that have tape tests
const TYPES_PACKAGES = []; // projects that have types tests
const BENCH_PACKAGES = []; // projects that have benchmarks

// iterate all the packages and figure out what buckets everything falls into
Expand All @@ -35,10 +35,6 @@ glob.sync(path.join(__dirname, "packages", "turf-*")).forEach((pk) => {
if (fs.existsSync(path.join(pk, "test.js"))) {
TAPE_PACKAGES.push(name);
}

if (fs.existsSync(path.join(pk, "types.ts"))) {
TYPES_PACKAGES.push(name);
}
});

const TS_TAPE_PACKAGES = TAPE_PACKAGES.filter(
Expand All @@ -50,6 +46,56 @@ const JS_TAPE_PACKAGES = TAPE_PACKAGES.filter(

export default {
rules: [
fileContents({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://monorepolint.com/docs/rules/standard-tsconfig/ maybe we should use standardTsconfig now instead of fileContents. My biggest issue with the current monorepolint is that we've got hand-managed lists of files. Although most of our packages only use a single file, its definitely unexpected if I add another file and the import doesn't work until it gets added in here (and further extends the proliferation of special cases in this file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can get away with something like this and be a little more forgiving of adding extra files.

{
  "include": ["index.js", "index.ts", "lib/*", "*.d.ts"],
  "exclude": ["index.d.ts"]
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will check this idea out. Thanks 👍

options: {
file: "tsconfig.testTypes.json",
templateFile: "./templates/tsconfig.testTypes.json",
},
includePackages: JS_PACKAGES,
}),
fileContents({
options: {
file: "tsconfig.json",
template: `{
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
`,
},
includePackages: TS_PACKAGES.filter(
(elem) =>
!["@turf/isobands", "@turf/isolines", "@turf/tesselate"].includes(
elem
)
),
}),

// Special treatment for three packages with locally defined .d.ts files for
// untyped Javascript dependencies. Might be possible to remove should those
// libraries be retired / types added to DefinitelyTyped.
fileContents({
options: {
file: "tsconfig.json",
template: `{
"extends": "../../tsconfig.shared.json",
"files": ["index.ts", "marchingsquares.d.ts"]
}
`,
},
includePackages: ["@turf/isobands", "@turf/isolines"],
}),
fileContents({
options: {
file: "tsconfig.json",
template: `{
"extends": "../../tsconfig.shared.json",
"files": ["index.ts", "earcut.d.ts"]
}
`,
},
includePackages: ["@turf/tesselate"],
}),

packageOrder({
options: {
order: [
Expand Down Expand Up @@ -183,37 +229,35 @@ export default {
build: "tsup --config ../../tsup.config.ts",
},
},
includePackages: [...TS_PACKAGES, ...JS_PACKAGES],
includePackages: [MAIN_PACKAGE, ...TS_PACKAGES, ...JS_PACKAGES],
}),

packageScript({
options: {
scripts: {
build:
"tsup --config ../../tsup.config.ts && rollup -c rollup.config.js",
bench: "tsx bench.ts",
"test:tape": "tsx test.ts",
},
},
includePackages: [MAIN_PACKAGE],
includePackages: [...TS_TAPE_PACKAGES, ...JS_TAPE_PACKAGES],
}),

packageScript({
options: {
scripts: {
bench: "tsx bench.ts",
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit",
},
},
includePackages: [...TS_TAPE_PACKAGES, ...JS_TAPE_PACKAGES],
includePackages: TS_PACKAGES,
}),

packageScript({
options: {
scripts: {
"test:types":
"tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts",
"test:types": "tsc -p ./tsconfig.testTypes.json",
},
},
includePackages: TYPES_PACKAGES,
includePackages: JS_PACKAGES,
}),

requireDependency({
Expand Down
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"{projectRoot}/test/**",
"{projectRoot}/types.ts"
],
"dependsOn": ["build"],
"dependsOn": [],
"cache": true
},
"last-checks": {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"lint:eslint": "eslint packages",
"lint:mrl": "mrl check",
"lint:prettier": "prettier --check .",
"postinstall": "husky install",
"preinstall": "npx only-allow pnpm",
"prepare": "husky && lerna run build",
"test": "pnpm run lint && lerna run test && lerna run --scope @turf/turf last-checks"
"prepublishOnly": "lerna run build && lerna run --scope @turf/turf cdnBundle",
"test": "lerna run test"
},
"lint-staged": {
"package.json": [
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-along/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-along/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-angle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@turf/distance": "workspace:^",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-angle/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-area/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-area/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-bbox-clip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@turf/bbox": "workspace:^",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-bbox-clip/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-bbox-polygon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-bbox-polygon/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-bbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-bbox/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-bearing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@turf/destination": "workspace:^",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-bearing/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-bezier-spline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-bezier-spline/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-boolean-clockwise/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-boolean-clockwise/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-boolean-concave/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-boolean-concave/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-boolean-contains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-boolean-contains/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-boolean-crosses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-boolean-crosses/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-boolean-disjoint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-boolean-disjoint/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-boolean-equal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-boolean-equal/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
3 changes: 2 additions & 1 deletion packages/turf-boolean-intersects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"build": "tsup --config ../../tsup.config.ts",
"docs": "tsx ../../scripts/generate-readmes.ts",
"test": "npm-run-all --npm-path npm test:*",
"test:tape": "tsx test.ts"
"test:tape": "tsx test.ts",
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-boolean-intersects/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.shared.json"
"extends": "../../tsconfig.shared.json",
"files": ["index.ts"]
}
Loading