expose JSHint's options as a configurable setting #895

Closed
NodeGuy opened this Issue Aug 26, 2012 · 9 comments

7 participants

@NodeGuy

Currently the options sent to JSHint are hardwired within javascript_worker.js:

lint(value, {undef: false, onevar: false, passfail: false});

Please make them available via the public API as a configurable setting.

@nightwing
Ajax.org B.V. member

i've started doing this in the worker branch
https://github.com/ajaxorg/ace/blob/2aae3e253f47d7422596d2908efcc7915728c064/lib/ace/mode/javascript_worker.js#L83-108

it's not very convenient to use now

ace.session.$worker.send("setOptions",[options])

and i'll probably add a way for setting default options for new workers
or make one worker for all sessions? need to think some more about this

@NodeGuy

Thank you. How do I use this?

@nightwing
Ajax.org B.V. member

something like this

function configureWorker(e, session) {
    if (session.getMode().id == "ace/mode/javascript")
    if (session.$worker) {
       session.$worker.send("changeOptions",[ {undef: true}])
       // or
       session.$worker.send("setOptions",[ {onevar: false, asi:true}])
    }
}
// after changing the session
session.on("changeMode", configureWorker)
@NodeGuy

Thank you!

@peterjosling peterjosling referenced this issue in CodeboxIDE/codebox Feb 26, 2014
Closed

Allow setting custom JSHint options #281

@homam

I hope it helps saving time: if you like to suppress specific error / warning codes use:

session.$worker.send("setOptions", [ { "-W095": false, "-W025": false }])
@hyusetiawan

@homam tried using that line, but it's not working, it complains that $worker is undefined, any other way to expose the jshint options? or disable the linting process altogether?

@rocketinventor

There should be a settings file.
The sublime version lets you edit the lint settings with a master settings file, as well as per-project setting file.

@homam

@hyusetiawan this is what I'm using:

editor.session.on('changeMode', function(e, session){
  if ("ace/mode/javascript" === session.getMode().$id) {
    if (!!session.$worker) {
      session.$worker.send("setOptions", [{
        "-W095": false,
        "-W025": false
      }]);
    }
  }
});
@electron0zero
electron0zero commented Jul 14, 2016 edited

i had to silence <something> is not defined warning so is modified @homam 's code like this

editor.session.on('changeMode', function(e, session){
      if ("ace/mode/javascript" === session.getMode().$id) {
          if (!!session.$worker) {
              session.$worker.send("setOptions", [{
                  "-W117": false
              }]);
          }
       }
    }); 

here W117 is warning code of <something> is not defined warning which i looked up in worker-javascript.js file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment