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] order: Add warnOnUnassignedImports option to enable warnings for out of order unassigned imports #1990

Merged
merged 1 commit into from
May 14, 2021

Conversation

hayes
Copy link

@hayes hayes commented Feb 12, 2021

fixes #1639

This seems like a pretty simple solution, but does have one weird side effect: The behavior of the newline option changes slightly, in that it can now remove newlines between groups correctly when there are unassigned imports. This is only the case when the new option is enabled. Updating this to make that behavior consistent (always allow new-line changes around unassigned imports) would be safe, and easy to implement, but is a breaking change, so leaving it as is seems better.

cc @Alphy11 @ljharb

@hayes
Copy link
Author

hayes commented Feb 12, 2021

@ljharb would having a configurable whitelist of extensions that are safe to autofix as unassigned imports be acceptable? I know that side effects are generally not safe to re-order, but specifically for styles, there are use cases, where either ordering them can be known to be safe for a specific application.

@Alphy11
Copy link

Alphy11 commented Feb 12, 2021

Specifically, css files are often safe to reorder (not always, but in many applications). Plus opting-in makes it a much safer operation.

@coveralls
Copy link

coveralls commented Feb 12, 2021

Coverage Status

Coverage increased (+0.9%) to 82.358% when pulling a943fd0 on hayes:mh--unassigned-imports into ad2a619 on benmosher:master.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable

@ljharb
Copy link
Member

ljharb commented May 13, 2021

@hayes let's explore that in a future issue.

@ljharb ljharb force-pushed the mh--unassigned-imports branch from d93eb29 to dedd912 Compare May 13, 2021 13:49
@ljharb ljharb changed the title [New]: Add option to enable warnings for out of order unassigned imports [New] order: Add warnOnUnassignedImports option to enable warnings for out of order unassigned imports May 13, 2021
@ljharb ljharb force-pushed the mh--unassigned-imports branch from dedd912 to a943fd0 Compare May 13, 2021 22:33
@ljharb ljharb merged commit a943fd0 into import-js:master May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

import/order doesn't sort assets that aren't assigned to a variable (e.g. import './file.css')
4 participants