-
Notifications
You must be signed in to change notification settings - Fork 76
Closed
Labels
Description
I'm trying to set up a rule set that is able to discriminate between ESM examples and CJS code snippets inside the markdown documentation:
```js esm
export default {};
```
```js cjs
'use strict';
module.exports = {};
```
The issue is that only the js
is passed through unfied
lang
data, and the part after the space is pass to the meta
option:
{
type: 'html',
lang: 'js',
meta: 'esm',
value: 'export default {};',
position: {
start: { line: 1, column: 1, offset: 0 },
end: { line: 3, column: 4, offset: 32 }
}
}
{
type: 'html',
lang: 'js',
meta: 'cjs',
value: "'use strict';\nmodule.exports = {};",
position: {
start: { line: 4, column: 1, offset: 33 },
end: { line: 7, column: 4, offset: 81 }
}
}
I wish there was a way to create separate rules for those blocks, something like:
// .eslintrc.js
module.exports = {
plugins: ["markdown"],
overrides: [
{
files: ["**/*.md/*.js:cjs"],
parserOption: { sourceType: "script" },
rules: {
// ...
}
},
{
files: ["**/*.md/*.js:esm"],
parserOption: { sourceType: "module" },
rules: {
// ...
}
},
]
};
EDIT: I'm using remark-parse
9.0.0, the meta
property doesn't seem to be available in remark-parse
5.x this repo is using.