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: {
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: {
simple: {
@ -63,4 +66,4 @@ module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-yamllint");
grunt.loadNpmTasks("grunt-markdownlint");
grunt.registerTask("default", ["eslint", "stylelint", "jsonlint", "markdownlint", "yamllint"]);
};
};

View File

@ -8,18 +8,18 @@
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 maximumEntries = 10;
var maximumNumberOfDays = 365;
console.log('Create fetcher ...');
console.log("Create fetcher ...");
fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays);
fetcher.onReceive(function(fetcher) {
console.log(fetcher.events());
console.log('------------------------------------------------------------');
console.log(fetcher.events());
console.log("------------------------------------------------------------");
});
fetcher.onError(function(fetcher, error) {
@ -29,5 +29,5 @@ fetcher.onError(function(fetcher, error) {
fetcher.startFetch();
console.log('Create fetcher done! ');
console.log("Create fetcher done! ");

View File

@ -8,7 +8,7 @@
Module.register("clock",{
// Module config defaults.
defaults: {
displayType: 'digital', // options: digital, analog, both
displayType: "digital", // options: digital, analog, both
timeFormat: config.timeFormat,
displaySeconds: true,
@ -18,11 +18,11 @@ Module.register("clock",{
showDate: true,
/* specific to the analog clock */
analogSize: '200px',
analogFace: 'simple', // options: 'none', 'simple', 'face-###' (where ### is 001 to 012 inclusive)
analogPlacement: 'bottom', // options: 'top', 'bottom', 'left', 'right'
analogShowDate: 'top', // options: false, 'top', or 'bottom'
secondsColor: '#888888',
analogSize: "200px",
analogFace: "simple", // options: 'none', 'simple', 'face-###' (where ### is 001 to 012 inclusive)
analogPlacement: "bottom", // options: 'top', 'bottom', 'left', 'right'
analogShowDate: "top", // options: false, 'top', or 'bottom'
secondsColor: "#888888",
timezone: null,
},
// Define required scripts.
@ -92,7 +92,7 @@ Module.register("clock",{
}
}
if(this.config.showDate){
dateWrapper.innerHTML = now.format("dddd, LL");
dateWrapper.innerHTML = now.format("dddd, LL");
}
timeWrapper.innerHTML = timeString;
secondsWrapper.innerHTML = now.format("ss");
@ -112,7 +112,7 @@ Module.register("clock",{
* 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
// 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.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.backgroundSize = "100%";
} else if (this.config.analogFace != 'none') {
} else if (this.config.analogFace != "none") {
clockCircle.style.border = "2px solid white";
}
var clockFace = document.createElement("div");
@ -168,18 +168,18 @@ Module.register("clock",{
* Combine wrappers, check for .displayType
*/
if (this.config.displayType === 'digital') {
if (this.config.displayType === "digital") {
// Display only a digital clock
wrapper.appendChild(dateWrapper);
wrapper.appendChild(timeWrapper);
} else if (this.config.displayType === 'analog') {
} else if (this.config.displayType === "analog") {
// Display only an analog clock
dateWrapper.style.textAlign = "center";
dateWrapper.style.paddingBottom = "15px";
if (this.config.analogShowDate === 'top') {
if (this.config.analogShowDate === "top") {
wrapper.appendChild(dateWrapper);
wrapper.appendChild(clockCircle);
} else if (this.config.analogShowDate === 'bottom') {
} else if (this.config.analogShowDate === "bottom") {
wrapper.appendChild(clockCircle);
wrapper.appendChild(dateWrapper);
} else {
@ -199,11 +199,11 @@ Module.register("clock",{
digitalWrapper.appendChild(dateWrapper);
digitalWrapper.appendChild(timeWrapper);
if (placement === 'left' || placement === 'right') {
if (placement === "left" || placement === "right") {
digitalWrapper.style.display = "inline-block";
digitalWrapper.style.verticalAlign = "top";
analogWrapper.style.display = "inline-block";
if (placement === 'left') {
if (placement === "left") {
analogWrapper.style.padding = "0 20px 0 0";
wrapper.appendChild(analogWrapper);
wrapper.appendChild(digitalWrapper);
@ -214,7 +214,7 @@ Module.register("clock",{
}
} else {
digitalWrapper.style.textAlign = "center";
if (placement === 'top') {
if (placement === "top") {
analogWrapper.style.padding = "0 0 20px 0";
wrapper.appendChild(analogWrapper);
wrapper.appendChild(digitalWrapper);

View File

@ -29,7 +29,7 @@ Module.register("compliments",{
]
},
updateInterval: 30000,
remoteFile: null,
remoteFile: null,
fadeSpeed: 4000
},
@ -47,11 +47,11 @@ Module.register("compliments",{
this.lastComplimentIndex = -1;
if (this.config.remoteFile != null) {
this.complimentFile((response) => {
this.config.compliments = JSON.parse(response);
});
}
if (this.config.remoteFile != null) {
this.complimentFile((response) => {
this.config.compliments = JSON.parse(response);
});
}
// Schedule update timer.
var self = this;
@ -114,17 +114,17 @@ Module.register("compliments",{
/* complimentFile(callback)
* Retrieve a file from the local filesystem
*/
complimentFile: function(callback) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open('GET', this.file(this.config.remoteFile), true);
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
callback(xobj.responseText);
}
};
xobj.send(null);
},
complimentFile: function(callback) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open("GET", this.file(this.config.remoteFile), true);
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
callback(xobj.responseText);
}
};
xobj.send(null);
},
/* complimentArray()
* Retrieve a random compliment.

View File

@ -166,7 +166,7 @@ Module.register("currentweather",{
}
if (!this.loaded) {
wrapper.innerHTML = this.translate('LOADING');
wrapper.innerHTML = this.translate("LOADING");
wrapper.className = "dimmed light small";
return wrapper;
}
@ -323,20 +323,20 @@ Module.register("currentweather",{
// So we need to generate the timestring manually.
// See issue: https://github.com/MichMich/MagicMirror/issues/181
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) {
//var hours = sunriseSunsetDateObject.getHours() % 12 || 12;
if (this.config.showPeriod) {
if (this.config.showPeriodUpper) {
//timeString = hours + moment(sunriseSunsetDateObject).format(':mm A');
timeString = moment(sunriseSunsetDateObject).format('h:mm A');
timeString = moment(sunriseSunsetDateObject).format("h:mm A");
} else {
//timeString = hours + moment(sunriseSunsetDateObject).format(':mm a');
timeString = moment(sunriseSunsetDateObject).format('h:mm a');
timeString = moment(sunriseSunsetDateObject).format("h:mm a");
}
} else {
//timeString = hours + moment(sunriseSunsetDateObject).format(':mm');
timeString = moment(sunriseSunsetDateObject).format('h:mm');
timeString = moment(sunriseSunsetDateObject).format("h:mm");
}
}
@ -387,39 +387,39 @@ Module.register("currentweather",{
},
deg2Cardinal: function(deg) {
if (deg>11.25 && deg<=33.75){
return "NNE";
} else if (deg > 33.75 && deg <= 56.25) {
return "NE";
} else if (deg > 56.25 && deg <= 78.75) {
return "ENE";
} else if (deg > 78.75 && deg <= 101.25) {
return "E";
} else if (deg > 101.25 && deg <= 123.75) {
return "ESE";
} else if (deg > 123.75 && deg <= 146.25) {
return "SE";
} else if (deg > 146.25 && deg <= 168.75) {
return "SSE";
} else if (deg > 168.75 && deg <= 191.25) {
return "S";
} else if (deg > 191.25 && deg <= 213.75) {
return "SSW";
} else if (deg > 213.75 && deg <= 236.25) {
return "SW";
} else if (deg > 236.25 && deg <= 258.75) {
return "WSW";
} else if (deg > 258.75 && deg <= 281.25) {
return "W";
} else if (deg > 281.25 && deg <= 303.75) {
return "WNW";
} else if (deg > 303.75 && deg <= 326.25) {
return "NW";
} else if (deg > 326.25 && deg <= 348.75) {
return "NNW";
} else {
return "N";
}
if (deg>11.25 && deg<=33.75){
return "NNE";
} else if (deg > 33.75 && deg <= 56.25) {
return "NE";
} else if (deg > 56.25 && deg <= 78.75) {
return "ENE";
} else if (deg > 78.75 && deg <= 101.25) {
return "E";
} else if (deg > 101.25 && deg <= 123.75) {
return "ESE";
} else if (deg > 123.75 && deg <= 146.25) {
return "SE";
} else if (deg > 146.25 && deg <= 168.75) {
return "SSE";
} else if (deg > 168.75 && deg <= 191.25) {
return "S";
} else if (deg > 191.25 && deg <= 213.75) {
return "SSW";
} else if (deg > 213.75 && deg <= 236.25) {
return "SW";
} else if (deg > 236.25 && deg <= 258.75) {
return "WSW";
} else if (deg > 258.75 && deg <= 281.25) {
return "W";
} else if (deg > 281.25 && deg <= 303.75) {
return "WNW";
} else if (deg > 303.75 && deg <= 326.25) {
return "NW";
} else if (deg > 326.25 && deg <= 348.75) {
return "NNW";
} else {
return "N";
}
},
/* function(temperature)

View File

@ -44,9 +44,9 @@ var Fetcher = function(url, reloadInterval, encoding) {
parser.on("item", function(item) {
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 url = item.url || item.link || '';
var url = item.url || item.link || "";
if (title && pubdate) {
@ -81,7 +81,7 @@ var Fetcher = function(url, reloadInterval, encoding) {
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);
};

View File

@ -25,8 +25,8 @@ Module.register("newsfeed",{
updateInterval: 10 * 1000,
animationSpeed: 2.5 * 1000,
maxNewsItems: 0, // 0 for unlimited
removeStartTags: '',
removeEndTags: '',
removeStartTags: "",
removeEndTags: "",
startTags: [],
endTags: []
@ -93,33 +93,41 @@ Module.register("newsfeed",{
var sourceAndTimestamp = document.createElement("div");
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 !== '' && 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 += ':';
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 !== "" && 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);
}
//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++) {
if (this.newsItems[this.activeItem].title.slice(0,this.config.startTags[f].length) == this.config.startTags[f]) {
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].title.slice(this.config.startTags[f].length,this.newsItems[this.activeItem].title.length);
}
}
}
}
if (this.config.removeStartTags == 'description' || 'both') {
if (this.config.removeStartTags == "description" || "both") {
if (this.config.showDescription) {
for (f=0; f<this.config.startTags.length;f++) {
if (this.newsItems[this.activeItem].description.slice(0,this.config.startTags[f].length) == this.config.startTags[f]) {
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].description.slice(this.config.startTags[f].length,this.newsItems[this.activeItem].description.length);
}
}
}
}
@ -131,14 +139,14 @@ Module.register("newsfeed",{
for (f=0; f<this.config.endTags.length;f++) {
if (this.newsItems[this.activeItem].title.slice(-this.config.endTags[f].length)==this.config.endTags[f]) {
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].title.slice(0,-this.config.endTags[f].length);
}
}
}
if (this.config.showDescription) {
for (f=0; f<this.config.endTags.length;f++) {
if (this.newsItems[this.activeItem].description.slice(-this.config.endTags[f].length)==this.config.endTags[f]) {
this.newsItems[this.activeItem].description = this.newsItems[this.activeItem].description.slice(0,-this.config.endTags[f].length);
}
}
}
}
@ -234,10 +242,10 @@ Module.register("newsfeed",{
for (var f in this.config.feeds) {
var feed = this.config.feeds[f];
if (feed.url === feedUrl) {
return feed.title || '';
return feed.title || "";
}
}
return '';
return "";
},
/* scheduleUpdateInterval()

View File

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

View File

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

View File

@ -59,7 +59,7 @@ Module.register("updatenotification", {
var subtext = document.createElement("div");
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);
subtext.className = "xsmall dimmed";
wrapper.appendChild(subtext);