Merge pull request #553 from roramirez/grunt-eslint-modules

Grunt eslint modules
This commit is contained in:
Michael Teeuw 2016-12-13 12:58:43 +01:00 committed by GitHub
commit 48db615ac8
10 changed files with 111 additions and 100 deletions

View File

@ -6,7 +6,10 @@ module.exports = function(grunt) {
options: { options: {
configFile: ".eslintrc.json" configFile: ".eslintrc.json"
}, },
target: ["js/*.js", "modules/default/*.js", "serveronly/*.js", "*.js"] target: ["js/*.js", "modules/default/*.js", "modules/default/*/*.js",
"serveronly/*.js", "*.js", "!modules/default/alert/notificationFx.js",
"!modules/default/alert/modernizr.custom.js", "!modules/default/alert/classie.js"
]
}, },
stylelint: { stylelint: {
simple: { simple: {

View File

@ -8,18 +8,18 @@
var CalendarFetcher = require("./calendarfetcher.js"); var CalendarFetcher = require("./calendarfetcher.js");
var url = 'https://calendar.google.com/calendar/ical/pkm1t2uedjbp0uvq1o7oj1jouo%40group.calendar.google.com/private-08ba559f89eec70dd74bbd887d0a3598/basic.ics'; var url = "https://calendar.google.com/calendar/ical/pkm1t2uedjbp0uvq1o7oj1jouo%40group.calendar.google.com/private-08ba559f89eec70dd74bbd887d0a3598/basic.ics";
var fetchInterval = 60 * 60 * 1000; var fetchInterval = 60 * 60 * 1000;
var maximumEntries = 10; var maximumEntries = 10;
var maximumNumberOfDays = 365; var maximumNumberOfDays = 365;
console.log('Create fetcher ...'); console.log("Create fetcher ...");
fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays); fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays);
fetcher.onReceive(function(fetcher) { fetcher.onReceive(function(fetcher) {
console.log(fetcher.events()); console.log(fetcher.events());
console.log('------------------------------------------------------------'); console.log("------------------------------------------------------------");
}); });
fetcher.onError(function(fetcher, error) { fetcher.onError(function(fetcher, error) {
@ -29,5 +29,5 @@ fetcher.onError(function(fetcher, error) {
fetcher.startFetch(); fetcher.startFetch();
console.log('Create fetcher done! '); console.log("Create fetcher done! ");

View File

@ -8,7 +8,7 @@
Module.register("clock",{ Module.register("clock",{
// Module config defaults. // Module config defaults.
defaults: { defaults: {
displayType: 'digital', // options: digital, analog, both displayType: "digital", // options: digital, analog, both
timeFormat: config.timeFormat, timeFormat: config.timeFormat,
displaySeconds: true, displaySeconds: true,
@ -18,11 +18,11 @@ Module.register("clock",{
showDate: true, showDate: true,
/* specific to the analog clock */ /* specific to the analog clock */
analogSize: '200px', analogSize: "200px",
analogFace: 'simple', // options: 'none', 'simple', 'face-###' (where ### is 001 to 012 inclusive) analogFace: "simple", // options: 'none', 'simple', 'face-###' (where ### is 001 to 012 inclusive)
analogPlacement: 'bottom', // options: 'top', 'bottom', 'left', 'right' analogPlacement: "bottom", // options: 'top', 'bottom', 'left', 'right'
analogShowDate: 'top', // options: false, 'top', or 'bottom' analogShowDate: "top", // options: false, 'top', or 'bottom'
secondsColor: '#888888', secondsColor: "#888888",
timezone: null, timezone: null,
}, },
// Define required scripts. // Define required scripts.
@ -112,7 +112,7 @@ Module.register("clock",{
* Create wrappers for ANALOG clock, only if specified in config * Create wrappers for ANALOG clock, only if specified in config
*/ */
if (this.config.displayType !== 'digital') { if (this.config.displayType !== "digital") {
// If it isn't 'digital', then an 'analog' clock was also requested // If it isn't 'digital', then an 'analog' clock was also requested
// Calculate the degree offset for each hand of the clock // Calculate the degree offset for each hand of the clock
@ -131,10 +131,10 @@ Module.register("clock",{
clockCircle.style.width = this.config.analogSize; clockCircle.style.width = this.config.analogSize;
clockCircle.style.height = this.config.analogSize; clockCircle.style.height = this.config.analogSize;
if (this.config.analogFace != '' && this.config.analogFace != 'simple' && this.config.analogFace != 'none') { if (this.config.analogFace != "" && this.config.analogFace != "simple" && this.config.analogFace != "none") {
clockCircle.style.background = "url("+ this.data.path + "faces/" + this.config.analogFace + ".svg)"; clockCircle.style.background = "url("+ this.data.path + "faces/" + this.config.analogFace + ".svg)";
clockCircle.style.backgroundSize = "100%"; clockCircle.style.backgroundSize = "100%";
} else if (this.config.analogFace != 'none') { } else if (this.config.analogFace != "none") {
clockCircle.style.border = "2px solid white"; clockCircle.style.border = "2px solid white";
} }
var clockFace = document.createElement("div"); var clockFace = document.createElement("div");
@ -168,18 +168,18 @@ Module.register("clock",{
* Combine wrappers, check for .displayType * Combine wrappers, check for .displayType
*/ */
if (this.config.displayType === 'digital') { if (this.config.displayType === "digital") {
// Display only a digital clock // Display only a digital clock
wrapper.appendChild(dateWrapper); wrapper.appendChild(dateWrapper);
wrapper.appendChild(timeWrapper); wrapper.appendChild(timeWrapper);
} else if (this.config.displayType === 'analog') { } else if (this.config.displayType === "analog") {
// Display only an analog clock // Display only an analog clock
dateWrapper.style.textAlign = "center"; dateWrapper.style.textAlign = "center";
dateWrapper.style.paddingBottom = "15px"; dateWrapper.style.paddingBottom = "15px";
if (this.config.analogShowDate === 'top') { if (this.config.analogShowDate === "top") {
wrapper.appendChild(dateWrapper); wrapper.appendChild(dateWrapper);
wrapper.appendChild(clockCircle); wrapper.appendChild(clockCircle);
} else if (this.config.analogShowDate === 'bottom') { } else if (this.config.analogShowDate === "bottom") {
wrapper.appendChild(clockCircle); wrapper.appendChild(clockCircle);
wrapper.appendChild(dateWrapper); wrapper.appendChild(dateWrapper);
} else { } else {
@ -199,11 +199,11 @@ Module.register("clock",{
digitalWrapper.appendChild(dateWrapper); digitalWrapper.appendChild(dateWrapper);
digitalWrapper.appendChild(timeWrapper); digitalWrapper.appendChild(timeWrapper);
if (placement === 'left' || placement === 'right') { if (placement === "left" || placement === "right") {
digitalWrapper.style.display = "inline-block"; digitalWrapper.style.display = "inline-block";
digitalWrapper.style.verticalAlign = "top"; digitalWrapper.style.verticalAlign = "top";
analogWrapper.style.display = "inline-block"; analogWrapper.style.display = "inline-block";
if (placement === 'left') { if (placement === "left") {
analogWrapper.style.padding = "0 20px 0 0"; analogWrapper.style.padding = "0 20px 0 0";
wrapper.appendChild(analogWrapper); wrapper.appendChild(analogWrapper);
wrapper.appendChild(digitalWrapper); wrapper.appendChild(digitalWrapper);
@ -214,7 +214,7 @@ Module.register("clock",{
} }
} else { } else {
digitalWrapper.style.textAlign = "center"; digitalWrapper.style.textAlign = "center";
if (placement === 'top') { if (placement === "top") {
analogWrapper.style.padding = "0 0 20px 0"; analogWrapper.style.padding = "0 0 20px 0";
wrapper.appendChild(analogWrapper); wrapper.appendChild(analogWrapper);
wrapper.appendChild(digitalWrapper); wrapper.appendChild(digitalWrapper);

View File

@ -117,7 +117,7 @@ Module.register("compliments",{
complimentFile: function(callback) { complimentFile: function(callback) {
var xobj = new XMLHttpRequest(); var xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json"); xobj.overrideMimeType("application/json");
xobj.open('GET', this.file(this.config.remoteFile), true); xobj.open("GET", this.file(this.config.remoteFile), true);
xobj.onreadystatechange = function () { xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") { if (xobj.readyState == 4 && xobj.status == "200") {
callback(xobj.responseText); callback(xobj.responseText);

View File

@ -166,7 +166,7 @@ Module.register("currentweather",{
} }
if (!this.loaded) { if (!this.loaded) {
wrapper.innerHTML = this.translate('LOADING'); wrapper.innerHTML = this.translate("LOADING");
wrapper.className = "dimmed light small"; wrapper.className = "dimmed light small";
return wrapper; return wrapper;
} }
@ -323,20 +323,20 @@ Module.register("currentweather",{
// So we need to generate the timestring manually. // So we need to generate the timestring manually.
// See issue: https://github.com/MichMich/MagicMirror/issues/181 // See issue: https://github.com/MichMich/MagicMirror/issues/181
var sunriseSunsetDateObject = (sunrise < now && sunset > now) ? sunset : sunrise; var sunriseSunsetDateObject = (sunrise < now && sunset > now) ? sunset : sunrise;
var timeString = moment(sunriseSunsetDateObject).format('HH:mm'); var timeString = moment(sunriseSunsetDateObject).format("HH:mm");
if (this.config.timeFormat !== 24) { if (this.config.timeFormat !== 24) {
//var hours = sunriseSunsetDateObject.getHours() % 12 || 12; //var hours = sunriseSunsetDateObject.getHours() % 12 || 12;
if (this.config.showPeriod) { if (this.config.showPeriod) {
if (this.config.showPeriodUpper) { if (this.config.showPeriodUpper) {
//timeString = hours + moment(sunriseSunsetDateObject).format(':mm A'); //timeString = hours + moment(sunriseSunsetDateObject).format(':mm A');
timeString = moment(sunriseSunsetDateObject).format('h:mm A'); timeString = moment(sunriseSunsetDateObject).format("h:mm A");
} else { } else {
//timeString = hours + moment(sunriseSunsetDateObject).format(':mm a'); //timeString = hours + moment(sunriseSunsetDateObject).format(':mm a');
timeString = moment(sunriseSunsetDateObject).format('h:mm a'); timeString = moment(sunriseSunsetDateObject).format("h:mm a");
} }
} else { } else {
//timeString = hours + moment(sunriseSunsetDateObject).format(':mm'); //timeString = hours + moment(sunriseSunsetDateObject).format(':mm');
timeString = moment(sunriseSunsetDateObject).format('h:mm'); timeString = moment(sunriseSunsetDateObject).format("h:mm");
} }
} }

View File

@ -44,9 +44,9 @@ var Fetcher = function(url, reloadInterval, encoding) {
parser.on("item", function(item) { parser.on("item", function(item) {
var title = item.title; var title = item.title;
var description = item.description || item.summary || item.content || ''; var description = item.description || item.summary || item.content || "";
var pubdate = item.pubdate || item.published || item.updated; var pubdate = item.pubdate || item.published || item.updated;
var url = item.url || item.link || ''; var url = item.url || item.link || "";
if (title && pubdate) { if (title && pubdate) {
@ -81,7 +81,7 @@ var Fetcher = function(url, reloadInterval, encoding) {
scheduleTimer(); scheduleTimer();
}); });
var headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A'}; var headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"};
request({uri: url, encoding: null, headers: headers}).pipe(iconv.decodeStream(encoding)).pipe(parser); request({uri: url, encoding: null, headers: headers}).pipe(iconv.decodeStream(encoding)).pipe(parser);
}; };

View File

@ -25,8 +25,8 @@ Module.register("newsfeed",{
updateInterval: 10 * 1000, updateInterval: 10 * 1000,
animationSpeed: 2.5 * 1000, animationSpeed: 2.5 * 1000,
maxNewsItems: 0, // 0 for unlimited maxNewsItems: 0, // 0 for unlimited
removeStartTags: '', removeStartTags: "",
removeEndTags: '', removeEndTags: "",
startTags: [], startTags: [],
endTags: [] endTags: []
@ -93,17 +93,25 @@ Module.register("newsfeed",{
var sourceAndTimestamp = document.createElement("div"); var sourceAndTimestamp = document.createElement("div");
sourceAndTimestamp.className = "light small dimmed"; sourceAndTimestamp.className = "light small dimmed";
if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== '') sourceAndTimestamp.innerHTML = this.newsItems[this.activeItem].sourceTitle; if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== "") {
if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== '' && this.config.showPublishDate) sourceAndTimestamp.innerHTML += ', '; sourceAndTimestamp.innerHTML = this.newsItems[this.activeItem].sourceTitle;
if (this.config.showPublishDate) sourceAndTimestamp.innerHTML += moment(new Date(this.newsItems[this.activeItem].pubdate)).fromNow(); }
if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== '' || this.config.showPublishDate) sourceAndTimestamp.innerHTML += ':'; if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== "" && this.config.showPublishDate) {
sourceAndTimestamp.innerHTML += ", ";
}
if (this.config.showPublishDate) {
sourceAndTimestamp.innerHTML += moment(new Date(this.newsItems[this.activeItem].pubdate)).fromNow();
}
if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== "" || this.config.showPublishDate) {
sourceAndTimestamp.innerHTML += ":";
}
wrapper.appendChild(sourceAndTimestamp); wrapper.appendChild(sourceAndTimestamp);
} }
//Remove selected tags from the beginning of rss feed items (title or description) //Remove selected tags from the beginning of rss feed items (title or description)
if (this.config.removeStartTags == 'title' || 'both') { if (this.config.removeStartTags == "title" || "both") {
for (f=0; f<this.config.startTags.length;f++) { for (f=0; f<this.config.startTags.length;f++) {
if (this.newsItems[this.activeItem].title.slice(0,this.config.startTags[f].length) == this.config.startTags[f]) { if (this.newsItems[this.activeItem].title.slice(0,this.config.startTags[f].length) == this.config.startTags[f]) {
@ -113,7 +121,7 @@ Module.register("newsfeed",{
} }
if (this.config.removeStartTags == 'description' || 'both') { if (this.config.removeStartTags == "description" || "both") {
if (this.config.showDescription) { if (this.config.showDescription) {
for (f=0; f<this.config.startTags.length;f++) { for (f=0; f<this.config.startTags.length;f++) {
@ -234,10 +242,10 @@ Module.register("newsfeed",{
for (var f in this.config.feeds) { for (var f in this.config.feeds) {
var feed = this.config.feeds[f]; var feed = this.config.feeds[f];
if (feed.url === feedUrl) { if (feed.url === feedUrl) {
return feed.title || ''; return feed.title || "";
} }
} }
return ''; return "";
}, },
/* scheduleUpdateInterval() /* scheduleUpdateInterval()

View File

@ -35,8 +35,8 @@ module.exports = NodeHelper.create({
createFetcher: function(feed, config) { createFetcher: function(feed, config) {
var self = this; var self = this;
var url = feed.url || ''; var url = feed.url || "";
var encoding = feed.encoding || 'UTF-8'; var encoding = feed.encoding || "UTF-8";
var reloadInterval = config.reloadInterval || 5 * 60 * 1000; var reloadInterval = config.reloadInterval || 5 * 60 * 1000;
if (!validUrl.isUri(url)) { if (!validUrl.isUri(url)) {

View File

@ -22,7 +22,7 @@ module.exports = NodeHelper.create({
var stat; var stat;
try { try {
stat = fs.statSync(path.join(moduleFolder, '.git')); stat = fs.statSync(path.join(moduleFolder, ".git"));
} catch(err) { } catch(err) {
// Error when directory .git doesn't exist // Error when directory .git doesn't exist
// This module is not managed with git, skip // This module is not managed with git, skip

View File

@ -59,7 +59,7 @@ Module.register("updatenotification", {
var subtext = document.createElement("div"); var subtext = document.createElement("div");
subtext.innerHTML = this.translate("UPDATE_INFO") subtext.innerHTML = this.translate("UPDATE_INFO")
.replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1)? 'commit' : 'commits')) .replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1)? "commit" : "commits"))
.replace("BRANCH_NAME", this.status.current); .replace("BRANCH_NAME", this.status.current);
subtext.className = "xsmall dimmed"; subtext.className = "xsmall dimmed";
wrapper.appendChild(subtext); wrapper.appendChild(subtext);