Replies: 13 comments
-
Hi @so1ve, could you provide a reproducible demo? Taking a quick look at the plugin docs shows that the API has changed between v1 and v2. Version 2 is configured like this it seems: module.exports = {
extends: "plugin:markdown/recommended",
plugins: ["markdown"],
overrides: [
{
files: ["**/*.md"],
processor: "markdown/markdown"
},
]
}; |
Beta Was this translation helpful? Give feedback.
-
Sure, please checkout https://github.com/so1ve/eslint-plugin-markdown-repro
|
Beta Was this translation helpful? Give feedback.
-
Thank you for the demo @so1ve. Just ran it on my machine and I see that the linter throws error if you use module.exports = {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module"
},
plugins: ["markdown"],
overrides: [
{
files: ["**/*.md"],
processor: "markdown/markdown",
},
],
rules: {
semi: "error"
}
}; It also works if you remove the processor: module.exports = {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module"
},
plugins: ["markdown"],
overrides: [
{
files: ["**/*.md"],
},
],
rules: {
semi: "error"
}
}; Now, if I understood you correctly, it seems like the markdown errors stop working once you add a custom module.exports = {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module"
},
plugins: ["markdown"],
overrides: [
{
files: ["**/*.md"],
processor: "markdown/markdown", // Comment out this line
parser: require.resolve("./parser.js")
},
],
rules: {
semi: "error"
}
}; and then use the following format in var espree = require("espree");
function parseForESLint(code, options) {
console.log('parseForESLint');
return {
ast: espree.parse(code, options),
services: {
isPlain: true,
foo: function() {
console.log("foo");
}
},
scopeManager: null,
visitorKeys: null
};
};
module.exports = { parseForESLint }; This calls the custom parser and throws the error still. |
Beta Was this translation helpful? Give feedback.
-
@sam3k when you say "throws errors", are you saying that ESLint is reporting linting errors or that it is throwing an error (with a stack trace)? |
Beta Was this translation helpful? Give feedback.
-
@nzakas I meant ESLint reports lint error: |
Beta Was this translation helpful? Give feedback.
-
@so1ve were you able to try out the configuration I've suggested? |
Beta Was this translation helpful? Give feedback.
-
@sam3k Ah, sorry. Before I was busy with exams and didn't have time to see github. I'll try your solution later |
Beta Was this translation helpful? Give feedback.
-
Haven't tried it yet, but I think it won't work as my expectations. In your code, you call |
Beta Was this translation helpful? Give feedback.
-
@so1ve it seems like it returns JS AST. I've seen the function parseForESLint(code, options) {
return {
ast: {
// ast is JS ast. We don't have JS, so this AST is for empty JS file
type: 'Program',
start: 0,
end: 0,
loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
range: [0, 0],
body: [],
tokens: [],
comments: [],
// Used only by eslint-plugin-markdown-language
mdCode: code,
},
services: {
isPlain: true,
foo: function() {
console.log("foo");
}
},
scopeManager: null,
visitorKeys: null
};
};
module.exports = { parseForESLint }; Not sure if this is helpful; but could you give it a shot? |
Beta Was this translation helpful? Give feedback.
-
Maybe I am doing something wrong? function parseForESLint(code, options) {
console.log(code) // This logs nothing :(
return {
ast: {
// ast is JS ast. We don't have JS, so this AST is for empty JS file
type: 'Program',
start: 0,
end: 0,
loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
range: [0, 0],
body: [],
tokens: [],
comments: [],
// Used only by eslint-plugin-markdown-language
mdCode: code,
},
services: {
isPlain: true,
foo: function() {
console.log("foo");
}
},
scopeManager: null,
visitorKeys: null
};
};
module.exports = { parseForESLint }; |
Beta Was this translation helpful? Give feedback.
-
@so1ve everything looks good. Can you try this fork I've made? |
Beta Was this translation helpful? Give feedback.
-
It doesn't work either... It logs nothing :( |
Beta Was this translation helpful? Give feedback.
-
It looks like this isn't about a problem with the plugin, but rather, a question about how to configure ESLint, so I'm moving this to a discussion. |
Beta Was this translation helpful? Give feedback.
-
I don't think a reproduction is needed for this issue :(
For example, in eslint config:
The parser does not take effect. (Actually it doesn't run at all!)
Is this by design?
Beta Was this translation helpful? Give feedback.
All reactions