Skip to content

Instantly share code, notes, and snippets.

@furu
Created June 12, 2014 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save furu/e8d4cbf825b0d11cfdae to your computer and use it in GitHub Desktop.
Save furu/e8d4cbf825b0d11cfdae to your computer and use it in GitHub Desktop.

EditorConfig の紹介をするだけ - LT駆動開発 04

EditorConfig

  • キャラクターが眼鏡鼠
  • 知性を感じる
  • 名前何なんだろう
  • 異なるエディターや IED 間での一貫性のあるコーディングスタイルを定義しメンテナンス することを手助けするよ
  • GitHub の editorconfig/editorconfig の Wiki のどこかで EditorConfig を使っているプロジェクトの一覧が見れる
  • 何個かピックアップする?
  • Twitter Bootstrap
  • CakePHP
  • Chocolatey
  • jQuery
  • Modernizr
  • Octopress
  • Ruby
  • Zsh
  • 正直、あんまり .editorconfig 置いてあるリポジトリ見ないけどね
  • .editorconfig のサンプルを見せててきとーに少し説明する
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# 4 space indentation
[*.py]
indent_style = space
indent_size = 4

# Tab indentation (no size specified)
[*.js]
indent_style = tab

# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 2

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

使い方

  1. EditorConfig のコアライブラリを何か入れるどうにかして
  • eix editorconfig -> No matches found. f*ck!
  1. お好きなエディターや IDE のプラグインをどうにか導入して有効にする
  2. .editorconfig をみんなで相談して書く
  3. 使う
  4. やったぜ

EditorConfig の設定ファイルについて

  • 名前は、.editorconfig でなければならない
  • ファイルフォーマットは、INI
  • UTF-8CRLFLF でないといけないらしいけどなんでだ

.editorconfig の探索

  1. 開いたファイルのディレクトリから探す
  2. その親ディレクトリから探す
  3. ルートまでいくか、.editorconfig に root=true が設定されていれば、そこで探索を終える

プロパティは上書きされるの?

よさそうプロパティ

何個か選ぶ

  • ハードタブ or ソフトタブ
  • インデントサイズ
  • 2? 4? 16?
  • 改行コード
  • LF? CR? CRLF?
  • 文字コード
  • Only latin1, utf-8, utf-16be, utf-16e
  • ファッ!? euc-jp? sjis?
  • 行末スペースの削除
  • Wow, it's very exiting feature!
  • ファイルの最後に改行を入れる
  • なんで入れたほうがいいんだっけ?

プラグイン

  • 画像をダウンロードして、それらで紹介する
  • Vim の画像だけ大きくするというネタ
  • アイコンが良い雰囲気を出している
  • すべてのプラグインですべてのプロパティがサポートされているわけではないというつらみ

プラグインの作成

  • EditorConfig のコアライブラリの1つを使って開発できる
  • C
  • Python
  • Java
  • JavaScript
  • editorconfig.org の Create a plugin にどうすればよいのか書いてある
  • プラグインを作成するために必要なことは用意されている印象

感想

  • コードを整形 というコミットメッセージは、やばい匂いでは
  • OSS だとあまり必要はないのかもしれない
  • 意識が高い
  • gofmt
  • 手軽そうに見えて、割と壁がある
  • 各自でコアライブラリを入れ、エディターや IDE のプラグインを設定しなければならない
  • めんどくさい人にはめんどくさい作業
  • コードは読む時間の方が多い
  • まだチームで使っていないので効果はわからん
  • エントロピー
  • 達人プログラマーのどっかのページ。きれいなところは汚したくないし、 汚ないところでは、きれいにする気力が湧かず汚ないままである、みたいな話。

This file is written with the Atom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment