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

Unable to specify a new line after a header using a template file #37

Open
jonnycornwell opened this issue Apr 1, 2021 · 3 comments · May be fixed by #45
Open

Unable to specify a new line after a header using a template file #37

jonnycornwell opened this issue Apr 1, 2021 · 3 comments · May be fixed by #45

Comments

@jonnycornwell
Copy link

I am trying to use a template header from file but due to the fact that it trims when loading from file it is removing the trailing new lines which I require due to microsoft/TypeScript#12307 (comment). I am also unable to specify a newline going the route with a single argument.

It would be good to either not trim the comment when loading from a file (though this would be a major breaking change as some users may depend on it) or maybe support adding newlines when using the template file?

@Stuk
Copy link
Owner

Stuk commented Apr 5, 2021

If it understand the linked comment correctly, the newline must be in-between the comment and the first line, rather than within the comment itself. Maybe I'm misunderstanding though?

@shorsher
Copy link

shorsher commented Jun 2, 2021

Yes.

If your file is

console.log(1)

and your license is (see blank line beneath final comment)

// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

your file would become

// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
console.log(1)

The trailing line is not preserved.

@liarco
Copy link

liarco commented Sep 24, 2021

Same issue here, the template file is trimmed by the comment parser:

text = text.trim();

This makes it impossible to force new lines at the end of the comment while using a template file.

liarco added a commit to liarco/eslint-plugin-header that referenced this issue Sep 24, 2021
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 a pull request may close this issue.

4 participants