Skip to content

lines-before-block also triggers for first constituent in a union or intersection type #1343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JoshuaKGoldberg opened this issue Dec 1, 2024 · 1 comment

Comments

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Dec 1, 2024

Expected behavior

This should not report:

export type SomeType =
	/**
	 * 🍏 fruit.
	 */
	| Apple

	/**
	 * 🍌 fruit.
	 */
	| Banana;

Actual behavior

Required 1 line(s) before JSDoc blockeslint[jsdoc/lines-before-block](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/lines-before-block.md#repos-sticky-header)

ESLint Config

import jsdoc from 'eslint-plugin-jsdoc';

export default [jsdoc.configs['flat/recommended']];

Additional info

I'd fixed this bug/feature for blocks in #1341, but didn't think to for union or intersection types.

The autofix puts a blank line before the JSDoc block. Prettier removes that blank line. Fun.

LukeAbby added a commit to LukeAbby/eslint-plugin-jsdoc that referenced this issue May 10, 2025
LukeAbby added a commit to LukeAbby/eslint-plugin-jsdoc that referenced this issue May 10, 2025
brettz9 added a commit that referenced this issue May 10, 2025
…1383)

* fix(lines-before-block): Only trigger after ';', '}', '|', and '&'; fixes #1379 and #1343

* fix(lines-before-block): Switch lintedPunctuators to a Set

---------

Co-authored-by: Brett Zamir <[email protected]>
@LukeAbby
Copy link
Contributor

Fixed by #1383. Wasn't closed because I couldn't link it in my PR. @brettz9 could you close this?

@brettz9 brettz9 closed this as completed May 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants