Conversation
PeterPanZH
suggested changes
Dec 6, 2022
| } | ||
| ``` | ||
|
|
||
| ### 【强制】要求适当处理类似 Promise 的语句 @佘采华 |
PeterPanZH
reviewed
Dec 6, 2022
|
|
||
| 详细的标签嵌套规则参见[HTML DTD](http://www.cs.tut.fi/~jkorpela/html5.dtd)中的 `Elements` 定义部分。 | ||
|
|
||
| 详细的标签嵌套规则参见[HTMLf外](https://html.spec.whatwg.org/multipage/)中各元素定义的“Content model”说明。 |
| </table> | ||
| ``` | ||
|
|
||
| #### [强制] 新窗口/标签页打开的链接需要按业务需要添加安全相关的 `rel` 属性值 `noopener`。 |
Member
Author
There was a problem hiding this comment.
不,noreferrer是业务诉求,noopener是安全诉求,不考虑在编码规范上去要求业务怎么样
|
|
||
| 对于函数声明(Function Declaration)、类声明(Class Declaration),它们不属于语句(Statement),因此不需要以分号结束。 | ||
|
|
||
| 对于 `export default` 语句,参考其后部分的类型,如果是函数、类声明,同样不需要分号。 |
Member
Author
There was a problem hiding this comment.
我想named export应该不会有人误解,export default比较特殊些所以特别说明
| 解释: | ||
|
|
||
| 除去不定长参数以外,函数具备不同逻辑意义的参数建议控制在 `6` 个以内,过多参数会导致维护难度增大。 | ||
| ##### [建议] 一个函数的参数控制在 **6**** 个以内。 |
| } | ||
| ``` | ||
|
|
||
| ### [强制]禁止不必要的类型约束 |
There was a problem hiding this comment.
相关讨论:#65
我理解 lint 的职责一方面是统一代码格式,另一方面就是引导使用者写出简洁的代码。
像上面的一系列『禁止不必要……』就很好的体现了这一点。与『不必要的断言』、『不必要的参数』不同的地方是,类型约束在某些场景下是必要的 ,就像我上面举的例子中,它关乎到能否正确解析代码。即便这个必要是由于语法缺陷导致的,但这确实是一个会遇到的场景。
与它类似的,就像 const a = ({}) 是不必要的圆括号,而 () => ({}) 是有必要的一样的。在 tsx 文件中写带有泛型的箭头函数,这个事情本身没有什么不合理之处。如果强制禁止,会否让开发者太过受限,而背离了写简洁代码的初衷。
Member
Author
There was a problem hiding this comment.
参考 typescript-eslint/typescript-eslint#4062 ,官方似乎并没有修正的想法,我们可以考虑ts和tsx使用不同的规则
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.