Environment
ESLint version: 10.7.0
@eslint/markdown version: 8.0.3
Node version: 26.5.0
npm version: 12.0.1
Operating System: Linux
What problem do you want to solve?
Currently the processor only returns the embedded code blocks.
This has the disadvantage that ESLint can only either run for the embedded code blocks or the markdown itself.
This limitation has been hit by users multiple times, e.g. #695 or #297.
What do you think is the correct solution?
Passthrough the original file contents as a "processor block".
Concretely this processor can be specified using the existing preprocess and postprocess like this:
export const processorWithPassthrough = {
meta: {
name: "@eslint/markdown/markdown-passthrough",
version: "8.0.3", // x-release-please-version
},
preprocess(sourceText, filename) {
const blocks = preprocess(sourceText, filename);
// Add the original source file at the start
return [{ text: sourceText, filename }].concat(blocks);
},
postprocess(messages, filename) {
// Passthrough the messages from the original file
return [...messages[0], ...postprocess(messages.slice(1), filename)]
},
supportsAutofix: SUPPORTS_AUTOFIX,
}
Then the user can configure the rules like this in their eslint.config.js:
export default [{
// For markdown files
files: ['**/*.md'],
plugins: { markdown },
processor: 'markdown/markdownPassthrough',
language: 'markdown/gfm',
rules: {
'markdown/no-bare-urls': 'error', // Any markdown rules here
},
}, {
// For embedded code blocks, e.g. JavaScript
files: ['**/*.md/*.js'],
rules: {
semi: 'error', // Any rules for embedded JavaScript code blocks here
},
}]
Participation
AI acknowledgment
Additional comments
I tried this locally and this solution works but seems to be quite hacky.
The changes are only adding the processor from above and exporting it in the plugin.
I could create a draft PR, so the passthrough processor is easier to try out.
If accepted, should the existing processor do the passthrough or should an additional processor (like above) be created?
Environment
ESLint version: 10.7.0
@eslint/markdown version: 8.0.3
Node version: 26.5.0
npm version: 12.0.1
Operating System: Linux
What problem do you want to solve?
Currently the processor only returns the embedded code blocks.
This has the disadvantage that ESLint can only either run for the embedded code blocks or the markdown itself.
This limitation has been hit by users multiple times, e.g. #695 or #297.
What do you think is the correct solution?
Passthrough the original file contents as a "processor block".
Concretely this processor can be specified using the existing
preprocessandpostprocesslike this:Then the user can configure the rules like this in their
eslint.config.js:Participation
AI acknowledgment
Additional comments
I tried this locally and this solution works but seems to be quite hacky.
The changes are only adding the processor from above and exporting it in the plugin.
I could create a draft PR, so the passthrough processor is easier to try out.
If accepted, should the existing processor do the passthrough or should an additional processor (like above) be created?