Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

False Error: A constructor name should not start with a lowercase letter babel/new-cap

Well I have an false positive error with Babel.

This is the error in the console.

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

And here is the code:

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: '<'
  }
};
like image 906
Merlyn007 Avatar asked Oct 29 '22 18:10

Merlyn007


1 Answers

Like rici says:

I don't know anything about Babel, but my instinct says that the expression new foo() is supposed to construct an object of class foo. So if class names must start with capital letters, that would have to be new Foo(). Or new Webtorrent(), in your case (see line 6, as per the error message). –

like image 128
Merlyn007 Avatar answered Nov 09 '22 07:11

Merlyn007