Suppress "Unknown global symbol" warnings in qooxdoo with coffeescript - javascript

I'm using qooxdoo in combination with the google maps API. I'm actually using it in combination with coffeescript, but I had the same problem before I moved over to coffeescript (although I suspect coffeescript isn't helping).
When I build the project, I get a lot of lines like this:
- Warning: myproj.App (22,50): Unknown global symbol used: 'google'
- Warning: myproj.App (22,76): Unknown global symbol used: 'google.maps'
- Warning: myproj.App (23,21): Unknown global symbol used: 'google'
- Warning: myproj.App (23,47): Unknown global symbol used: 'google'
- Warning: myproj.App (23,74): Unknown global symbol used: 'google.maps'
- Warning: myproj.App (15,18): Unknown global symbol used: 'google.maps.LatLng'
I've found lots of references to #ignoreUndefined or #ignore to get rid of this, all supposed to be placed in a javadoc comment like this:
/**
* #ignore(google.*)
*/
However, I've been unable to get this to work. I've tried #ignoreUndefined and #ignore, with and without brackets, with google on it's own, with google. with google*, with google.*, with google.maps.LatLng explicitly (and all the other ones) and a few other variations. In the coffeescript I've tried having it all in a ### block and also in a block at the top of the file that looks like this:
`/**
* #ignoreUndefined google
*/`
or
`/** #ignore(google) */`
(the backticks stick it straight into the javascript source unmolested).
What I really want to do is put something in config.json that tells it to stop complaining about google.* (this would be simpler than per-file as it will be in every file), but I can't find a way to do this. It's starting to be a problem as I'm missing genuine mistakes amongst the pages of Unknown global symbol used: 'google...
Please can anyone tell me what I'm doing wrong?
Edit
Thanks to Richard, I now have it working. In case it's of use to anyone else, my config.json looks like this (irrelevant bits removed):
{
...
"config-warnings" :
{
"job-shadowing": ["common", "lint", "source-all", "build"]
},
"jobs" :
{
"build" :
{
"run" :
[
"coffee-compile",
"build-resources",
"build-script",
"build-files"
]
},
"source-all" :
{
"run" :
[
"coffee-compile",
"source-all-script"
]
},
"common":
{
"lint-check": {
"allowed-globals": [
"google"
]
}
},
"lint":
{
"lint-check": {
"allowed-globals": [
"google"
]
}
},
"coffee-compile" :
{
"extend": ["common"],
"shell" :
{
"command": "coffee --bare --compile --output ./source/class/myapp/ ./coffee/myapp/*.coffee"
}
}
}
}

I assume you are using qooxdoo 3.0 (the current github master branch - not yet released but very soon) which introduces the #ignore syntax (superseding the old #ignore syntax). I got it working like this in my config.json:
{
"config-warnings" :
{
"job-shadowing" : ["source"],
},
...
"jobs" :
{
...
"source" :
{
"lint-check" : {
"allowed-globals" : [
"google"
]
}
}
}
}
Changing the config.json like that should also work in qooxdoo 2.1.1.
Read on:
http://manual.qooxdoo.org/3.0/pages/development/api_jsdoc_at_ignore.html
http://manual.qooxdoo.org/3.0/pages/development/api_jsdoc_ref.html#ignore
http://manual.qooxdoo.org/3.0/pages/tool/generator/generator_config_ref.html#config-warnings
http://manual.qooxdoo.org/3.0/pages/tool/migration/migration_guide.html#compiler-hints

Related

Can I enforce multiple levels for the same es lint rule. eg: error and warning for different paths

I am looking to enforce the no-restricted-imports rule in my codebase for specific imports.
However, I need to throw an error for some paths and warnings for others. Looks like I cannot do it by just doing :
'no-restricted-imports': [
'warn',
{
paths: [
{
name: 'd3',
message: 'd3 would be deprecated soon, please consider moving away from it'
}
]
},
'error',
{
paths: [
{
name: 'moment',
message: 'Use of moment is not allowed',
},
]
]
What would be the best way to achieve this behavior?
I have already tried defining the no-restricted-imports rule twice, once for error and once for warning, but since its an object, it gets overridden.
This is not possible in ESLint. A rule must either always warn or always error.
A combination of eslint-plugin-local and a small stub rule that references the no-restricted-imports rule directly from the eslint package could potentially get this working for you.
Not elegant by any stretch, but seems like it should be possible at least.

Emmet JS snippets in VS Code

Has anyone ever succeeded in getting Emmet JS snippets to work in VS Code or even in Sublime?
The solution from https://stackoverflow.com/a/16943996/2012407 did not work for me.
These are my settings:
"emmet.includeLanguages": {
"javascript": "javascriptreact",
"vue-html": "html",
"plaintext": "html"
},
This is my snippets.json:
{
"javascript": {
"abbreviations": {
"cl": "console.log",
"va": "var"
},
"snippets": {
"cl": "console.log",
"va": "var"
}
},
"css": {
"snippets": {
"cb": "color: black",
"bsd": "border: 1px solid ${1:red}"
}
}
}
There's no problem with CSS, SCSS, HTML, and all the rest - only JS. I've tried abbreviations or snippets, but the Emmet expansion puts HTML tags around what I write: cl becomes <cl> in Javascript & javascriptreact files.
I also tried js and javascriptreact in the snippets definition for the language with no luck.
No need to add JS snippets in Emmet: the new concept of Emmet 2.0 (already available in VS Code; v2.0 in beta and not publicly released yet) works as autocomplete provider so you can simply use native VS Code snippets instead
So I will put an example here for the built-in VS Code snippets, which are still not my favorite.
Open the command prompt with cmd+shift+p and type user snippets. There is already an example in there. Uncomment it, save, and you can use it straight away by typing the prefix.
I had to create the same snippet file named javascriptreact.json as well for it to work in most of my JS files - Javascript React (babel)
Ex:
{
"Test": {
"prefix": "ts",
"body": [
"console.log('test')",
"$1"
],
"description": "Prints test"
}
}
Now I have Emmet mapped to ctrl+e and having the built-in snippets limited to the intellisense is not great. I'd like a key binding like ctrl+e, and I am a big fan of Emmet.
I am still keen on having it working with Emmet using the same key binding if anyone knows.
This article solve issue in my case
https://medium.com/#eshwaren/enable-emmet-support-for-jsx-in-visual-studio-code-react-f1f5dfe8809c

Sencha cmd, closure compiler error: how to locate the offending code

When running Sencha cmd 6.5, and I get the following error:
[ERR] C2001: Closure Compiler Error (Parse error. undefined label "f") -- compression-input:1:4095
How can I locate the code at compression-input:1:4095 ?
This happens when I include a custom javascript file in app.json using:
"js": [
{
"path": "app.js",
"bundle": true
},{
"path": "custom.js",
"includeInBundle": true
}
],
The error disapears when I remove the reference to custom.js in app.json.
If I interpret the error correctly, it means that closure compiler finds an error on line 1, character 4095 of the compression-input. But the first line of custom.js is not such long.
How can I locate the offending code ?
And by the way, what is an undefined label in closure compiler ?
I had the same issue a year ago, and I was told you cannot locate it from the error message.
Assuming that you have already tried to open your uncompiled project directly in the browser, and not getting a syntax error, there's not much you can do except narrowing it down further by splitting the custom.js content in two parts and check these independently.
In my case it was Ext.define where should have been Ext.create, and the syntax error is thrown because usage of Ext.define is rewritten into other commands during generation of the compression-input. Maybe if you look for this specifically, you can find it.
I faced similar problems too.
I disabled compression in app.json file:
"testing": {
"compressor": {
//"type": "closure",
"type": "none",
"warningLevel": "quiet"
},
"output": "...."
}
And I separately checked the output app.js file with the compiler (which can be downloaded):
java -jar closure-compiler-v20210302.jar --js app.js --js_output_file compiled_output.js

Unable to get "disallowSpacesInsideParentheses" to work

My .jscsrc file looks like below
{
"preset": "wikimedia",
"requireSpacesInsideArrayBrackets": null,
"validateIndentation": 4,
"disallowMultipleVarDecl": true,
"disallowSpaceAfterObjectKeys": "ignoreMultiLine",
"disallowSpacesInsideParentheses": { "only": [ "{", "}" ] }
}
But on running jscs over my code, it throws the following error in console
Missing space after opening round bracket at js/app.js :
29 | windowScrollTimeout = null;
30 | if (currentTopOffet < prevTopOffset) {
31 | $('header').removeClass('mobile-hide');
----------------------------------------------------------------^
I also tried setting the value of disallowSpacesInsideParentheses to true but still no change in results. Any idea what I am doing wrong? Or is it that I am trying to solve my problem using wrong rule? Can somebody point me to the right rule set?
Thanks
Checking the source for disallowSpacesInsideParentheses, that rule won't throw the error you're seeing. It seems that your rule is conflicting with the wikimedia presets rule:
"requireSpacesInsideParentheses": "all"
requireSpacesInsideParentheses seems to be the culprit, not any rule you've set, as it's the only rule which will throw that error. To overwrite the preset rule, according to the docs you'll need to set the rule to null in your .jscsrc file.
"requireSpacesInsideParentheses": "null"

Kartograph: Map Creation fails

Recently I started using Kartograph. I am inexperienced in SVG, so the map creation is creating headaches for me. After initial trouble creating a world map that outlines country borders - similar to this - and a few other things(city regions and some decorating elements), my problem boils down to a undocumented - or at least I haven't found it in the docs - error. I guess it is related with my ignorance towards the kartograph.py framework.
The json file I provide Kartograph looks like that:
{
"proj": {
"id": "lonlat",
"lon0": 20,
"lat0": 0
},
"layers": {
"background": {
"special": "sea",
"charset": "latin-1",
"simplify": false
},
"graticule": {
"special": "graticule",
"charset": "latin-1",
"simplify": false,
"latitudes": 1,
"longitudes": 1,
"styles":{
"stroke-width": "0.3px"
}
},
"world":{
"src": "ne_50m_admin_0_countries.shp",
"charset": "latin-1",
"simplify": false
},
"lakes":{
"src": "Lakes.shp",
"charset": "latin-1",
"simplify": false
},
"trees":{
"src": "Trees.shp",
"charset": "latin-1",
"simplify": false
},
"depth":{
"src": "DepthContours.shp",
"charset": "latin-1",
"simplify": false
},
"cities":{
"src": "CityAreas.shp",
"charset": "latin-1",
"simplify": false
}
}
}
I know the output file will be huge and the generation will take ages, but it is just a test. I will experiment with the "simplify" option later. Much of the code in the file is based on this tutorial. Also, the empty simplify clause might not be necessary, but kartograph complained about the lack of the option, so I added it.
The command I use is this one:
kartograph world.json -o world.svg
It runs for some time(I guess, parsing all the input files etc.) before aborting. Now, the error I am facing is this one:
cli.py, in render_map()
71: K.generate(cfg, args.output, preview=args.preview, format=format, stylesheet=css) kartograph.py, in generate()
46: _map = Map(opts, self.layerCache, format=format) map.py, in __init__()
50: me.bounds_poly = me._init_bounds() map.py, in _init_bounds()
192: features = self._get_bounding_geometry() map.py, in _get_bounding_geometry()
257: charset=layer.options['charset']
get_features() got an unexpected keyword argument 'filter'
I tried looking at the file which throws the error(map.py), but I realized quickly that there's just too much interaction in the files for me to grasp things quickly.
I hope the data I provided is sufficient for someone more familiar with kartograph than me to track the error down.
UPDATE: The error is still valid. I tested it on both a MacBook Pro and an Asus Netbook now(Arch and Bodhi Linux, respectively).
Thanks in advance,
Carson
As far as I know, you can solve that problem by including a 'bounds' parameter. It is in deed very tricky, because according to the documentation (is it valid to call it 'documentation') this error should not appear, since the only required parameter is 'layers'. Also, how the bounds are defined depend apparently from the chosen projection. For your example I would use a simple polygon bounds.
I also had problems with that error. But, after many trials to set up everything, I noticed that apparently it only appears in the command-line version of Kartograph, and not when using Kartograph as a Python module in a script. I.e., try to include the json dictionary into a Python script where you import kartograph, like in the example here below.
I also put an example of filtering, for the record, because it was another thing that failed to work when using the command-line version of Kartograph.
# file: makeMap.py
from kartograph import Kartograph
K = Kartograph()
def myfilter(record):
return record['iso_a3'] in ["FRA","ITA","DEU"]
config = {
"layers": {
"mylayer": {
"src": "ne_50m_admin_0_countries.shp",
"filter": myfilter,
"attributes": {"iso_a3":"iso_a3", "name":"name", "id":"iso_a3"}
}
},
}
K.generate(config, outfile='world.svg')
Then, run the script as a Python script:
python makeMap.py

Categories