Grunt jshint disable Expected a conditional expression and instead saw an assignment - gruntjs

I am using grunt-contrib-jshint and it finds the following error in my JS file:
line 5 col 70 Expected a conditional expression and instead saw an assignment.
I know the reason of this error, but all I want is to disable it. Looking here it looks like I can either use no-cond-assign to 0 in my jshintrc or by adding -W084 : true in my options.
The problem is that the first solution ended up in a corrupted jshintrc and the second one does not solve the problem. Another option is to add -W022 : true (which solution I found in the comments) also does not work.

Use the ignore pragma to skip this line:
/* jshint ignore:start */
if(this = Infinity)
/* jshint ignore:end */
{
return;
}

Related

LESS addition operator (+) is appending instead of adding

I'm having a strange issue I haven't seen occur. I am trying to do some basic addition to some variables like this:
#screen-break-sm: 768px;
#screen-break-md: 992px;
#screen-max-mobile: #screen-break-sm;
#screen-min-desktop: #screen-break-sm + 1;
Then, those values are being used in some media queries. When it is compiled using gulp-less (version ~3.0.0 in package.json) via Gulp, the output ends up being something like:
#media (min-width:768px + 1) {
// CSS
}
I'm expecting:
#media (min-width:769px) {
// CSS
}
I have tried doing the addition as both #screen-break-sm + 1 and also screen-break-sm + 1px. I've also tried removing the px part of the original values and doing the add and appending the px afterwards, but that doesn't add either.
In case it is relevant, this is one of the gulp scripts that builds a section where I first ran into this issue:
module.exports = function (build) {
return function () {
var pagesPath = build.options.styles.buildPath + '/pages/';
return build.gulp.src('./resources/assets/less/pages/**/*')
.pipe(build.plugins.less({
paths: [ build.plugins.path.join(__dirname, 'less', 'vendor', 'theme', 'bootstrap') ]
})).on('error', build.errorHandler)
.pipe(build.plugins.minifyCss()).on('error', build.errorHandler)
.pipe(build.plugins.extReplace('.min.css')).on('error', build.errorHandler)
.pipe(build.gulp.dest(pagesPath));
};
};
Any ideas why LESS is concatenating/appending instead of performing addition?
[EDIT]
While the solution is the same as the other question that was identified as a possible duplicate, that question does not discuss the problem that users will encounter directly, and therefore I think this question is much better suited for searching purposes. I never found that solution after an hour of Googling and only after getting the answer and the "strict math" verbiage did that other question show up.
Look at strict math option which default value is OFF. Are you sure that for some reason you don't have it set to ON?
lessc -sm=on
lessc --strict-math=on

How can I return the date in a custom format in this Qt/QML plasmoid?

