是否可以通過 eslint 強制執行以下規則?
- 如果函式引數的數量多于一個,則使用“object”作為引數。
例如,
- 好的
- const f = (x: string) => ...
- const f = (x: {id: string}) => ...
- const f = (x: {id: string; name: string}) => ...
- 壞的
- const f= (x: string; y: string) => ...
我查看了官方檔案(https://eslint.org/docs/rules/),但找不到合適的規則。我想知道是否某種自定義規則可以實作這一點。
uj5u.com熱心網友回復:
您可以使用max-params規則。https://eslint.org/docs/rules/max-params將max值設定為1.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/421805.html
標籤:
