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

Make template-indent preserve trailing spaces #1872

Merged
merged 3 commits into from Oct 1, 2022

Conversation

mnaoumov
Copy link
Contributor

Fixes #1868

I realized that having it as a setting is not a right thing, because linter fixes should be essentially the same code, just restyled. Trimming trailing spaces essentially modifies the string and this should be considered as a bug.

Corresponding unit tests were added

@@ -67,9 +67,11 @@ const create = context => {
}

const dedented = stripIndent(joined);
const trimmed = dedented.replace(new RegExp(`^${eol}|${eol}[ \t]*$`, 'g'), '');
Copy link
Collaborator

@fisker fisker Sep 19, 2022

Choose a reason for hiding this comment

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

I don't think this is correct.

It should only remove leading/trailing empty new lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fisker This is the way it is already working and I was not sure if we should alter the existing behavior because it would be a breaking change

Copy link
Collaborator

Choose a reason for hiding this comment

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

Somehow I missed space in the regexp, it's good.

@sindresorhus sindresorhus merged commit e4071f5 into sindresorhus:main Oct 1, 2022
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.

template-indent rule should have a setting to preserve trailing spaces
3 participants