2016-10-24 24 views
1

まあ、私はBabelに偽陽性のエラーがあります。偽のエラー:コンストラクタ名は、小文字のbabel/new-capで始めるべきではありません。

これはコンソールのエラーです。

ERROR in ./src/app/playlist/playlist.js 

/Users/macbook-lucas/refreex/src/app/playlist/playlist.js 
    6:23 error A constructor name should not start with a lowercase letter babel/new-cap 

✖ 1 problem (1 error, 0 warnings) 

@ ./src/app/playlist/index.js 12:16-37 
@ ./src/index.js 

そして、ここのコードです:私はバベルについて何も知らない

が、私の本能は、式new fooは()想定していると述べている:

import {webtorrent} from 'webtorrent'; 

class PlaylistController { 
    contructor() { 
    this.TorrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel-1024-surround.mp4'; 
    this.Client = new webtorrent(); 
    } 
} 

export const playlist = { 
    templateUrl: "app/playlist/playlist.html", 
    controller: PlaylistController, 
    bindings: { 
    playlist: '<' 
    } 
}; 
+0

私はBabelについて何も知らないが、私の本能は、 'new foo()'という表現は 'foo'クラスのオブジェクトを構築することになっていると言っている。したがって、クラス名が大文字で始まる場合は、 'new Foo()'にする必要があります。あなたのケースでは '新しいWebtorrent()'があります(エラーメッセージに従って6行目を見てください)。 – rici

+0

これはあなたが偽陽性であると感じることはどうか分かりません。あなたのリンター設定のどこかで、 'new-cap'を有効にして、今は小文字のコンストラクターを使用しています。ルールは失敗する必要があります。 – loganfsmyth

+0

私はあなたが混乱していると思う、このエラーはESLintからであり、Babelではない。 Babelはこのコードを問題なくコンパイルしますが、小文字のコンストラクタでエラーが発生するESLintルールを有効にしています。 – loganfsmyth

答えて

1

RICIは述べています同様クラスfooのオブジェクトを構築します。したがって、クラス名が大文字で始まる場合は、新しいFoo()でなければなりません。あなたのケースでは、新しいWebtorrent()を使用してください(エラーメッセージに従って6行目を参照)。 -

関連する問題