eslint常見規則總結


google: eslint+rules

es6: impot

When you import the module's default, don't use brace {}

意思是,當你使用默認的模塊時,不要加{}。如果不是默認模塊的話,請把{}加上。

定義后不使用

對象的最后一個屬性后面要加逗號

不得重復定義

縮進

constructor必須有super

constructor必須有意義,就是有其他代碼

if 后要有括號

no-trailing-spaces

最后面不能有額外的空格

關閉的標簽必須對齊

The closing bracket must be aligned with the line containing the opening tag.

// like this
<Icon 
/>

不得在refs里使用字符串

using string literals in ref attribute is deprecated.

// so should use like this:
<input 
  type="text"
  ref={(c) => {
    this.input = c;
  }}
/>

handleClick(e) {
  const node = this.input;
  const value = node.value;
}

unexpected parentheses around single function argument having a body with no 

單個函數參數周圍的意外括號具有一個沒有花括號的主體的箭頭

unexpected parentheses around single function argument having a body with no curly braces arrow-parens

箭頭函數不應該返回賦值

arrow function should not return assignment.

箭頭函數參數周圍的預期括號具有帶大括號的主體

expected parenteses around arrow function argument having a body with curly braces arrow-parens

jsx中等號前面沒有空格

there should ne no space before '='

沒有交互的元素不允許有事件

visible, non-interactive elements should not have moue or keyboard listeners jsx-ally/no-static-element-interations

common interactive roles include:

1. button
2. link
3. checkbox
4. menuitem
5. menuitemcheckbox
6. menuitemradio
7. option
8. radio
9. searchbox
10. switch
11. textbox


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM