typebulb 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -17
- package/description.md +1 -1
- package/dist/agents/claude/client.js +343 -206
- package/dist/agents/claude/styles.css +3 -21
- package/dist/ai/aiProvider.d.ts +59 -0
- package/dist/ai/aiProvider.d.ts.map +1 -0
- package/dist/ai/aiProvider.js +109 -0
- package/dist/ai/aiProvider.js.map +1 -0
- package/dist/ai/aiProviders.d.ts +28 -0
- package/dist/ai/aiProviders.d.ts.map +1 -0
- package/dist/ai/aiProviders.js +47 -0
- package/dist/ai/aiProviders.js.map +1 -0
- package/dist/ai/chat.d.ts +32 -0
- package/dist/ai/chat.d.ts.map +1 -0
- package/dist/ai/chat.js +5 -0
- package/dist/ai/chat.js.map +1 -0
- package/dist/ai/index.d.ts +9 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +11 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/protocol.d.ts +18 -0
- package/dist/ai/protocol.d.ts.map +1 -0
- package/dist/ai/protocol.js +3 -0
- package/dist/ai/protocol.js.map +1 -0
- package/dist/ai/providers/anthropic.d.ts +123 -0
- package/dist/ai/providers/anthropic.d.ts.map +1 -0
- package/dist/ai/providers/anthropic.js +130 -0
- package/dist/ai/providers/anthropic.js.map +1 -0
- package/dist/ai/providers/gemini.d.ts +62 -0
- package/dist/ai/providers/gemini.d.ts.map +1 -0
- package/dist/ai/providers/gemini.js +136 -0
- package/dist/ai/providers/gemini.js.map +1 -0
- package/dist/ai/providers/openAI.d.ts +146 -0
- package/dist/ai/providers/openAI.d.ts.map +1 -0
- package/dist/ai/providers/openAI.js +127 -0
- package/dist/ai/providers/openAI.js.map +1 -0
- package/dist/ai/providers/openRouter.d.ts +65 -0
- package/dist/ai/providers/openRouter.d.ts.map +1 -0
- package/dist/ai/providers/openRouter.js +82 -0
- package/dist/ai/providers/openRouter.js.map +1 -0
- package/dist/ai/sseParser.d.ts +32 -0
- package/dist/ai/sseParser.d.ts.map +1 -0
- package/dist/ai/sseParser.js +121 -0
- package/dist/ai/sseParser.js.map +1 -0
- package/dist/ai/stream.d.ts +20 -0
- package/dist/ai/stream.d.ts.map +1 -0
- package/dist/ai/stream.js +6 -0
- package/dist/ai/stream.js.map +1 -0
- package/dist/dts/cache.d.ts +30 -0
- package/dist/dts/cache.d.ts.map +1 -0
- package/dist/dts/cache.js +2 -0
- package/dist/dts/cache.js.map +1 -0
- package/dist/dts/definitelyTypedProvider.d.ts +20 -0
- package/dist/dts/definitelyTypedProvider.d.ts.map +1 -0
- package/dist/dts/definitelyTypedProvider.js +93 -0
- package/dist/dts/definitelyTypedProvider.js.map +1 -0
- package/dist/dts/dtsConfig.d.ts +12 -0
- package/dist/dts/dtsConfig.d.ts.map +1 -0
- package/dist/dts/dtsConfig.js +24 -0
- package/dist/dts/dtsConfig.js.map +1 -0
- package/dist/dts/dtsResolver.d.ts +63 -0
- package/dist/dts/dtsResolver.d.ts.map +1 -0
- package/dist/dts/dtsResolver.js +272 -0
- package/dist/dts/dtsResolver.js.map +1 -0
- package/dist/dts/fetchDts.d.ts +13 -0
- package/dist/dts/fetchDts.d.ts.map +1 -0
- package/dist/dts/fetchDts.js +46 -0
- package/dist/dts/fetchDts.js.map +1 -0
- package/dist/dts/httpFetch.d.ts +17 -0
- package/dist/dts/httpFetch.d.ts.map +1 -0
- package/dist/dts/httpFetch.js +35 -0
- package/dist/dts/httpFetch.js.map +1 -0
- package/dist/dts/index.d.ts +14 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/index.js +14 -0
- package/dist/dts/index.js.map +1 -0
- package/dist/dts/libManifest.d.ts +41 -0
- package/dist/dts/libManifest.d.ts.map +1 -0
- package/dist/dts/libManifest.js +109 -0
- package/dist/dts/libManifest.js.map +1 -0
- package/dist/dts/negativeCacheHelper.d.ts +29 -0
- package/dist/dts/negativeCacheHelper.d.ts.map +1 -0
- package/dist/dts/negativeCacheHelper.js +44 -0
- package/dist/dts/negativeCacheHelper.js.map +1 -0
- package/dist/dts/tarballFetcher.d.ts +13 -0
- package/dist/dts/tarballFetcher.d.ts.map +1 -0
- package/dist/dts/tarballFetcher.js +58 -0
- package/dist/dts/tarballFetcher.js.map +1 -0
- package/dist/dts/tbTypings.d.ts +15 -0
- package/dist/dts/tbTypings.d.ts.map +1 -0
- package/dist/dts/tbTypings.js +210 -0
- package/dist/dts/tbTypings.js.map +1 -0
- package/dist/dts/typeProvider.d.ts +37 -0
- package/dist/dts/typeProvider.d.ts.map +1 -0
- package/dist/dts/typeProvider.js +30 -0
- package/dist/dts/typeProvider.js.map +1 -0
- package/dist/dts/typeRefScanner.d.ts +8 -0
- package/dist/dts/typeRefScanner.d.ts.map +1 -0
- package/dist/dts/typeRefScanner.js +33 -0
- package/dist/dts/typeRefScanner.js.map +1 -0
- package/dist/dts/typescriptProvider.d.ts +21 -0
- package/dist/dts/typescriptProvider.d.ts.map +1 -0
- package/dist/dts/typescriptProvider.js +140 -0
- package/dist/dts/typescriptProvider.js.map +1 -0
- package/dist/dts/virtualFs.d.ts +20 -0
- package/dist/dts/virtualFs.d.ts.map +1 -0
- package/dist/dts/virtualFs.js +48 -0
- package/dist/dts/virtualFs.js.map +1 -0
- package/dist/format/chunks.d.ts +20 -0
- package/dist/format/chunks.d.ts.map +1 -0
- package/dist/format/chunks.js +51 -0
- package/dist/format/chunks.js.map +1 -0
- package/dist/format/config.d.ts +17 -0
- package/dist/format/config.d.ts.map +1 -0
- package/dist/format/config.js +13 -0
- package/dist/format/config.js.map +1 -0
- package/dist/format/detection.d.ts +11 -0
- package/dist/format/detection.d.ts.map +1 -0
- package/dist/format/detection.js +43 -0
- package/dist/format/detection.js.map +1 -0
- package/dist/format/index.d.ts +8 -0
- package/dist/format/index.d.ts.map +1 -0
- package/dist/format/index.js +8 -0
- package/dist/format/index.js.map +1 -0
- package/dist/format/parse.d.ts +20 -0
- package/dist/format/parse.d.ts.map +1 -0
- package/dist/format/parse.js +88 -0
- package/dist/format/parse.js.map +1 -0
- package/dist/format/registry.d.ts +24 -0
- package/dist/format/registry.d.ts.map +1 -0
- package/dist/format/registry.js +31 -0
- package/dist/format/registry.js.map +1 -0
- package/dist/format/serialize.d.ts +8 -0
- package/dist/format/serialize.d.ts.map +1 -0
- package/dist/format/serialize.js +30 -0
- package/dist/format/serialize.js.map +1 -0
- package/dist/format/yaml.d.ts +4 -0
- package/dist/format/yaml.d.ts.map +1 -0
- package/dist/format/yaml.js +17 -0
- package/dist/format/yaml.js.map +1 -0
- package/dist/index.js +401 -89
- package/dist/lint/index.d.ts +29 -0
- package/dist/lint/index.d.ts.map +1 -0
- package/dist/lint/index.js +257 -0
- package/dist/lint/index.js.map +1 -0
- package/dist/render.js +176 -39
- package/dist/resolver/attempt.d.ts +2 -0
- package/dist/resolver/attempt.d.ts.map +1 -0
- package/dist/resolver/attempt.js +9 -0
- package/dist/resolver/attempt.js.map +1 -0
- package/dist/resolver/cdnClient.d.ts +46 -0
- package/dist/resolver/cdnClient.d.ts.map +1 -0
- package/dist/resolver/cdnClient.js +107 -0
- package/dist/resolver/cdnClient.js.map +1 -0
- package/dist/resolver/cdnConstants.d.ts +10 -0
- package/dist/resolver/cdnConstants.d.ts.map +1 -0
- package/dist/resolver/cdnConstants.js +10 -0
- package/dist/resolver/cdnConstants.js.map +1 -0
- package/dist/resolver/index.d.ts +20 -0
- package/dist/resolver/index.d.ts.map +1 -0
- package/dist/resolver/index.js +20 -0
- package/dist/resolver/index.js.map +1 -0
- package/dist/resolver/packageRef.d.ts +21 -0
- package/dist/resolver/packageRef.d.ts.map +1 -0
- package/dist/resolver/packageRef.js +89 -0
- package/dist/resolver/packageRef.js.map +1 -0
- package/dist/resolver/packageService.d.ts +40 -0
- package/dist/resolver/packageService.d.ts.map +1 -0
- package/dist/resolver/packageService.js +156 -0
- package/dist/resolver/packageService.js.map +1 -0
- package/dist/resolver/peerResolver.d.ts +33 -0
- package/dist/resolver/peerResolver.d.ts.map +1 -0
- package/dist/resolver/peerResolver.js +66 -0
- package/dist/resolver/peerResolver.js.map +1 -0
- package/dist/resolver/semver.d.ts +17 -0
- package/dist/resolver/semver.d.ts.map +1 -0
- package/dist/resolver/semver.js +56 -0
- package/dist/resolver/semver.js.map +1 -0
- package/dist/resolver/types.d.ts +33 -0
- package/dist/resolver/types.d.ts.map +1 -0
- package/dist/resolver/types.js +2 -0
- package/dist/resolver/types.js.map +1 -0
- package/dist/resolver/versionResolver.d.ts +29 -0
- package/dist/resolver/versionResolver.d.ts.map +1 -0
- package/dist/resolver/versionResolver.js +79 -0
- package/dist/resolver/versionResolver.js.map +1 -0
- package/dist/servers.js +142 -3
- package/dist/transpile/index.d.ts +19 -0
- package/dist/transpile/index.d.ts.map +1 -0
- package/dist/transpile/index.js +23 -0
- package/dist/transpile/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +99 -68
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lints a bulb's code block for environment-specific issues — patterns that are
|
|
3
|
+
* valid TypeScript but break in the Typebulb runtime. Shared by typebulb.com and
|
|
4
|
+
* the CLI (`typebulb check`) so both enforce the same rules with the same
|
|
5
|
+
* AI-facing messages.
|
|
6
|
+
*
|
|
7
|
+
* Target-aware: `code.tsx` runs in the browser under an import map and a sandboxed
|
|
8
|
+
* iframe, `server.ts` runs in Node. The import-map / browser rules (dynamic
|
|
9
|
+
* import, URL / version / `.js`-deep-path imports, CSS imports, navigation) apply
|
|
10
|
+
* only to the client; the Sucrase / ESM core (require, `const enum`, `namespace`,
|
|
11
|
+
* `export =` / `import =`, `module {}`, redundant `tb`) applies to both.
|
|
12
|
+
*/
|
|
13
|
+
export type LintTarget = 'client' | 'server';
|
|
14
|
+
export type LintIssueType = 'DYNAMIC_IMPORT' | 'COMMONJS_REQUIRE' | 'JS_EXTENSION_IMPORT' | 'URL_IMPORT' | 'VERSION_SPECIFIER_IMPORT' | 'REDUNDANT_TB_DECLARATION' | 'CONST_ENUM' | 'NAMESPACE_DECLARATION' | 'COMMONJS_EXPORT_EQUALS' | 'COMMONJS_IMPORT_EQUALS' | 'MODULE_DECLARATION' | 'CSS_FILE_IMPORT' | 'NAVIGATION';
|
|
15
|
+
export type LintIssue = {
|
|
16
|
+
type: LintIssueType;
|
|
17
|
+
severity: 'error';
|
|
18
|
+
message: string;
|
|
19
|
+
lineNumber?: number;
|
|
20
|
+
lineContent?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Lint a bulb code block. `target` selects the ruleset: `client` (`code.tsx`,
|
|
24
|
+
* the browser superset) or `server` (`server.ts`, the Sucrase / ESM core only).
|
|
25
|
+
*/
|
|
26
|
+
export declare function lint(source: string, options: {
|
|
27
|
+
target: LintTarget;
|
|
28
|
+
}): LintIssue[];
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lint/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE5C,MAAM,MAAM,aAAa,GACrB,gBAAgB,GAAG,kBAAkB,GAAG,qBAAqB,GAAG,YAAY,GAC5E,0BAA0B,GAAG,0BAA0B,GAAG,YAAY,GACtE,uBAAuB,GAAG,wBAAwB,GAAG,wBAAwB,GAC7E,oBAAoB,GAAG,iBAAiB,GAAG,YAAY,CAAA;AAE3D,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,aAAa,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AA4BD;;;GAGG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GAAG,SAAS,EAAE,CAuBjF"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lints a bulb's code block for environment-specific issues — patterns that are
|
|
3
|
+
* valid TypeScript but break in the Typebulb runtime. Shared by typebulb.com and
|
|
4
|
+
* the CLI (`typebulb check`) so both enforce the same rules with the same
|
|
5
|
+
* AI-facing messages.
|
|
6
|
+
*
|
|
7
|
+
* Target-aware: `code.tsx` runs in the browser under an import map and a sandboxed
|
|
8
|
+
* iframe, `server.ts` runs in Node. The import-map / browser rules (dynamic
|
|
9
|
+
* import, URL / version / `.js`-deep-path imports, CSS imports, navigation) apply
|
|
10
|
+
* only to the client; the Sucrase / ESM core (require, `const enum`, `namespace`,
|
|
11
|
+
* `export =` / `import =`, `module {}`, redundant `tb`) applies to both.
|
|
12
|
+
*/
|
|
13
|
+
const CLIENT = ['client'];
|
|
14
|
+
const BOTH = ['client', 'server'];
|
|
15
|
+
const RULES = [
|
|
16
|
+
{ type: 'DYNAMIC_IMPORT', pattern: /\bimport\s*\(\s*['"`]/, targets: CLIENT },
|
|
17
|
+
{ type: 'COMMONJS_REQUIRE', pattern: /\brequire\s*\(\s*['"`]/, targets: BOTH },
|
|
18
|
+
// Only flag .js extension when it appears in a deep import path (has /).
|
|
19
|
+
// Package names that ARE ".js" (like "decimal.js") are legitimate npm packages.
|
|
20
|
+
// Browser-only: a `.js` on a deep path is valid (often required) in Node ESM.
|
|
21
|
+
{ type: 'JS_EXTENSION_IMPORT', pattern: /from\s+['"][^'"]*\/[^'"]*\.js['"]/, targets: CLIENT },
|
|
22
|
+
{ type: 'URL_IMPORT', pattern: /from\s+['"]https?:\/\//, targets: CLIENT },
|
|
23
|
+
{ type: 'VERSION_SPECIFIER_IMPORT', pattern: /from\s+['"][^'"]*@[\d^~]/, targets: CLIENT },
|
|
24
|
+
{ type: 'REDUNDANT_TB_DECLARATION', pattern: /declare\s+(const|var|let)\s+tb\b/, targets: BOTH },
|
|
25
|
+
{ type: 'CONST_ENUM', pattern: /\bconst\s+enum\b/, targets: BOTH },
|
|
26
|
+
{ type: 'NAMESPACE_DECLARATION', pattern: /\bnamespace\s+\w+/, targets: BOTH },
|
|
27
|
+
{ type: 'COMMONJS_EXPORT_EQUALS', pattern: /\bexport\s*=/, targets: BOTH },
|
|
28
|
+
{ type: 'COMMONJS_IMPORT_EQUALS', pattern: /\bimport\s+\w+\s*=/, targets: BOTH },
|
|
29
|
+
{ type: 'MODULE_DECLARATION', pattern: /\bmodule\s+\w+\s*\{/, targets: BOTH },
|
|
30
|
+
{ type: 'CSS_FILE_IMPORT', pattern: /(?:from|import)\s+['"][^'"]*\.css['"]/, targets: CLIENT },
|
|
31
|
+
// Navigation APIs break the sandboxed iframe.
|
|
32
|
+
{ type: 'NAVIGATION', pattern: /window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/, targets: CLIENT },
|
|
33
|
+
{ type: 'NAVIGATION', pattern: /window\.location(\.href)?\s*=[^=]/, targets: CLIENT },
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* Lint a bulb code block. `target` selects the ruleset: `client` (`code.tsx`,
|
|
37
|
+
* the browser superset) or `server` (`server.ts`, the Sucrase / ESM core only).
|
|
38
|
+
*/
|
|
39
|
+
export function lint(source, options) {
|
|
40
|
+
if (!source)
|
|
41
|
+
return [];
|
|
42
|
+
const { target } = options;
|
|
43
|
+
const issues = [];
|
|
44
|
+
const lines = source.split('\n');
|
|
45
|
+
for (let i = 0; i < lines.length; i++) {
|
|
46
|
+
const line = lines[i];
|
|
47
|
+
const lineNumber = i + 1;
|
|
48
|
+
for (const rule of RULES) {
|
|
49
|
+
if (!rule.targets.includes(target))
|
|
50
|
+
continue;
|
|
51
|
+
if (!rule.pattern.test(line))
|
|
52
|
+
continue;
|
|
53
|
+
issues.push({
|
|
54
|
+
type: rule.type,
|
|
55
|
+
severity: 'error',
|
|
56
|
+
message: messageFor(rule.type, lineNumber),
|
|
57
|
+
lineNumber,
|
|
58
|
+
lineContent: line,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return issues;
|
|
63
|
+
}
|
|
64
|
+
function messageFor(type, lineNumber) {
|
|
65
|
+
if (type === 'URL_IMPORT') {
|
|
66
|
+
return `Direct URL imports are not supported! Found on line ${lineNumber}.
|
|
67
|
+
|
|
68
|
+
**CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
|
|
69
|
+
|
|
70
|
+
✅ CORRECT - Package name only:
|
|
71
|
+
\`\`\`typescript
|
|
72
|
+
import React from "react"
|
|
73
|
+
import _ from "lodash"
|
|
74
|
+
\`\`\`
|
|
75
|
+
|
|
76
|
+
❌ WRONG - Direct URL imports:
|
|
77
|
+
\`\`\`typescript
|
|
78
|
+
import React from "https://esm.sh/react"
|
|
79
|
+
import _ from "https://cdn.skypack.dev/lodash"
|
|
80
|
+
import x from "https://unpkg.com/some-package"
|
|
81
|
+
\`\`\`
|
|
82
|
+
|
|
83
|
+
**Fix:** Use the package name only. Package resolution is handled automatically.`;
|
|
84
|
+
}
|
|
85
|
+
if (type === 'VERSION_SPECIFIER_IMPORT') {
|
|
86
|
+
return `Version specifiers in imports are not supported! Found on line ${lineNumber}.
|
|
87
|
+
|
|
88
|
+
**CRITICAL**: Import packages by name only. Do NOT include version numbers:
|
|
89
|
+
|
|
90
|
+
✅ CORRECT - Package name only:
|
|
91
|
+
\`\`\`typescript
|
|
92
|
+
import React from "react"
|
|
93
|
+
import _ from "lodash"
|
|
94
|
+
import { something } from "@scope/package"
|
|
95
|
+
\`\`\`
|
|
96
|
+
|
|
97
|
+
❌ WRONG - Version in import path:
|
|
98
|
+
\`\`\`typescript
|
|
99
|
+
import React from "react@18.2.0"
|
|
100
|
+
import _ from "lodash@^4.17.0"
|
|
101
|
+
import { x } from "@scope/package@1.0.0"
|
|
102
|
+
\`\`\`
|
|
103
|
+
|
|
104
|
+
**Fix:** Remove the version specifier (everything from @ onwards). Versions are managed separately.`;
|
|
105
|
+
}
|
|
106
|
+
if (type === 'JS_EXTENSION_IMPORT') {
|
|
107
|
+
return `Deep import paths must NOT include \`.js\` extension! Found on line ${lineNumber}.
|
|
108
|
+
|
|
109
|
+
**CRITICAL**: Remove the \`.js\` extension from deep import paths (paths with \`/\`):
|
|
110
|
+
|
|
111
|
+
✅ CORRECT - No extension in deep import:
|
|
112
|
+
\`\`\`typescript
|
|
113
|
+
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"
|
|
114
|
+
\`\`\`
|
|
115
|
+
|
|
116
|
+
❌ WRONG - Has .js extension in deep import:
|
|
117
|
+
\`\`\`typescript
|
|
118
|
+
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js"
|
|
119
|
+
\`\`\`
|
|
120
|
+
|
|
121
|
+
**Note:** Package names that literally end with ".js" (like \`decimal.js\`) are fine - this rule only applies to file paths within packages.
|
|
122
|
+
|
|
123
|
+
**Fix:** Remove \`.js\` from the end of the import path.`;
|
|
124
|
+
}
|
|
125
|
+
if (type === 'DYNAMIC_IMPORT') {
|
|
126
|
+
return `Dynamic imports are not supported! You used \`import('...')\` on line ${lineNumber}.
|
|
127
|
+
|
|
128
|
+
**CRITICAL**: All imports MUST be at the TOP of the file using standard ES6 import syntax:
|
|
129
|
+
|
|
130
|
+
✅ CORRECT - Static import at top of file:
|
|
131
|
+
\`\`\`typescript
|
|
132
|
+
import { createRoot } from 'react-dom/client'
|
|
133
|
+
|
|
134
|
+
// Later in code...
|
|
135
|
+
const root = createRoot(rootElement)
|
|
136
|
+
root.render(<App />)
|
|
137
|
+
\`\`\`
|
|
138
|
+
|
|
139
|
+
❌ WRONG - Dynamic import() in code:
|
|
140
|
+
\`\`\`typescript
|
|
141
|
+
// This is completely invalid!
|
|
142
|
+
import('react-dom/client').then(({ createRoot }) => {
|
|
143
|
+
const root = createRoot(rootElement)
|
|
144
|
+
root.render(<App />)
|
|
145
|
+
})
|
|
146
|
+
\`\`\`
|
|
147
|
+
|
|
148
|
+
**Fix:** Move ALL import statements to the top of the file using standard \`import\` syntax.`;
|
|
149
|
+
}
|
|
150
|
+
if (type === 'REDUNDANT_TB_DECLARATION') {
|
|
151
|
+
return `Redundant \`declare const tb\` found on line ${lineNumber}.
|
|
152
|
+
The \`tb\` global is already provided by the environment. Remove this declaration.`;
|
|
153
|
+
}
|
|
154
|
+
if (type === 'CONST_ENUM') {
|
|
155
|
+
return `\`const enum\` is not supported! Found on line ${lineNumber}.
|
|
156
|
+
|
|
157
|
+
**Fix:** Use a regular \`enum\` or an object with \`as const\`:
|
|
158
|
+
|
|
159
|
+
\`\`\`typescript
|
|
160
|
+
// Option 1: Regular enum
|
|
161
|
+
enum Direction { Up, Down, Left, Right }
|
|
162
|
+
|
|
163
|
+
// Option 2: Object literal (often better)
|
|
164
|
+
const Direction = { Up: 0, Down: 1, Left: 2, Right: 3 } as const
|
|
165
|
+
\`\`\`
|
|
166
|
+
|
|
167
|
+
\`const enum\` requires the full TypeScript compiler to inline values at compile time. Regular \`enum\` and object literals work identically at runtime.`;
|
|
168
|
+
}
|
|
169
|
+
if (type === 'NAMESPACE_DECLARATION') {
|
|
170
|
+
return `TypeScript \`namespace\` is not supported! Found on line ${lineNumber}.
|
|
171
|
+
|
|
172
|
+
**Fix:** Use ES modules instead:
|
|
173
|
+
|
|
174
|
+
\`\`\`typescript
|
|
175
|
+
// Instead of: namespace MyLib { export function foo() {} }
|
|
176
|
+
// Just use top-level exports:
|
|
177
|
+
export function foo() {}
|
|
178
|
+
\`\`\`
|
|
179
|
+
|
|
180
|
+
Namespaces are a legacy TypeScript pattern. Use standard ES module imports/exports instead.`;
|
|
181
|
+
}
|
|
182
|
+
if (type === 'COMMONJS_EXPORT_EQUALS') {
|
|
183
|
+
return `\`export =\` syntax is not supported! Found on line ${lineNumber}.
|
|
184
|
+
|
|
185
|
+
**Fix:** Use ES module \`export default\` instead:
|
|
186
|
+
|
|
187
|
+
\`\`\`typescript
|
|
188
|
+
// Instead of: export = myValue
|
|
189
|
+
export default myValue
|
|
190
|
+
\`\`\``;
|
|
191
|
+
}
|
|
192
|
+
if (type === 'COMMONJS_IMPORT_EQUALS') {
|
|
193
|
+
return `\`import x =\` syntax is not supported! Found on line ${lineNumber}.
|
|
194
|
+
|
|
195
|
+
**Fix:** Use ES module \`import\` instead:
|
|
196
|
+
|
|
197
|
+
\`\`\`typescript
|
|
198
|
+
// Instead of: import x = require('module')
|
|
199
|
+
import x from 'module'
|
|
200
|
+
\`\`\``;
|
|
201
|
+
}
|
|
202
|
+
if (type === 'MODULE_DECLARATION') {
|
|
203
|
+
return `TypeScript \`module\` declarations are not supported! Found on line ${lineNumber}.
|
|
204
|
+
|
|
205
|
+
**Fix:** Use ES modules instead. The \`module Foo {}\` syntax is a legacy TypeScript pattern — use standard imports/exports.`;
|
|
206
|
+
}
|
|
207
|
+
if (type === 'CSS_FILE_IMPORT') {
|
|
208
|
+
return `Importing CSS files is not supported! Found on line ${lineNumber}.
|
|
209
|
+
|
|
210
|
+
**CRITICAL**: CSS imports don't work here. The styles.css block is already applied to the page automatically.
|
|
211
|
+
|
|
212
|
+
✅ CORRECT - Just remove the import. CSS from the styles.css block is already applied to the page.
|
|
213
|
+
|
|
214
|
+
❌ WRONG - Importing CSS as a file:
|
|
215
|
+
\`\`\`typescript
|
|
216
|
+
import "./styles.css"
|
|
217
|
+
import styles from "./styles.css"
|
|
218
|
+
\`\`\`
|
|
219
|
+
|
|
220
|
+
**Fix:** Delete the CSS import line entirely. Write styles in the styles.css block — they are loaded automatically.`;
|
|
221
|
+
}
|
|
222
|
+
if (type === 'NAVIGATION') {
|
|
223
|
+
return `Navigation is forbidden in this sandboxed environment! Found on line ${lineNumber}.
|
|
224
|
+
|
|
225
|
+
**CRITICAL**: \`window.location\` changes, \`window.open()\`, and page reloads will break the app.
|
|
226
|
+
|
|
227
|
+
✅ CORRECT - Reset application state programmatically:
|
|
228
|
+
\`\`\`typescript
|
|
229
|
+
setState(initialState)
|
|
230
|
+
\`\`\`
|
|
231
|
+
|
|
232
|
+
❌ WRONG - Browser navigation:
|
|
233
|
+
\`\`\`typescript
|
|
234
|
+
window.location.reload()
|
|
235
|
+
window.location.href = "..."
|
|
236
|
+
window.open("...")
|
|
237
|
+
\`\`\`
|
|
238
|
+
|
|
239
|
+
**Fix:** Remove the navigation call. To "restart", reset your state variables instead.`;
|
|
240
|
+
}
|
|
241
|
+
return `CommonJS \`require()\` is not supported! Found on line ${lineNumber}.
|
|
242
|
+
|
|
243
|
+
**CRITICAL**: Use ES6 \`import\` statements at the TOP of the file:
|
|
244
|
+
|
|
245
|
+
✅ CORRECT - ES6 import:
|
|
246
|
+
\`\`\`typescript
|
|
247
|
+
import { something } from 'module-name'
|
|
248
|
+
\`\`\`
|
|
249
|
+
|
|
250
|
+
❌ WRONG - CommonJS require:
|
|
251
|
+
\`\`\`typescript
|
|
252
|
+
const something = require('module-name') // NOT SUPPORTED!
|
|
253
|
+
\`\`\`
|
|
254
|
+
|
|
255
|
+
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`;
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lint/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAkBH,MAAM,MAAM,GAA0B,CAAC,QAAQ,CAAC,CAAA;AAChD,MAAM,IAAI,GAA0B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AAIxD,MAAM,KAAK,GAAW;IACpB,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,EAAE;IAC7E,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAAE,IAAI,EAAE;IAC9E,yEAAyE;IACzE,gFAAgF;IAChF,8EAA8E;IAC9E,EAAE,IAAI,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