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

Fix prettier and other rules working at the same time #360

Merged
merged 2 commits into from
Jul 13, 2024

Conversation

dartess
Copy link
Contributor

@dartess dartess commented Jul 1, 2024

Closed #354

I'm not a stylelint guru. But at least I added a test demonstrating the bug, and added a description of the problem that this bug causes.

@@ -182,7 +182,7 @@ const ruleFunction = (expectation, options, context) => {
insertText +
rawData.substring(difference.offset + deleteText.length)
);
}, root.source.input.css);
}, source);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it looks like the prettier always runs on the raw input data, and not on the current version of the code (some rules may have done their job before the prettier).

@@ -107,6 +106,7 @@ const ruleFunction = (expectation, options, context) => {

let prettierSource;

const source = root.toString();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where asynchrony comes into play. Previously, this code was executed before some asynchronous operations, and it turned out that first this plugin gets the code, after that other rules made changes to the code, and after that the prettier was launched on the old version of the code. Now this code works synchronously because it runs after all asynchronous operations.

@BPScott BPScott merged commit 35efe65 into prettier:main Jul 13, 2024
2 checks passed
BPScott pushed a commit that referenced this pull request Jul 17, 2024
* add test for less (issue #362)

* fix issue #362
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stylelint-prettier doesn't fix problems at the same time as removing empty extra lines
2 participants