Skip to content

Commit d934feb

Browse files
jacobparisericallammatt-aitken
authored
feature: add no-trigger-core-import (#1175)
* feature: add no-trigger-core-import * fix: handle aliases and limit to exported modules * fix: use longest export map name * fix: support export type and interface * fix: simplify message when export map is needed * feature: fine grained modules for core * fix: add prerequisite lint plugins * fix: why do I have to fix these components again??? * fix: tests * Add eslint config and vscode settings * Create yellow-roses-arrive.md * Remove the vscode linting This is temporary so no one fixes these until we merge the remix branch --------- Co-authored-by: Eric Allam <[email protected]> Co-authored-by: Eric Allam <[email protected]> Co-authored-by: Matt Aitken <[email protected]>
1 parent 7fdedf3 commit d934feb

File tree

17 files changed

+1569
-193
lines changed

17 files changed

+1569
-193
lines changed

.changeset/yellow-roses-arrive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
Add more package exports that can be used from the web app

apps/webapp/.eslintrc

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
{
2-
"extends": ["@remix-run/eslint-config", "@remix-run/eslint-config/node", "prettier"],
3-
"rules": {
4-
"@typescript-eslint/strict-boolean-expressions": [
5-
"error",
6-
{
7-
"allowNullableBoolean": true,
8-
"allowNullableString": true,
9-
"allowNullableNumber": true
2+
"plugins": [
3+
"@trigger.dev/eslint-plugin",
4+
"react-hooks",
5+
"@typescript-eslint/eslint-plugin",
6+
"import"
7+
],
8+
"parser": "@typescript-eslint/parser",
9+
"overrides": [
10+
{
11+
"files": ["*.ts", "*.tsx"],
12+
"rules": {
13+
// Autofixes imports from "@trigger.dev/core" to fine grained modules
14+
"@trigger.dev/no-trigger-core-import": "error",
15+
// Normalize `import type {}` and `import { type }`
16+
"@typescript-eslint/consistent-type-imports": [
17+
"warn",
18+
{
19+
// the "type" annotation can get tangled and cause syntax errors
20+
// during some autofixes, so easier to just turn it off
21+
"prefer": "type-imports",
22+
"disallowTypeAnnotations": true,
23+
"fixStyle": "inline-type-imports"
24+
}
25+
],
26+
// no-trigger-core-import splits imports into multiple lines
27+
// this one merges them back into a single line
28+
// if they still import from the same module
29+
"import/no-duplicates": ["warn", { "prefer-inline": true }],
30+
// lots of undeclared vars, enable this rule if you want to clean them up
31+
"turbo/no-undeclared-env-vars": "off"
1032
}
11-
]
12-
}
33+
}
34+
],
35+
"ignorePatterns": ["seed.js", "seedCloud.ts", "populate.js"]
1336
}

apps/webapp/app/components/primitives/Alert.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@ const Alert = AlertDialogPrimitive.Root;
88

99
const AlertTrigger = AlertDialogPrimitive.Trigger;
1010

11-
const AlertPortal = ({
12-
className,
13-
children,
14-
...props
15-
}: AlertDialogPrimitive.AlertDialogPortalProps) => (
16-
<AlertDialogPrimitive.Portal className={cn(className)} {...props}>
11+
const AlertPortal = ({ children, ...props }: AlertDialogPrimitive.AlertDialogPortalProps) => (
12+
<AlertDialogPrimitive.Portal {...props}>
1713
<div className="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
1814
{children}
1915
</div>

apps/webapp/app/components/primitives/Dialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const Dialog = DialogPrimitive.Root;
1010

1111
const DialogTrigger = DialogPrimitive.Trigger;
1212

13-
const DialogPortal = ({ className, children, ...props }: DialogPrimitive.DialogPortalProps) => (
14-
<DialogPrimitive.Portal className={cn(className)} {...props}>
13+
const DialogPortal = ({ children, ...props }: DialogPrimitive.DialogPortalProps) => (
14+
<DialogPrimitive.Portal {...props}>
1515
<div className="fixed inset-0 z-50 flex items-start justify-center sm:items-center">
1616
{children}
1717
</div>

apps/webapp/app/components/primitives/Sheet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ interface SheetPortalProps
2828
extends SheetPrimitive.DialogPortalProps,
2929
VariantProps<typeof portalVariants> {}
3030

31-
const SheetPortal = ({ position, className, children, ...props }: SheetPortalProps) => (
32-
<SheetPrimitive.Portal className={cn(className)} {...props}>
31+
const SheetPortal = ({ position, children, ...props }: SheetPortalProps) => (
32+
<SheetPrimitive.Portal {...props}>
3333
<div className={portalVariants({ position })}>{children}</div>
3434
</SheetPrimitive.Portal>
3535
);

apps/webapp/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
"@tailwindcss/forms": "^0.5.3",
189189
"@tailwindcss/typography": "^0.5.9",
190190
"@total-typescript/ts-reset": "^0.4.2",
191+
"@trigger.dev/eslint-plugin": "workspace:*",
191192
"@types/bcryptjs": "^2.4.2",
192193
"@types/compression": "^1.7.2",
193194
"@types/eslint": "^8.4.6",
@@ -221,6 +222,9 @@
221222
"esbuild": "^0.15.10",
222223
"eslint": "^8.24.0",
223224
"eslint-config-prettier": "^8.5.0",
225+
"eslint-plugin-import": "^2.29.1",
226+
"eslint-plugin-react-hooks": "^4.6.2",
227+
"eslint-plugin-turbo": "^2.0.4",
224228
"npm-run-all": "^4.1.5",
225229
"postcss-import": "^16.0.1",
226230
"postcss-loader": "^8.1.1",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"@types/node": "18.17.1",
5454
"autoprefixer": "^10.4.12",
5555
"eslint-config-custom": "workspace:*",
56+
"eslint-plugin-turbo": "^2.0.4",
5657
"prettier": "^3.0.0",
5758
"tsx": "^3.7.1",
5859
"turbo": "^1.10.3",

packages/core/package.json

Lines changed: 136 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,70 @@
2121
"require": "./dist/index.js",
2222
"types": "./dist/index.d.ts"
2323
},
24+
"./eventFilterMatches": {
25+
"import": {
26+
"types": "./dist/eventFilterMatches.d.mts",
27+
"default": "./dist/eventFilterMatches.mjs"
28+
},
29+
"require": "./dist/eventFilterMatches.js",
30+
"types": "./dist/eventFilterMatches.d.ts"
31+
},
32+
"./replacements": {
33+
"import": {
34+
"types": "./dist/replacements.d.mts",
35+
"default": "./dist/replacements.mjs"
36+
},
37+
"require": "./dist/replacements.js",
38+
"types": "./dist/replacements.d.ts"
39+
},
40+
"./requestFilterMatches": {
41+
"import": {
42+
"types": "./dist/requestFilterMatches.d.mts",
43+
"default": "./dist/requestFilterMatches.mjs"
44+
},
45+
"require": "./dist/requestFilterMatches.js",
46+
"types": "./dist/requestFilterMatches.d.ts"
47+
},
48+
"./retry": {
49+
"import": {
50+
"types": "./dist/retry.d.mts",
51+
"default": "./dist/retry.mjs"
52+
},
53+
"require": "./dist/retry.js",
54+
"types": "./dist/retry.d.ts"
55+
},
56+
"./utils": {
57+
"import": {
58+
"types": "./dist/utils.d.mts",
59+
"default": "./dist/utils.mjs"
60+
},
61+
"require": "./dist/utils.js",
62+
"types": "./dist/utils.d.ts"
63+
},
64+
"./schemas": {
65+
"import": {
66+
"types": "./dist/schemas/index.d.mts",
67+
"default": "./dist/schemas/index.mjs"
68+
},
69+
"require": "./dist/schemas/index.js",
70+
"types": "./dist/schemas/index.d.ts"
71+
},
72+
"./types": {
73+
"import": {
74+
"types": "./dist/types.d.mts",
75+
"default": "./dist/types.mjs"
76+
},
77+
"require": "./dist/types.js",
78+
"types": "./dist/types.d.ts"
79+
},
80+
"./versions": {
81+
"import": {
82+
"types": "./dist/versions.d.mts",
83+
"default": "./dist/versions.mjs"
84+
},
85+
"require": "./dist/versions.js",
86+
"types": "./dist/versions.d.ts"
87+
},
2488
"./v3": {
2589
"import": {
2690
"types": "./dist/v3/index.d.mts",
@@ -29,6 +93,22 @@
2993
"require": "./dist/v3/index.js",
3094
"types": "./dist/v3/index.d.ts"
3195
},
96+
"./v3/errors": {
97+
"import": {
98+
"types": "./dist/v3/errors.d.mts",
99+
"default": "./dist/v3/errors.mjs"
100+
},
101+
"require": "./dist/v3/errors.js",
102+
"types": "./dist/v3/errors.d.ts"
103+
},
104+
"./v3/logger-api": {
105+
"import": {
106+
"types": "./dist/v3/logger-api.d.mts",
107+
"default": "./dist/v3/logger-api.mjs"
108+
},
109+
"require": "./dist/v3/logger-api.js",
110+
"types": "./dist/v3/logger-api.d.ts"
111+
},
32112
"./v3/otel": {
33113
"import": {
34114
"types": "./dist/v3/otel/index.d.mts",
@@ -37,6 +117,62 @@
37117
"require": "./dist/v3/otel/index.js",
38118
"types": "./dist/v3/otel/index.d.ts"
39119
},
120+
"./v3/semanticInternalAttributes": {
121+
"import": {
122+
"types": "./dist/v3/semanticInternalAttributes.d.mts",
123+
"default": "./dist/v3/semanticInternalAttributes.mjs"
124+
},
125+
"require": "./dist/v3/semanticInternalAttributes.js",
126+
"types": "./dist/v3/semanticInternalAttributes.d.ts"
127+
},
128+
"./v3/utils/durations": {
129+
"import": {
130+
"types": "./dist/v3/utils/durations.d.mts",
131+
"default": "./dist/v3/utils/durations.mjs"
132+
},
133+
"require": "./dist/v3/utils/durations.js",
134+
"types": "./dist/v3/utils/durations.d.ts"
135+
},
136+
"./v3/utils/flattenAttributes": {
137+
"import": {
138+
"types": "./dist/v3/utils/flattenAttributes.d.mts",
139+
"default": "./dist/v3/utils/flattenAttributes.mjs"
140+
},
141+
"require": "./dist/v3/utils/flattenAttributes.js",
142+
"types": "./dist/v3/utils/flattenAttributes.d.ts"
143+
},
144+
"./v3/utils/ioSerialization": {
145+
"import": {
146+
"types": "./dist/v3/utils/ioSerialization.d.mts",
147+
"default": "./dist/v3/utils/ioSerialization.mjs"
148+
},
149+
"require": "./dist/v3/utils/ioSerialization.js",
150+
"types": "./dist/v3/utils/ioSerialization.d.ts"
151+
},
152+
"./v3/utils/omit": {
153+
"import": {
154+
"types": "./dist/v3/utils/omit.d.mts",
155+
"default": "./dist/v3/utils/omit.mjs"
156+
},
157+
"require": "./dist/v3/utils/omit.js",
158+
"types": "./dist/v3/utils/omit.d.ts"
159+
},
160+
"./v3/utils/retries": {
161+
"import": {
162+
"types": "./dist/v3/utils/retries.d.mts",
163+
"default": "./dist/v3/utils/retries.mjs"
164+
},
165+
"require": "./dist/v3/utils/retries.js",
166+
"types": "./dist/v3/utils/retries.d.ts"
167+
},
168+
"./v3/utils/structuredLogger": {
169+
"import": {
170+
"types": "./dist/v3/utils/structuredLogger.d.mts",
171+
"default": "./dist/v3/utils/structuredLogger.mjs"
172+
},
173+
"require": "./dist/v3/utils/structuredLogger.js",
174+
"types": "./dist/v3/utils/structuredLogger.d.ts"
175+
},
40176
"./v3/zodfetch": {
41177
"import": {
42178
"types": "./dist/v3/zodfetch.d.mts",
@@ -77,22 +213,6 @@
77213
"require": "./dist/v3/zodIpc.js",
78214
"types": "./dist/v3/zodIpc.d.ts"
79215
},
80-
"./v3/utils/structuredLogger": {
81-
"import": {
82-
"types": "./dist/v3/utils/structuredLogger.d.mts",
83-
"default": "./dist/v3/utils/structuredLogger.mjs"
84-
},
85-
"require": "./dist/v3/utils/structuredLogger.js",
86-
"types": "./dist/v3/utils/structuredLogger.d.ts"
87-
},
88-
"./v3/utils/durations": {
89-
"import": {
90-
"types": "./dist/v3/utils/durations.d.mts",
91-
"default": "./dist/v3/utils/durations.mjs"
92-
},
93-
"require": "./dist/v3/utils/durations.js",
94-
"types": "./dist/v3/utils/durations.d.ts"
95-
},
96216
"./v3/utils/timers": {
97217
"import": {
98218
"types": "./dist/v3/utils/timers.d.mts",

packages/core/src/index.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,4 @@ export * from "./replacements";
66
export * from "./searchParams";
77
export * from "./eventFilterMatches";
88
export * from "./requestFilterMatches";
9-
10-
export const API_VERSIONS = {
11-
LAZY_LOADED_CACHED_TASKS: "2023-09-29",
12-
SERIALIZED_TASK_OUTPUT: "2023-11-01",
13-
} as const;
14-
15-
export const PLATFORM_FEATURES = {
16-
yieldExecution: API_VERSIONS.LAZY_LOADED_CACHED_TASKS,
17-
lazyLoadedCachedTasks: API_VERSIONS.LAZY_LOADED_CACHED_TASKS,
18-
};
19-
20-
export function supportsFeature<TFeatureName extends keyof typeof PLATFORM_FEATURES>(
21-
featureName: TFeatureName,
22-
version: string
23-
): boolean {
24-
if (version === "unversioned" || version === "unknown") {
25-
return false;
26-
}
27-
28-
const supportedVersion = PLATFORM_FEATURES[featureName];
29-
30-
if (!supportedVersion) {
31-
return false;
32-
}
33-
34-
return version >= supportedVersion;
35-
}
9+
export * from "./versions";

packages/core/src/versions.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export const API_VERSIONS = {
2+
LAZY_LOADED_CACHED_TASKS: "2023-09-29",
3+
SERIALIZED_TASK_OUTPUT: "2023-11-01",
4+
} as const;
5+
6+
export const PLATFORM_FEATURES = {
7+
yieldExecution: API_VERSIONS.LAZY_LOADED_CACHED_TASKS,
8+
lazyLoadedCachedTasks: API_VERSIONS.LAZY_LOADED_CACHED_TASKS,
9+
};
10+
11+
export function supportsFeature<TFeatureName extends keyof typeof PLATFORM_FEATURES>(
12+
featureName: TFeatureName,
13+
version: string
14+
): boolean {
15+
if (version === "unversioned" || version === "unknown") {
16+
return false;
17+
}
18+
19+
const supportedVersion = PLATFORM_FEATURES[featureName];
20+
21+
if (!supportedVersion) {
22+
return false;
23+
}
24+
25+
return version >= supportedVersion;
26+
}

packages/core/tsup.config.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,36 @@ export default defineConfig({
44
...packageOptions,
55
config: "tsconfig.build.json",
66
entry: [
7+
"./src/eventFilterMatches.ts",
78
"./src/index.ts",
9+
"./src/replacements.ts",
10+
"./src/requestFilterMatches.ts",
11+
"./src/retry.ts",
12+
"./src/schemas/index.ts",
13+
"./src/types.ts",
14+
"./src/utils.ts",
15+
"./src/versions.ts",
16+
"./src/v3/dev/index.ts",
17+
"./src/v3/errors.ts",
818
"./src/v3/index.ts",
19+
"./src/v3/logger-api.ts",
920
"./src/v3/otel/index.ts",
21+
"./src/v3/prod/index.ts",
22+
"./src/v3/schemas/index.ts",
23+
"./src/v3/semanticInternalAttributes.ts",
24+
"./src/v3/utils/durations.ts",
25+
"./src/v3/utils/flattenAttributes.ts",
26+
"./src/v3/utils/ioSerialization.ts",
27+
"./src/v3/utils/omit.ts",
28+
"./src/v3/utils/retries.ts",
29+
"./src/v3/utils/structuredLogger.ts",
30+
"./src/v3/workers/index.ts",
31+
"./src/v3/zodfetch.ts",
32+
"./src/v3/zodIpc.ts",
1033
"./src/v3/zodMessageHandler.ts",
1134
"./src/v3/zodNamespace.ts",
1235
"./src/v3/zodSocket.ts",
13-
"./src/v3/zodIpc.ts",
14-
"./src/v3/utils/structuredLogger.ts",
15-
"./src/v3/utils/durations.ts",
1636
"./src/v3/utils/timers.ts",
17-
"./src/v3/dev/index.ts",
18-
"./src/v3/prod/index.ts",
19-
"./src/v3/workers/index.ts",
20-
"./src/v3/zodfetch.ts",
21-
"./src/v3/schemas/index.ts",
2237
],
2338
external: ["node:timers/promises"],
2439
});

0 commit comments

Comments
 (0)