UNPKG

eslint-plugin-mdx

Version:
59 lines • 1.54 kB
import { ENABLED_OPTION_SCHEMA, getRuleConfig } from './helpers.js'; const shellLanguages = new Set([ 'bash', 'bats', 'command', 'csh', 'ebuild', 'eclass', 'ksh', 'sh', 'sh.in', 'tcsh', 'tmux', 'tool', 'zsh', 'zsh-theme', 'abuild', 'alpine-abuild', 'apkbuild', 'gentoo-ebuild', 'gentoo-eclass', 'openrc', 'openrc-runscript', 'shell', 'shell-script', ]); export const noShellDollars = { meta: { type: 'problem', docs: { description: 'Disallow shell code prefixed by dollar signs', }, schema: [ENABLED_OPTION_SCHEMA], }, create(context) { const config = getRuleConfig(context, 'no-shell-dollars'); if (!config) { return {}; } return { MDCode(node) { if (!node.lang || !shellLanguages.has(node.lang)) { return; } const lines = node.value .split('\n') .map(line => line.trim()) .filter(Boolean); if (lines.length > 0 && lines.every(line => line.startsWith('$'))) { context.report({ loc: node.loc, message: 'Unexpected shell code with every line prefixed by `$`, expected different code for input and output', }); } }, }; }, }; //# sourceMappingURL=no-shell-dollars.js.map