Skip to content

Commit 8054ceb

Browse files
committed
fix prettier-ignore comments on 3.6.x
1 parent cee03bf commit 8054ceb

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"eslint-plugin-simple-import-sort": "^12.1.1",
7676
"eslint-plugin-unicorn": "^59.0.1",
7777
"globals": "^16.2.0",
78-
"prettier": "3.7.1",
78+
"prettier": "3.6.2",
7979
"prettier-plugin-jsdoc": "^1.3.2",
8080
"release-plan": "^0.11.0",
8181
"typescript": "^5.8.3",

pnpm-lock.yaml

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/print/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,15 @@ function printRawText(
154154
}
155155

156156
function hasPrettierIgnore(path: AstPath<Node | undefined>): boolean {
157-
return path.node?.leadingComments?.at(-1)?.value.trim() === 'prettier-ignore';
157+
let possibleComment = path.node?.leadingComments?.at(-1)?.value.trim();
158+
159+
// @ts-expect-error Comments exist on node sometimes
160+
if (!path.node?.leadingComments && path.node?.comments) {
161+
// @ts-expect-error Comments exist on node sometimes
162+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
163+
possibleComment = path.node.comments?.at(-1)?.value.trim();
164+
}
165+
return possibleComment === 'prettier-ignore';
158166
}
159167

160168
function checkPrettierIgnore(path: AstPath<Node | undefined>): boolean {

0 commit comments

Comments
 (0)