Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions packages/devtools/src/devframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ const pangular = defineDevframe({
name: 'pipe-lint',
type: 'query',
jsonSerializable: true,
// A source scan like get-pipes, so a static report bakes it in too.
snapshot: true,
handler: () => lintPipes(ctx.cwd),
});

Expand Down
29 changes: 27 additions & 2 deletions packages/devtools/src/rpc/__tests__/static-dump.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { writeFileSync } from 'node:fs';
import { mkdirSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { createHostContext } from 'devframe/node';
import { collectStaticRpcDump } from 'devframe/rpc/dump';
import { collectStaticRpcDump, createClientFromDump, dumpFunctions } from 'devframe/rpc/dump';
import { describe, expect, it } from 'vitest';
import pangular from '../../devframe.ts';
import { fixtureDir } from './fixture-dir.ts';
Expand All @@ -28,8 +28,33 @@ describe('static report dump', () => {
'get-providers',
'get-pipes',
'get-ngrx-store',
'pipe-lint',
].map((name) => `pangular:${name}`),
),
);
});

it('answers the Pipes lint from the report', async () => {
const cwd = fixtureDir('pangular-dump-lint-');
writeFileSync(join(cwd, 'package.json'), '{}');
mkdirSync(join(cwd, 'src'));
writeFileSync(
join(cwd, 'src', 'debug.component.ts'),
`@Component({ selector: 'app-debug', template: '{{ user | json }}' })\nexport class Debug {}\n`,
);
const host = {
mountStatic: () => {},
resolveOrigin: () => 'http://localhost',
getStorageDir: () => '',
};
const ctx = await createHostContext({ cwd, mode: 'build', host: host as never });
await pangular.setup(ctx as never);
const pipes = ['pangular:get-pipes', 'pangular:pipe-lint'].map((name) =>
ctx.rpc.definitions.get(name)!,
);
const store = await dumpFunctions(pipes, ctx);
const client = createClientFromDump(store) as Record<string, () => Promise<unknown>>;
const findings = (await client['pangular:pipe-lint']()) as { rule: string }[];
expect(findings.map((finding) => finding.rule)).toEqual(['json-pipe-in-template']);
});
});
Loading