Glavin001/tslint-clean-code

Create a whitelist for id-length rule

Open

#40 建立於 2018年2月13日

在 GitHub 查看
 (4 留言) (0 反應) (1 負責人)TypeScript (15 fork)github user discovery
buggood first issuehelp wanted

倉庫指標

Star
 (175 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Hello and thank you for your work.

The id-length rule is great for forbidding one-letter variable names. However, there are cases where one-letter symbols would actually be preferred: type parameters (GenericTypeAnnotation nodes) and holes.

Holes

Array
  .from({ length: 10 })
  .map((_, index) => index);

Type parameters

function unique<T>(collection: T[]): T[] {
  return [...new Set(collection)];
}

What do you think about passing a config that would allow them?

"id-length": [true, {
  "check-type-parameters": false,
  "allow": ["_"]
}]

貢獻者指南