The digital clock in KDE Plasma 5.4.0 does not allow you to specify a custom format. I'm attempted to hack the plasmoid, which is just a QML file. However, I've been unsuccessful. There is a conditional branch, which allows you select from one of the following strings.
return Qt.SystemLocaleLongDate;
return Qt.ISODate;
return Qt.SystemLocaleShortDate;
I attempted to modify it to the following, but it's not working. Presumably I just have the syntax wrong.
return QDate::currentDate().toString("dd.MM.yyyy");
How can I modify the plasmoid to show a custom date format?
EDIT
I suspect that I might be changing the wrong line. The source code for the plasmoid I'm trying to hack is here. After decompressing the file, it's specifically at applets/digital-clock/package/. (When installed, this directory is moved to /usr/share/plasma/plasmoids/org.kde.plasma.digitalclock/.) I attempted changing line 43 of contents/ui/DigitalClock.qml.
I attempted changing the line to return "foo";, but this had no effect. Again, I'm not sure if I have the syntax correct.
As stated in the comments, the line returning this value isn't a reference to the date itself, but merely specifies the format. I'm unsure of the syntax to hack the code here, but instead, you can change the code that references this property later.
--- DigitalClock.qml.orig 2015-08-22 20:45:40.000000000 +1000
+++ DigitalClock.qml 2015-09-01 09:32:35.417197582 +1000
## -515,7 +515,7 ##
if (main.showDate) {
if (main.tooSmall) {
- dateLabelLeft.text = Qt.formatDate(main.currentTime, main.dateFormat);
+ dateLabelLeft.text = Qt.formatDate(main.currentTime, "dd.MM.yyyy");
} else {
dateLabel.text = Qt.formatDate(main.currentTime, main.dateFormat);
}

`Unrecognized input` error with LESS guarded mixin

In my LESS project I am having issues getting my guarded mixins working with variables that I declared in another file. Here is the code I am working with:
_defaults.less (contains all of my variables)
//------------------------------------//
// #INCLUDE
//------------------------------------//
// Set whatever components you want included
// in your project to `true` and any components
// you do not wish to be included to `false`
// Base
#use-main: true;
_main.less (just a random partial in my project)
.main(#boolean) when (#boolean = true) {
// Styles go here
}
// Execute mixin
.main(#use-main);
style.less (imports all of my partials)
//------------------------------------//
// #IMPORTS
//------------------------------------//
// Base styles
#import "base/_main.less";
This is how my project is structured (for around 20 partials that are then imported into the style.less file).
Whenever I try to compile my project, I get this error:
Unrecognised input
c:\Users\Keenan\Documents\GitHub\concise.css-less\less\base_main.less line 1
c:\Users\Keenan\Documents\GitHub\concise.css-less\less\concise.less
The code you pasted is correct. In fact you are misled by lessc error message. It refers to the #main block. It seems the issue you are facing is related to your project Concise.css-less and more precisely this line.
#if #global-border-box == true {
// [...]
}
This is not the proper syntax for if statements in less. See question:
How to use if statements in LESS
It seems you are converting a project from stylus to less. I would suggest cutting large chunks of files that fail to import to find out, through bisection, the lines that less doesn't recognize. Alternatively, you could comment the top mixins guards that are used here to include this or that part of the css, and that confuse less for error reporting.
For example, if you comment the first and last lines of file _lists.less:
//.lists(#boolean) when (#boolean = true) {
[...]
//.lists(#use-lists);
lessc will report the error near the proper line (actually it's > on line 111 that it doesn't like):
ParseError: Unrecognised input in concise.css-less/less/base/_lists.less on line 109, column 9:
108 .breakpoint(small) {
109 dl.dl-horizontal {
110 overflow: hidden;

Is it possible and reasonable to convince JSHint to accept a single line `do` loop?

This is clear (IMO) and valid javascript:
do var playerId = newPlayerId();
while(playerId in players);
JSHint complains that it expected a { before playerId. Is there any way to disable this warning, without disabling all curly-brace related warnings? My style is cool, right? No ambiguities or obscurities?
For some reason, this does not appear to be possible. It is possible with other similar statements (such as if and while) by setting the curly option to false:
/*jshint curly: false */
var x = 10;
if (x < 20)
x = 30;
I see no reason why this rule should not apply to the do statement, so I've opened a pull request to add this functionality to JSHint.

Why is mix() not working with my colors in LESSC?

My less file piggy-backs on to the end of the Twitter Bootstrap files (so things like #white are defined already. Here is my less code:
#columnSortScreen: #99f;
// the color used
#columnSort: mix( #white, #columnSortScreen );
When compiled, I get the following error (everything underlined by carets is highlighted):
non_object_property_loadError: error evaluating function `mix`: Cannot read property 'value' of undefined in /Users/cmv/Sites/...../tablesorter.less:12:14
11 // the color used
12 #columnSort: mix( #white, #columnSortScreen );
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What am I doing wrong? Lessc is version 1.3.0.
Thanks!
I had the exact same error.
Did some digging and found this:
The docs for mix are missing the third parameter.
Try:
#fallback-color: mix(#from-color, #to-color, 50%);
Note the third parameter. This solved it in my case, does this fix it for you?

Resources