-
Notifications
You must be signed in to change notification settings - Fork 0
Coding Style Guide
You should use linter, such as rubocop (for ruby), and eslint and prettier (for JS), to comply with the coding styles. And integrate them with your editor. There're Japanese version in each link.
Especially, you should care about time.
This RSpec style guide outlines the recommended best practices for real-world programmers to write code that can be maintained by other real-world programmers.
- The following rules can be ignored.
Use ES2015 (ES6) for a new project. Then transpile the JS code to ES5 with babel (using webpacker in Rails5). You're supposed to put the code under
app/javascript/packs/(example).
Never use CoffeeScript.
See Awesome ESLint, Prettier and ESLint Watch
Think of using a frontend framework such as Vue.js or React.js instead of jQuery if the frontend logic is complex.
JavaScript Styleguide (ES2015 (ES6)) by Airbnb
JavaScript Styleguide (ES2015 (ES6)) by Airbnb (Japanese)
JavaScript Styleguide (ES5) by Airbnb
チーム開発
■チームとしてコーディング規約を定めて、チームメンバーはアサイン時に読んでおく。Ruby/Rails/Rspecに関して、先立つものとしては以下。そのまま使っても良い。改変分、追加分はドキュメントとして残す(要READMEからリンク)。
- Ruby/Rails
- https://github.com/fortissimo1997/ruby-style-guide/blob/japanese/README.ja.md
- https://github.com/satour/rails-style-guide/blob/master/README-jaJA.md
- rspec
- https://github.com/rubocop-hq/rspec-style-guide
- http://www.betterspecs.org/jp/
■linter(Ruby では rubucop) + hook(overcommit など)を使って、コーディング規約を遵守する(※開発途中から入れると大量の違反が出ると思うが、autocorrect で直せるところだけ直し、今後の開発はコーディング規約を遵守でも有りかも)。
■ .github/PULL_REQUEST_TEMPLATE.md を作って、PRレビュー依頼時にレビューアーに共有すべき内容、及び自己チェックを行う。以下は私が過去に使っていたものです。「チェックリスト」部分は、プロジェクトメンバーの成熟度で違って来ます。例えば model, controller 毎に、もっと詳細にチェックリストを作っていたこともありますし(※オフショア開発時)、もっと項目が少なかったこともあります。
ある程度経験があるメンバーでも、凡ミスを防ぐためにあっていいと思っています。
■rubocopの設定
- ABC Sizeの妥当性