-
Notifications
You must be signed in to change notification settings - Fork 86
Bug: ESLint built-in types are not compatible with mdast node types #323
Description
Environment
ESLint version: v9.22.0
@eslint/markdown version: ^6.3.0
Node version: v20.18.0
npm version: v10.9.2
Operating System: win32 10.0.22631
Which language are you using?
commonmark
What did you do?
Configuration
<!-- Paste your configuration here -->
// Repro.mjs
// @ts-check
/**
* @typedef {import("@eslint/markdown").RuleModule} RuleModule
* @typedef {import("mdast").Text} Text
* @typedef
*/
/** @type {RuleModule} */
export default {
meta: {
// ...
},
create({ sourceCode }) {
return {
/** @param {Text} node */
text(node) {
console.log(sourceCode.getText(node));
},
};
},
};What did you expect to happen?
Hello,
The code above is causing a bug.
I found that @eslint/markdown uses mdast internally, so I tried using mdast node types for type declarations.
However, many ESLint types are designed specifically for ESTree, not mdast.
Because of this, there's an inconsistency when using mdast types with certain built-in ESLint methods, such as sourceCode.getText().
What actually happened?
An error like the one in the screenshot occurs.
Link to Minimal Reproducible Example
Participation
- I am willing to submit a pull request for this issue.
Additional comments
I believe this bug is not limited to Markdown. Since ESLint's internal types only support ESTree, other language supports, like CSS or JSON, might encounter the same problem.
In my opinion, there should be common interfaces to support the ASTs of multiple languages.
