What version of eslint are you using? 7.21.0
What version of prettier are you using? 2.2.1
What version of eslint-plugin-prettier are you using? 3.3.1
{
"script": {
"test": "eslint README.md"
},
"devDependencies": {
"eslint": "^7.21.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-markdown": "^2.0.0",
"eslint-plugin-prettier": "^3.3.1",
"prettier": "^2.2.1"
}
}
Please paste any applicable config files that you're using (e.g. .prettierrc or .eslintrc files)
No .prettierrc.
// .eslintrc.js
module.exports = {
root: true,
extends: ['plugin:prettier/recommended', 'plugin:markdown/recommended'],
};
What source code are you linting?
# README.md
```js
var x = 123;
```
What did you expect to happen?
npm test should run without throwing an exception.
What actually happened?
$ npm test
Oops! Something went wrong! :(
ESLint: 7.21.0
Error: ENOTDIR: not a directory, stat '.../README.md/0_0.js'
Occurred while linting .../README.md/0_0.js:1
at Object.statSync (node:fs:1128:3)
at isTypeSync (.../node_modules/prettier/third-party.js:9748:46)
at getDirectorySync (.../node_modules/prettier/third-party.js:9802:62)
at ExplorerSync.searchSync (.../node_modules/prettier/third-party.js:9950:66)
at _resolveConfig (.../node_modules/prettier/index.js:25592:50)
at Function.resolveConfig.sync (.../node_modules/prettier/index.js:25621:42)
at Program (.../node_modules/eslint-plugin-prettier/eslint-plugin-prettier.js:167:40)
at .../node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (.../node_modules/eslint/lib/linter/safe-emitter.js:45:38)
Credit to eslint/markdown#174 for originally reporting this. My examples are based on that issue.
eslint-plugin-markdown v2 switched to use the new processor API that was released as part of ESLint v6. Instead of returning each extracted code block as a string, processors can now return both the source code text and a filename. In the example code above, the code block's returned filename would be 0.js, with the extension coming from the code block's syntax tag.
The new processor API uses the code block's filename to construct a virtual filename as parentFilename + path.sep + index + filenameFromPreprocess. In the example above, the code block's virtual filename becomes README.md/0_0.js.
Based on the stack trace and a bit of stepping in a debugger, it looks like the exception is thrown when the rule tries to load the .prettierrc for the file. If I set usePrettierrc: false, a very similar exception is thrown in a call a few lines later.
This exception would occur with any processor that uses the new processor API and yields virtual filenames.
Depending on what it might take to handle code blocks with virtual filenames, eslint/eslint#11989 may be a related issue.
What version of
eslintare you using? 7.21.0What version of
prettierare you using? 2.2.1What version of
eslint-plugin-prettierare you using? 3.3.1{ "script": { "test": "eslint README.md" }, "devDependencies": { "eslint": "^7.21.0", "eslint-config-prettier": "^8.1.0", "eslint-plugin-markdown": "^2.0.0", "eslint-plugin-prettier": "^3.3.1", "prettier": "^2.2.1" } }Please paste any applicable config files that you're using (e.g.
.prettierrcor.eslintrcfiles)No
.prettierrc.What source code are you linting?
What did you expect to happen?
npm testshould run without throwing an exception.What actually happened?
Credit to eslint/markdown#174 for originally reporting this. My examples are based on that issue.
eslint-plugin-markdownv2 switched to use the new processor API that was released as part of ESLint v6. Instead of returning each extracted code block as a string, processors can now return both the source codetextand afilename. In the example code above, the code block's returnedfilenamewould be0.js, with the extension coming from the code block's syntax tag.The new processor API uses the code block's
filenameto construct a virtual filename asparentFilename + path.sep + index + filenameFromPreprocess. In the example above, the code block's virtual filename becomesREADME.md/0_0.js.Based on the stack trace and a bit of stepping in a debugger, it looks like the exception is thrown when the rule tries to load the
.prettierrcfor the file. If I setusePrettierrc: false, a very similar exception is thrown in a call a few lines later.This exception would occur with any processor that uses the new processor API and yields virtual filenames.
Depending on what it might take to handle code blocks with virtual filenames, eslint/eslint#11989 may be a related issue.