<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
A pre-processor may not be the way to go because a variable imported
by Cu.import may not be in the global scope.<br>
<br>
Of course, if we could use a pre-processor and preserver the scope
that would be awesome.<br>
<br>
> - Rules are normally supposed to output messages (actually
check code) rather than change the environment<br>
<br>
Still, it is awesome that we can do things like importing the
globals from a mochitest's head.js... we could also do the same for
head and tail files in xpcshell tests.<br>
<br>
/Mike<br>
<br>
<div class="moz-cite-prefix">On 08/12/2015 06:46, Patrick Brosset
wrote:<br>
</div>
<blockquote
cite="mid:CABcuYMB418pFkNHjHytE+kB-BgPSQooZZqTDuGp=_s9gL_SBww@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Sat, Dec 5, 2015 at 5:52 AM, Mark
Banner <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:mbanner@mozilla.com" target="_blank">mbanner@mozilla.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex"><span class="">On
04/12/2015 19:15, Patrick Brosset wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px
0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
I just discovered the concept of pre-processors in
eslint, I had no idea this even existed. Find out more
info here:<br>
<a moz-do-not-send="true"
href="http://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins"
rel="noreferrer" target="_blank">http://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins</a><br>
<br>
tl;dr;<br>
We can use this to process our source files before
eslint rules are run on them.<br>
So, in particular, we can do things like:<br>
- filter out ifdef instructions,<br>
- define global variables from imported modules (from
e.g. Cu.import)<br>
</blockquote>
</span>
There's already at least a partial plugin for Cu.import
and friends:<br>
<br>
<a moz-do-not-send="true"
href="http://mxr.mozilla.org/mozilla-central/source/testing/eslint-plugin-mozilla/lib/rules/"
rel="noreferrer" target="_blank">http://mxr.mozilla.org/mozilla-central/source/testing/eslint-plugin-mozilla/lib/rules/</a><span
class=""><font color="#888888"><br>
<br>
</font></span></blockquote>
<div><br>
</div>
<div>Yes I know this particular rule. I think it'd be good
to remove it though, and use a pre-processor instead
because:<br>
</div>
<div><br>
- Rules are normally supposed to output messages (actually
check code) rather than change the environment (in this
case, by declaring a new global variable for the
Cu.import). This isn't a big problem in itself, but still
it forces you to make sure that rule runs first.<br>
</div>
<div>- Adding variables to the ESLint's scope while it runs
is hacky, it relies on unsupported internal APIs, and I've
had to fix this last week already (bug 1230093).<br>
<br>
</div>
<div>Using a pre-processor instead makes it possible to
re-write code before the rules are executed, and so we can
use this to replace things eslint doesn't understand as
variable declarations with actual variable declarations.<br>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex"><span class=""><font
color="#888888">
Mark.</font></span>
<div class="">
<div class="h5"><br>
_______________________________________________<br>
firefox-dev mailing list<br>
<a moz-do-not-send="true"
href="mailto:firefox-dev@mozilla.org"
target="_blank">firefox-dev@mozilla.org</a><br>
<a moz-do-not-send="true"
href="https://mail.mozilla.org/listinfo/firefox-dev"
rel="noreferrer" target="_blank">https://mail.mozilla.org/listinfo/firefox-dev</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
firefox-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:firefox-dev@mozilla.org">firefox-dev@mozilla.org</a>
<a class="moz-txt-link-freetext" href="https://mail.mozilla.org/listinfo/firefox-dev">https://mail.mozilla.org/listinfo/firefox-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>