Skip to content
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

New Rule: newline-above-import #3137

Open
Deadmano opened this issue Jan 7, 2025 · 3 comments
Open

New Rule: newline-above-import #3137

Deadmano opened this issue Jan 7, 2025 · 3 comments

Comments

@Deadmano
Copy link

Deadmano commented Jan 7, 2025

Any chance for a rule that allows for adding a newline above the first import?

@ljharb
Copy link
Member

ljharb commented Jan 7, 2025

For what purpose?

@Deadmano
Copy link
Author

Deadmano commented Jan 8, 2025

@ljharb I end up having a JSDoc comment at the top of each file that has a license:

/**
 * @license MIT
 * This file is part of Example Project.
 * Copyright © Author
 */
import { CommentState, FormattingState, LineState } from '../config/types';

I'd like to ensure that if there is no space above the first import, one gets added (for consistency). The same way rules such as newline-after-import handle it, but in reverse.

@ljharb
Copy link
Member

ljharb commented Jan 8, 2025

The “after” rule is because command line tools work better when all files have a trailing newline, not for aesthetics or anything.

Since per-file license boilerplate is a bad practice, I’m not sure that’s sufficiently motivating reason to add an entirely new rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants