How to use the hint.Engine function in hint

To help you get started, we’ve selected a few hint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webhintio / hint / packages / utils-tests-helpers / src / hint-runner.ts View on Github external
const runHint = async (t: ExecutionContext, hintTest: HintLocalTest) => {

        try {
            if (hintTest.before) {
                await hintTest.before(t);
            }

            const hintConfig = createConfig(hintId, connector, configs);
            const resources = resourceLoader.loadResources(hintConfig);
            const engine = new Engine(hintConfig, resources);

            // Can assume `getAsUri(hintTest.path)` is not `null` since these are controlled test inputs.
            const target = getAsUri(hintTest.path)!;
            const results = await engine.executeOn(target);

            await engine.close();

            if (hintTest.after) {
                await hintTest.after(t);
            }

            const sources = new Map();

            for (const result of results) {
                if (!sources.has(result.resource)) {
                    sources.set(result.resource, await requestSource(result.resource, connector));
github webhintio / hint / packages / utils-tests-helpers / src / hint-runner.ts View on Github external
const createConnector = async (t: ExecutionContext, hintTest: HintTest, connector: string): Promise => {
        if (hintTest.before) {
            await hintTest.before();
        }

        const config = createConfig(hintId, connector, configs);
        const resources = resourceLoader.loadResources(config);
        const engine: Engine = new Engine(config, resources);

        return engine;
    };