Skip to content

Commit

Permalink
fix: parserPath type might be undefined on Eslint Flat Config (#588)
Browse files Browse the repository at this point in the history
Co-authored-by: JounQin <admin@1stg.me>
  • Loading branch information
krist7599555 and JounQin committed Oct 11, 2023
1 parent b2b93c3 commit 21a7146
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-birds-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-prettier": patch
---

fix: `parserPath` type might be `undefined` on Eslint Falt Config
7 changes: 5 additions & 2 deletions worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 21a7146

Please sign in to comment.