Skip to content

Commit 21a7146

Browse files
krist7599555JounQin
andauthoredOct 11, 2023
fix: parserPath type might be undefined on Eslint Flat Config (#588)
Co-authored-by: JounQin <admin@1stg.me>
1 parent b2b93c3 commit 21a7146

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
 

‎.changeset/thick-birds-share.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-prettier": patch
3+
---
4+
5+
fix: `parserPath` type might be `undefined` on Eslint Falt Config

‎worker.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @typedef {import('prettier').FileInfoOptions} FileInfoOptions
5-
* @typedef {import('prettier').Options & { onDiskFilepath: string, parserPath: string, usePrettierrc?: boolean }} Options
5+
* @typedef {import('prettier').Options & { onDiskFilepath: string, parserPath?: string, usePrettierrc?: boolean }} Options
66
*/
77

88
const { runAsWorker } = require('synckit');
@@ -112,7 +112,10 @@ runAsWorker(
112112
// it could be processed by `@ota-meshi/eslint-plugin-svelte`, `eslint-plugin-svelte` or `eslint-plugin-svelte3`
113113
case 'svelte': {
114114
// The `source` would be modified by `eslint-plugin-svelte3`
115-
if (!parserPath.includes('svelte-eslint-parser')) {
115+
if (
116+
typeof parserPath === 'string' &&
117+
!parserPath.includes('svelte-eslint-parser')
118+
) {
116119
// We do not support `eslint-plugin-svelte3`,
117120
// the users should run `prettier` on `.svelte` files manually
118121
return;

0 commit comments

Comments
 (0)
Please sign in to comment.