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

refactor(textlint): add no-js-function-paren #143

Merged
merged 2 commits into from
Sep 29, 2016
Merged

refactor(textlint): add no-js-function-paren #143

merged 2 commits into from
Sep 29, 2016

Conversation

azu
Copy link
Collaborator

@azu azu commented Sep 28, 2016

fn()の表記を原則禁止にして、fn関数と書くように変更

close #141
close #110

/cc @laco0416 こんな感じ

`fn()`の表記を原則禁止にして、`fn`関数と書くように変更
@@ -67,10 +67,14 @@ function displayView(view) {
コールバック関数を使うと、ソースコードのネストが深くなったり、例外処理が複雑になったりします。
Promiseを用いることで、可読性を保ちながらエラーハンドリングを簡単に行えます。

<!-- textlint-disable no-js-function-paren -->

コールバック関数を使う形式のAPIをPromiseに置き換えるのは、次のコードのように`new Promise()`を用いるのが一般的です。
Copy link
Collaborator

Choose a reason for hiding this comment

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

書き直すとしたら "Promiseのコンストラクタを呼び出します"あたりですかね

Copy link
Collaborator Author

@azu azu Sep 28, 2016

Choose a reason for hiding this comment

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

Promise() とも読めるから、Promiseをインスタンス化する or new するみたいな感じかなー。
コンストラクタって用語が扱いにくい…

  • new Foo Fooをインスタンス化する(Fooクラスとはいえないのが厄介…)
  • Foo() Fooコンストラクタ関数を呼び出す

かなー

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ここでは、Promiseをインスタンス化したいってより、new Promise()というパターンで書くのが一般的ですみたいな話だからそのままでもいいかなと思ったりしました。
(別の書き方として Promise.resolve().then(() => ) で書くパターンもあるけど、あんまりみないかな)

@@ -45,6 +45,6 @@ Console APIは原始的なプリントデバッグとして利用できるので
「この値は何だろう」と思ったらコンソールに表示してみることで解決する問題は多いです。

また、JavaScriptの開発環境は高機能化が進んでいるため、デバッガーなどが用意されていることが多く、
コードに`console.log()`と書かなくても値を見ることもできるようになっています
コードに`console.log`メソッドを書かなくても値を見ることもできるようになっています
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

関係ないけど、この表現冗長だな…

@azu azu merged commit c245888 into master Sep 29, 2016
@azu azu deleted the use-fn-format branch September 29, 2016 13:16
@azu
Copy link
Collaborator Author

azu commented Sep 29, 2016

とりあえずマージします

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

Successfully merging this pull request may close these issues.

表記統一: 関数/メソッド クラスメソッド/インスタンスメソッドの表記
2 participants