What exactly is this prettier error?:
error Insert '·' prettier/prettier
Does it expect a space after () in?:
beforeEach(function() {
What's the way to ignore that in eslint/prettier?
Insert ·eslintprettier/prettier is an error which you will get if you haven't given proper spacing. Here it denotes space by .
In your case, the prettier formatter expects you to give space in the function and () inside the beforeEach(). So changing your code from -
beforeEach(function() {
to
beforeEach(function () {
would solve the issue.
Note: In most text editors, you have the option to format on save by which you can set the text editor to automatically format the code as per the default formatted so that you won't need to worry about solving these issues. Once you save the document, your code will get auto-formatted.
Also, you can ignore if you don't want to format as per the change suggested. For eg. In VSCode, you will get options if you hover over the error -
You can choose to fix the problem, disable it for the line or even for entire file.
Prettier expects a space before the functions' (), i.e., between the word function and the opening parenthesis:
beforeEach(function () {
// Here -------^
Related
When the accessibility explorer is activated, there's a spacing issue. The spaces after 'f', 'M', and 'cos' are way too big. It's important that those spaces are small for readability reasons, since (for instance) "M(x)" is a single object, not two separate things as "M (x)" might suggest.
Current behavior
Expected behavior
Steps to Reproduce:
Open https://jsbin.com/ bohitetaka/edit?html,js,output
Check how math expression is displayed by making accessibility explorer property to false and true.
When explorer is set to false the spacing is correct, but I also want the accessibility feature.
This is due to the fact that the explorer uses semantic-enrichment that modifies the underlying MathML for the expression, and that adds mrows around the parentheses, which in turn causes MathJax to interpret the parentheses as though they came from \left...\right, which are spaced differently.
This was fixed in v3.1.3 via #583, but the fix has not been back-ported to v2.7.
For now, you can use the following configuration to work around the issue:
MathJax.Hub.Register.StartupHook('MathML Jax Ready', function () {
var PARSE = MathJax.InputJax.MathML.Parse;
PARSE.Augment({
_AddChildren: PARSE.prototype.AddChildren,
AddChildren: function (mml, node) {394
this._AddChildren(mml, node);
if (mml.type === "mrow" && (mml.open || mml.close)) {
if (mml.open && !mml.data[0].stretchy) delete mml.open;
if (mml.close && !mml.data[mml.data.length-1].sretchy) delete mml.close;
}
}
});
});
TLDR: I want to read in a file's contents and then export a function which relies on those contents ... without making that exported function use promises or some other form of asynchronicity.
I'm trying to write an XML-validating module, and in order for it to do its thing I need to read in an XSD file. However, this only needs to happen once at "load time", so ideally I'd rather not have other modules that use my function have to wait for a promise to resolve to get their results. If I were using Webpack this would be easy, as I could use it's text file loader to bring in the XSD as if it were any other module ... but unfortunately I'm not.
In other words, currently I have to do (borderline pseudo-code):
module.exports.validate = () =>
new Promise((resolve) =>
fs.readFile(path, (file) => {
// use file to validate, then:
resolve(validationResult);
});
});
};
and instead I'd like to do:
fs.readFile(path, (file) => {
module.exports.validate = myValidationFunction;
});
But the above doesn't work because you can't export from callbacks, so my question is, is there any other way to accomplish this?
The https://github.com/jonschlinkert/to-exports library seems to offer exactly this, so it seems like it's possible ... but it doesn't work for me :(
P.S. At worst I could literally wrap the contents of the file inside the template string characters, rename the file to be .js, and export it that way:
module.exports = `*XSD contents go here*`;
However, that seems very kludgy, so I'm hoping there is a better way.
If you want to read a file synchronously, then use fs.readFileSync. It returns the contents of the file or throws an error.
i am looking to simply animate two fill colors of an SVG. ping pong, loop, however you want to call it. the pieces work on their own, but put together into a recursive function to form the loop breaks it.
here's what i have (using jQuery):
$(document).ready( function() {
var items = $('.st1');
items.css('fill', '#ff3600');
bl-colorCycle();
function bl-colorCycle() {
console.log('color cycle called');
items.animate({fill: '#00ffcc'}, 5000, 'linear', bl-colorCycle);
}
});
for some reason, this throws this error:
SyntaxError: missing ( before formal parameters
what the heck am i missing? i've torn this apart several times and for the life of me, i cannot spot where the hell the missing '(' is! i've read all that i can find here, and found nothing that helps in this scenario. i've even tried putting the function call at the very end, just to see if some weird web-voodoo was at play...bupkiss. :(
i'm hoping someone out there has sharper eyes... :P
TIA.
WR!
Hyphen ("-") is not a legal identifier character. Try underscore ("_") instead. Ie. bl_colorCycle().
That's my setup. VS 2013, with the Node JS Tools, and Typescript. Adding a .ts file is handled without a hiccup. I am having some issues with the npm integration, but I've been able to work around them.
I've also added EdgeJS. It doesn't yet support TypeScript but I just write my EdgeJS calls with regular JS in my TS files. The problem is that EdgeJS allos you to write your CS functions a few different ways.
One way is like the following, where the entire body is enclosed in a comment block:
var hello = edge.func(function () {/*
async(input) => {
return ".NET welcomes " + input.ToString();
}
*/});
Unfortunately, the TS compiler, by default, removes these comments and I can't find a way in this project type to change that behavior.
Am I just out of luck (for now)?
To preserve comments for TypeScript, you'll need to start them on a new line. In the example you provided, the multi-line comment is not preserved as it starts on the end of a line with code.
Simply move the block comment start:
var edge = edge.func(() => {
/*
async(input) => {
}
*/
});
When I create a new javascript constructor I want to do this:
var PersonViewModel = function(){};
Then I press return after the semicolon and get this:
var PersonViewModel = function()
{
};
But what I want is this:
var PersonViewModel = function()
{
// so I can immediately continue writing code here
};
I want that line break after the opening curly brace.
I can not find the settings in the javascript options, anyone knows please?
ReSharper tries very hard not to mess with user typing (at least when it is correct). It can help you not to touch very much, but if you want to type something fully, it tries to allow you to do it. But the feature that you want breaks this principle: when user would type to function statement side-by-side, the second one would be inside the first one instead.
What I suggest instead is just typing ...function(){ and pressing Enter. ReSharper would add } for you automatically, so you can just continue to write function body. You would get syntactically correct code, because ; could be omitted in JavaScript. ReSharper would highlight missing ; anyway and would suggest to add all missing ; in the whole file. Just use this feature from time to time to make your code beautiful.