eslint-plugin-md
eslint-plugin-md copied to clipboard
Formatting with Prettier not working
Hi, I am loving this library already. Linting entire Markdown files with ESLint is great, so I'm glad you put this together.
I am having trouble getting this to work as expected with Prettier though. It is not formatting my files to account for line-length.
Here is my .prettierrc.json:
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "all",
"printWidth": 80,
"overrides": [
{
"files": "*.json",
"options": {
"trailingComma": "none"
}
},
{
"files": [
"*.md"
],
"options": {
"parser": "markdown",
"rules": {
"prettier/prettier": [
"error",
{
"parser": "markdown"
}
]
}
}
}
]
}
and here is my .eslintrc.json:
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "all",
"printWidth": 80,
"overrides": [
{
"files": "*.json",
"options": {
"trailingComma": "none"
}
},
{
"files": [
"*.md"
],
"options": {
"parser": "markdown",
"rules": {
"prettier/prettier": [
"error",
{
"parser": "markdown"
}
]
}
}
}
]
}
and here are the dependencies from my package.json:
"dependencies": {
"fibers": "^4.0.2",
"glob": "^7.1.6",
"gray-matter": "^4.0.2",
"isomorphic-unfetch": "^3.0.0",
"next": "^9.3.1",
"node-sass": "^4.13.1",
"raw-loader": "^4.0.0",
"react": "^16.13.1",
"react-addons-shallow-compare": "^15.6.2",
"react-dom": "^16.13.1",
"react-markdown": "^4.3.1",
"react-syntax-highlighter": "^12.2.1",
"sass": "^1.26.3",
"styled-components": "^5.1.0",
"swr": "^0.1.18"
},
"devDependencies": {
"babel-plugin-styled-components": "^1.10.7",
"eslint": "^7.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-json": "^2.1.1",
"eslint-plugin-md": "^1.0.15",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-react-hooks": "^4.0.4",
"husky": "^4.2.5",
"lint-staged": ">=10",
"markdown-eslint-parser": "^1.2.1",
"prettier": "2.0.5"
},
For reference, I am using VSCode, but I can't get this working from the CLI either. I would appreciate any help you can provide!
Actually, I realized once I added proseWrap: 'always' to my .prettierrc.json, it formatted the line-length issues correctly. But, I am still getting these errors:
26:69 error Emphasis should use `*` as a marker (emphasis-marker) md/remark
38:20 error Missing new line after list item (list-item-spacing) md/remark
39:1 error Marker should be `1`, was `2` (ordered-list-marker-value) md/remark
372:1 error Use the trailing `[]` on reference links (no-shortcut-reference-link) md/remark
So I am still trying to work these out.
I've spent some more time on this, but no luck.
My end goal is that Prettier will format my Markdown files according to the configurations we've added to ESLint for this plugin. Is this possible?
This is a few years later and it seems like this eslint plugin is still one of the most popular for markdown, but I am running into the EXACT same issues as you. @ryanjwessel did you happen to ever figure this out?
Sorry @GitMurf, I don't remember finding a solution to this problem.