0.0.0 • Published 2 years ago

@conformyze/lynta-ruleset-bundler v0.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

@conformyze/lynta-ruleset-bundler

Options

  • plugins - any other Rollup.js plugin, i.e. a minifier.
  • target:
    • node - a preset suitable for the Node.js runtime
    • browser - a preset tailored to Browsers
    • runtime - a preset you want to use if you want to bundle & execute the ruleset at the runtime
  • format - supported values are: esm, commonjs, iife.
  • treeshake - whether to enable tree shaking. False by default.

Bolded options are required.

Loading YAML/JSON Ruleset

import * as fs from "node:fs";
import { fileURLToPath } from "node:url";
import * as path from "node:path";
import { Lynta } from "lynta";
import { bundleAndLoadRuleset } from "@conformyze/lynta-ruleset-bundler/with-loader";
import { fetch } from "@conformyze/lynta-runtime";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const lynta = new Lynta();

lynta.setRuleset(await bundleAndLoadRuleset(path.join(__dirname, ".lynta.yaml"), { fs, fetch }));
// or
lynta.setRuleset(await bundleAndLoadRuleset(path.join(__dirname, ".spectral.yaml"), { fs, fetch }));

// lint as usual