diff --git a/.changeset/thick-birds-share.md b/.changeset/thick-birds-share.md new file mode 100644 index 00000000..8293e14b --- /dev/null +++ b/.changeset/thick-birds-share.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-prettier": patch +--- + +fix: `parserPath` type might be `undefined` on Eslint Falt Config diff --git a/worker.js b/worker.js index 5e36ad6c..d4cadc05 100644 --- a/worker.js +++ b/worker.js @@ -2,7 +2,7 @@ /** * @typedef {import('prettier').FileInfoOptions} FileInfoOptions - * @typedef {import('prettier').Options & { onDiskFilepath: string, parserPath: string, usePrettierrc?: boolean }} Options + * @typedef {import('prettier').Options & { onDiskFilepath: string, parserPath?: string, usePrettierrc?: boolean }} Options */ const { runAsWorker } = require('synckit'); @@ -112,7 +112,10 @@ runAsWorker( // it could be processed by `@ota-meshi/eslint-plugin-svelte`, `eslint-plugin-svelte` or `eslint-plugin-svelte3` case 'svelte': { // The `source` would be modified by `eslint-plugin-svelte3` - if (!parserPath.includes('svelte-eslint-parser')) { + if ( + typeof parserPath === 'string' && + !parserPath.includes('svelte-eslint-parser') + ) { // We do not support `eslint-plugin-svelte3`, // the users should run `prettier` on `.svelte` files manually return;