Files
test-repo/src/language-css/embed.js
T
Sosuke Suzuki e92dcbd1a5 Add new ESLint prefer-ast-path-node (#13470)
* Add new lint rule `prefer-path-get-value`

* Add new rule

* Apply fix

* Ingore projects in benchmark

* Add comment
2022-09-11 18:39:06 +09:00

20 lines
512 B
JavaScript

import { hardline } from "../document/builders.js";
import printFrontMatter from "../utils/front-matter/print.js";
function embed(path) {
const { node } = path;
if (node.type === "front-matter") {
return async (textToDoc) => {
const doc = await printFrontMatter(node, textToDoc);
return doc ? [doc, hardline] : undefined;
};
}
}
// `front-matter` only available on `css-root`
embed.getVisitorKeys = (node) =>
node.type === "css-root" ? ["frontMatter"] : [];
export default embed;