-4

We are developing an android app with webviews. We're gonna have third part developers for this webviews, but we want to forbid them to use some libraries to force the use of our owns. In this case, we want to forbid the use of jQuery, among other prohibitions. Ideally, this prohibition should be integrated in a linter tool. I don't know much about linters so it will be very helpful if you guide me a little bit about what linter tool to use, or any other kind of help.

I don't know the best approach, maybe looking for a regex to find src="*jquery*" and integrate this search in a jshint patch?

Thanks!

R01010010
  • 5,670
  • 11
  • 47
  • 77

1 Answers1

1

jQuery defines two global variables in its source. You could use the jsHint rule undef to disallow the use of undeclared variables in the code. This would mean that if they used $ or jQuery in their code then it would fail jsHint linting. For you to be able to use globals yourself you would then need to use the globals rule to give yourself a white list of allowed globals.

Zac Braddy
  • 611
  • 5
  • 12
  • 1
    unless, of course, they used the `/* global $, jQuery */` linter override comment in their code, which can't be prevented from linter configs. – LJHarb Nov 12 '15 at 10:38
  • @LJHarb Yes, you are absolutely correct. However, what you have there is a third party developer intentionally contravening a rule that you have put in place. I'm not saying that wouldn't happen but if I hired third party developers and I explicitly said to them, don't use jQuery and I even put in rules to stop it and then after that they still used jQuery. Then that would be a serious judgement error on their part. Not only would they lose my future business but it would certainly cause them problems for intentionally breaking the terms of this contract, and I would have the proof! – Zac Braddy Nov 12 '15 at 10:49
  • 1
    @ZacBraddy I love you. Is evident they can pass by the prohibition, but we're gonna supervise the code at the end, so better to inform then as soon as possible. The use of our own libraries is because jquery is very focused in crossbrowser but we don't need that for an android webview. Also many people use jquery for using their selectors but actually they're already in the native javascript. – R01010010 Nov 12 '15 at 10:51