我有以下代碼:ESLint錯誤6
class Car() {
constructor() {
// ...
}
withSemi() {
// ...
}; // ESLint does not complain here
withoutSemi() {
// ...
} // ESLint does not complain here
}; // ESLint will complain about this semicolon (no-extra-semi)
有人可以解釋如何自動插入分號將ES6工作,問候類和爲什麼ESLint有這種行爲?
根據我的理解,'class'的語義與'function'類似,沒有分號,即'class name {}'和'function name(){}',所以ESLint會對其警告是正確的。 – Xotic750
那麼如何解釋方法後的分號呢? (ESLint不關心我是否添加它們)。 – adrianp
從我所看到的'方法'沒有關鍵字'函數'而定義,就像'函數'不應該結束';'。但是像'public numAttacks = 0;'這樣的表達式應該以';'結尾;所以很像你希望javascript寫在ES6前 – Xotic750