Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function expectWarnings(css: string, warnings: Diagnostic[]) {
const source = findTestLocations(css);
const root = safeParse(source.css);
const res = process(root);
res.diagnostics.reports.forEach((report, i) => {
const expectedWarning = warnings[i];
if (expectedWarning.skip) {
return;
}
expect(report.message).to.equal(expectedWarning.message);
expect(report.node.source!.start, 'start').to.eql(source.start);
if (source.word !== null) {
expect(report.options.word).to.equal(source.word);
}
if (expectedWarning.severity) {
expect(
export function createMeta(src: string, path: string) {
let meta: StylableMeta;
const fakes: postcss.Rule[] = [];
try {
const ast: postcss.Root = safeParse(src, { from: URI.file(path).fsPath });
if (ast.nodes) {
for (const node of ast.nodes) {
if (node.type === 'decl') {
const r = postcss.rule({ selector: node.prop + ':' + node.value });
r.source = node.source;
node.replaceWith(r);
fakes.push(r);
}
}
}
if (ast.raws.after && ast.raws.after.trim()) {
const r = postcss.rule({ selector: ast.raws.after.trim() });
ast.append(r);
fakes.push(r);
}
export function extractSchema(
css: string,
filePath: string,
root: string,
path: MinimalPath,
resolveNamespace?: (namespace: string, source: string) => string
) {
const processor = new StylableProcessor(undefined, resolveNamespace);
const meta = processor.process(safeParse(css, { from: filePath }));
return generateSchema(meta, filePath, root, path);
}