A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
  • Config Error

    Troubleshooting
    39
    0 Votes
    39 Posts
    6k Views
    evroomE

    @BKeyport said in Config Error:

    @evroom “convention” isn’t the right word here, perhaps. I’m almost leaning to “peer pressure” perhaps? Doing it because it seems everyone else is?

    I had to read the beginning of the thread first before starting ‘name-calling’ :-) And perhaps had to address it to the thread starter @PHAGE-GOV, for learning purposes
    Some people treat the config.js file as code and think that they are actually coding. In principle a JS file is a text file containing JavaScript code, so it is a bit misleading, although it contains “var config =”, which suggests it being a part of some code.
    IMHO it would be better to use the json extension, so config.json, as it is based on JSON and stores data structures and objects in this format.

    One should’t care less how coders use variables in their programs (as Sam said: “make names meaningful, use case where appropriate”, especially if you want to keep it maintainable or want to hand it over to someone else), but in case of config.js one should make at least a bit of an effort to keep it simple and understandable. Again: IMHO.

    In my book this is for example a no-go:

    { location: "New York", locationID: "", appid: "YOUR_OPENWEATHER_API_KEY" }

    This is just waiting for an accident to happen.
    What is wrong using locationName, locationId and apiId ?
    Or location, location_id and api_id ?
    Probably nitpicking from my side, but it hurts my eyes :-)

    I would say “make names meaningful, use case where appropriate and keep it consistent”.

    I also know it it all voluntary work and it does not cost a dime (unless you donate something to the author, like I did) and therefore one is not really allowed to complain :-) I hope some constructive criticism is allowed though. Do not want to offend anyone.

    That being said, just enjoy your MagicMirror. :-)

  • Modules again.....

    Development
    11
    0 Votes
    11 Posts
    4k Views
    idoodlerI

    @sdetweil Actualy JSON requires quotation of the key and of the value (if the value is a string)

    Example of a JSON file:

    { "string": "This is a string", "bool": true, "int", 1, "float": 3.14, "arrayOfStrings": [ "string1", "string2" ], "arrayOfInts": [ 1, 2 ] }

    The same can be used in a Javascript file, but as an object. You can also throw away the quotation of the keys.