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
Related
I recently started using the eslint module to help clean-up some JavaScript files. The following error is being reported when I lint one of my files:
127:17 error Unexpected alias 'me' for 'this' consistent-this
After checking the documentation, I understand the error is being reported because my code is assigning the value of this to a variable named me instead of that.
What is the proper way to configure my project's .eslintrc.json to make it so the following line of code is not reported as an error: var me = this;?
The rule should be like this in your .eslintrc
{
"rules" : {
"consistent-this": ["error", "me"]
}
}
I had a static website and I'm trying to kinda convert it into MEAN stack using Angular 5.
I want to add some scripts and styles for galleries, scrolling etc. to my HTML. The scripts need jQuery and I don't have to access them really they just need to run. I added them in the .angular-cli.json like so:
"styles": [
"styles.css",
"./src/app/assets/css/font-awesome-4.3.0/css/font-awesome.min.css",
"./src/app/assets/css/normalize.css",
"./src/app/assets/css/owl.carousel.css",
"./src/app/assets/css/owl.theme.css",
"./src/app/assets/css/main.css",
"./src/app/assets/css/responsive"
],
"scripts": [
"./src/app/assets/plugins/jquery-1.11.1.min.js",
"./src/app/assets/plugins/jquery.smooth-scroll.min.js",
"./src/app/assets/plugins/imagesloaded.js",
"./src/app/assets/plugins/owl.carousel.min.js",
"https://maps.googleapis.com/maps/api/js",
"./src/app/assets/plugins/jquery.waypoints.min.js",
"./src/app/assets/plugins/main.js"
],
Also added allowJs: true in the tsconfig.app.json
But I get an error when I try to run ng serve or ng build.
Cannot convert undefined or null to object
TypeError: Cannot convert undefined or null to object
at hasOwnProperty ()
at Object.hasProperty (/home/robin/webdevelopment/Guenters-Fahrschulen/node_modules/typescript/lib/typescript.js:2229:31)
at parseConfig (/home/robin/webdevelopment/Guenters-Fahrschulen/node_modules/typescript/lib/typescript.js:71815:16)
at /home/robin/webdevelopment/Guenters-Fahrschulen/node_modules/typescript/lib/typescript.js:71721:22
at Object.parseJsonConfigFileContent (/home/robin/webdevelopment/Guenters-Fahrschulen/node_modules/typescript/lib/typescript.js:71735:11)
at Object.readTsconfig (/home/robin/webdevelopment/Guenters-Fahrschulen/node_modules/#angular/cli/utilities/read-tsconfig.js:8:32)
at new NgCliWebpackConfig (/home/robin/webdevelopment/Guenters-Fahrschulen/node_modules/#angular/cli/models/webpack-config.js:19:42)
at Class.run (/home/robin/webdevelopment/Guenters-Fahrschulen/node_modules/#angular/cli/tasks/serve.js:71:29)
at check_port_1.checkPort.then.port (/home/robin/webdevelopment/Guenters-Fahrschulen/node_modules/#angular/cli/commands/serve.js:123:26)
at
at process._tickCallback (internal/process/next_tick.js:160:7)
My linter also throws an error on $(document).ready(); but how would I replace it?
I'm trying to in include https://www.npmjs.com/package/react-bootstrap-typeahead in my project, but when I run my grunt browserify task, I get a ParseError: Unexpected token error. Full message here:
Running "browserify:dist" (browserify) task
>> /path/to/project/node_modules/react-bootstrap-typeahead/css/Typeahead.css:1
>> .bootstrap-typeahead .dropdown-menu {
>> ^
>> ParseError: Unexpected token
Warning: Error running grunt-browserify. Use --force to continue.
Aborted due to warnings.
The issue being that there is a require('/some/file.css') inside the react-bootstrap-typeahead source js.
Here is my grunt browserify task:
browserify: {
dist: {
cwd: 'build',
options: {
transform : ['browserify-css'],
alias: {
'index' : './dist/index.js',
'root' : './dist/containers/root.js',
'designs' : './dist/components/designs.js',
'addMutationForm' : './dist/components/addMutationForm.js',
'ProteinChecker': './dist/containers/ProteinChecker.js',
'configureStore': './dist/configureStore.js',
'actions' : './dist/actions.js',
'reducers' : './dist/reducers.js',
'utils': './dist/utils.js',
},
require: [
'./node_modules/isomorphic-fetch',
'./node_modules/jquery',
'./node_modules/react',
'./node_modules/react-dom',
'./node_modules/bootstrap',
'./node_modules/redux',
'./node_modules/babel-polyfill',
'./node_modules/redux-logger',
'./node_modules/redux-thunk',
'./node_modules/underscore',
'./node_modules/redux-form',
'./node_modules/react-bootstrap-typeahead'
]
},
src: ['./dist/*.js', './dist/*/*.js'],
dest: './public/build/app.js'
}
}
A few things I came across while attempting to solve the problem:
A similar SO (yet unanswered) question but using webpack, not grunt+browserify so I don't believe applicable:
Using react-bootstrap-typeahead generating CSS errors
And a closed issue on the github page of the react-bootstrap-typeahead project, but doesn't address use through grunt:
https://github.com/ericgio/react-bootstrap-typeahead/issues/2
which suggests using browserify-css transform.
I've tried to get grunt to use this transform by adding transform : ['browserify-css'] in the options field, but that didn't work. I still get the exact same error message.
I tried using browserify with the browserify-css transform on the command line to bundle up just this one library, and then include that bundle, but this leads to yet more errors down the line that I believe have to do with relative imports (and I don't think this is a good solution anyway because if I understand browserify right, it will end up including things like react twice, once for the typeahead bundle that I made on the command line and again for the actual app bundle and then the final js file is HUGE!).
Any ideas on how I can resolve this?
Thanks in advance!
So the solution it turns out was to add
"browserify": {
"transform": ["browserify-css"]
}
to the packages.json of react-bootstrap-typeahead.
It was in the browserify-css docs... (facepalm)
I have the following error for my files in tests:
Expected an assignment or function call and instead saw an expression.
It is generated from Chai libraries asserts. How can I turn it off in my .jshintrc file? I run a Gulp task based on it.
Here's how you can silence it inside of a .jshintrc file.
{
...
"expr": true
...
}
Source: http://jshint.com/docs/options/#expr
You can add the following on top of the line that's generating the error :
/*jshint -W030 */
Reference : http://jslinterrors.com/expected-an-assignment-or-function-call
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