-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
fix: prototypeを表すのに # を使わないようにする #1382
Conversation
✔️ Deploy Preview for js-primer ready! 🔨 Explore the source changes: 43d8f53 🔍 Inspect the deploy log: https://app.netlify.com/sites/js-primer/deploys/61ff3007fbcaca0008c7ab93 😎 Browse the preview: https://deploy-preview-1382--js-primer.netlify.app |
"no-use-prototype-hash": { | ||
"allow": [ | ||
// CSSセレクタの表現であるため許可 | ||
"div#result" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これだけ例外
@@ -21,6 +21,12 @@ module.exports = { | |||
}, | |||
"no-use-column": true, | |||
"footnote-order": true, | |||
"no-use-prototype-hash": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
textlintルールで、\w+#\w+
は基本的に禁止している。
getterやsetterを利用しないと実現が難しいものとして`Array#length`プロパティがあります。 | ||
`Array#length`プロパティへ値を代入すると、そのインデックス以降の要素は自動的に削除される仕様になっています。 | ||
getterやsetterを利用しないと実現が難しいものとして、`Array.prototype.length`プロパティがあります。 | ||
Arrayの`length`プロパティへ値を代入すると、そのインデックス以降の要素は自動的に削除される仕様になっています。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この章だけ prototype
自体の解説してるので、短縮表記自体(Arrayのincludes
メソッドパターン)を使わなくしてる部分がある。
修正し切れてない部分がありそうなので要チェック。
|
||
このインスタンスから`prototype`オブジェクト上に定義されたメソッドを参照できる仕組みを**プロトタイプチェーン**と呼びます。 | ||
プロトタイプチェーンの仕組みについては「[クラス][]」の章で扱うため、ここではインスタンスからプロトタイプメソッドを呼び出せるということがわかっていれば問題ありません。 | ||
|
||
<!-- textlint-disable no-use-prototype-hash,ja-technical-writing/sentence-length --> | ||
|
||
### [コラム] `Object#toString`という短縮した表記について {#prototype-shorthand-syntax} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
追加したコラム。
@@ -46,15 +46,13 @@ console.log(typeof Object.prototype.toString); // => "function" | |||
``` | |||
|
|||
このような`prototype`オブジェクトに組み込まれているメソッドは**プロトタイプメソッド**と呼ばれます。 | |||
この書籍では`Object.prototype.toString`のようなプロトタイプメソッドを`Object#toString`と短縮して表記します。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここ削除した。
@@ -214,8 +214,8 @@ Unicodeでは1文字を表すのに使う最小限のビットの組み合わせ | |||
--> | |||
|
|||
次のコードは、文字列を構成するCode Unitをhex値(16進数)にして表示する例です。 | |||
`String#charCodeAt`メソッドは、文字列の指定インデックスのCode Unitを整数として返します。 | |||
そのCode Unitの整数値を`Number#toString`メソッドでhex値(16進数)にしています。 | |||
Stringの`charCodeAt`メソッドは、文字列の指定インデックスのCode Unitを整数として返します。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stringの章 書き直しが多いので要チェック。
Stringの~~~
メソッド みたいなのが連発してたので、「Stringの」の部分も削ってる箇所が結構ある。
@@ -529,7 +529,7 @@ console.log(array.join(", ")); // => "1, 2, , , " | |||
|
|||
--> | |||
|
|||
`ArrayLike#length`のsetterで要素の追加や削除を実装することで、配列のような`length`プロパティを実装できます。 | |||
ArrayLikeの`length`プロパティのsetterで要素の追加や削除を実装することで、配列のような`length`プロパティを実装できます。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここなんか変かも。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一点だけコメントしました
Co-authored-by: Suguru Inatomi <suguru.inatomi@gmail.com>
@@ -1020,11 +1020,11 @@ console.log(str.replace(/にわ/, "niwa")); // => "niwaにはにわにわとり | |||
console.log(str.replace(/にわ/g, "niwa")); // => "niwaにはniwaniwaとりがいる" | |||
``` | |||
|
|||
文字列から検索文字列にマッチするものをすべて置換する場合には、ES2021で追加された`String#replaceAll`メソッドも利用できます。 | |||
`String#replace`メソッドでは、最初に一致したものだけが置換されますが、`String#replaceAll`メソッドでは一致したものがすべて置換されます。 | |||
文字列から検索文字列にマッチするものをすべて置換する場合には、ES2021で追加されたStringの`replaceAll`メソッドも利用できます。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
タイトル的なのでString.prototype.replaceAll
でもいいかなー
結構他の所も多いか。
#1368
#
はES2022以降だと別の意味を持つのでprototypeの意味には使わないようにする。基本ルール
Array.prototype.includes
メソッド 」を使うincludes
メソッド」を使うArray.from
静的メソッド 」と言うことで区別するa
プロパティ」という表現Class Fieldはまだ未定メンバー
と呼ぶ感じで、プロパティと区別div#result
はlintのオプションで例外としてる変更点
fix #1368