LoginSignup
14
9

More than 3 years have passed since last update.

No Newline at End of Fileって何?どう対策するの?

Posted at

No Newline at End of Fileって何?どう対策するの?

No Newline at End of Fileって何?

前提となる文化

all text files should end with a newline

A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character.

Since this is a “shall” clause, we must emit a diagnostic message for a violation of this rule.

まあつまり、空ではないソースファイルは、改行文字で終わらせなければならない。
とのことですね
C言語における標準ルールだったそうです

No Newline at End of File

どう対策するか

エディターでフォーマッターの設定をする

僕はエディターがVScodeなので
VScodeでは、ファイル末尾に自動的に改行を挿入してくれる設定があったのでそれを今回使いたい

VScodeのコマンドマレット開いて

setting
と打つと、setting.jsonが開くはずです。
そこで、

setting.json
"files.insertFinalNewline": true

と打ってください!
これでOKです

締め

先輩エンジニアの方に、「大工は自分の工具を毎日整備し、漁師は毎日漁のための道具をチェックする。そのようにエンジニアも、自分の開発環境は整備するべき。」と教えて頂いたので、今回初めてNOEOL(No end of line)問題に取り掛かってみました。

14
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
9