Since we're already relying on internals it makes more sense to just use
escope's function for declaring variables. We then have to remove references
from the through array and update them to point to their variables, this was
cribbed from https://github.com/eslint/eslint/blob/master/lib/eslint.js#L180
MozReview-Commit-ID: JD7CFm1aO6T
--HG--
extra : rebase_source : ff5ab7359457db0cdae744523fa5f5da461ca154
xpcshell tests used to use head_*.js files so this adds those for global
discovery.
MozReview-Commit-ID: BOsoGIpwdgu
--HG--
extra : rebase_source : ef36531641cbd353625019f8deba333cfd352891
extra : source : 70eca07367f40a9b4fe8c6e23ec0aef73bf2a962
This adds more of the scripts that browser.js relies on and also makes
browser-chrome head files import the browser.js globals.
The MOZ_JSDOWNLOADS block in contentAreaUtils only seems to hide a single
function, I don't see any need to keep hiding that now we're on by default.
MozReview-Commit-ID: 5zvF3JtJrZG
--HG--
extra : rebase_source : 94daff602b51d7ad57a24872d9eba9b304cf2da9
extra : source : b554c7ce41c42f16c2279ae88fd9567da7509bff
To properly lint XBL files we need to support things like import-globals-from
and other ESlint comment directives so we have to pass comments through to the
code blocks that ESlint parses. Unfortunately the way the XBL processor works
now is by passing a separate code block for every method/property/etc. in the
XBL and ESlint doesn't retain state across the blocks so we would have to prefix
every block with every comment. Instead this change makes us output just a
single block that roughly looks like this:
<comments>
var bindings = {
"<binding-id>": {
<binding-part-name>: function() { ... }
}
}
This has some interesting bonuses. Defining the same ID twice will cause a lint
failure. Same for the same field in a binding. The line mapping is a little
harder and there are still a few lines that won't map directly back to the
original file but they should be rare cases. The only downside is that since
some bindings have the same binding declared differently for different platforms
we have to exclude those from linting for now.
MozReview-Commit-ID: CAsPt5dtf6T
--HG--
extra : rebase_source : 91a60ef0359ef53093fe197ed63dbc4e1a9f10a5
extra : source : 01675e4828b524c04a9057d68b41e9cc01ca1bb9
While working on turning on no-undef I discovered that the various rules we
have for defining globals are a little inconsistent in whether the files they
load recurse through import-globals-from directives and none of them imported
eslint globals directives.
I think we're better off putting all this global parsing code in a single place
rather than spread across multiple rules. Have one rule to turn it on for
parsed files and one function to load globals from other files and make them
share most of the code so we won't get inconsistent. If we find us needing to
turn on/off individual features we can figure out a way to do that in the
future.
This patch does that, the globals.js file does all global parsing with a shared
object that receives events from the AST, either through from an ESlint rule
or from a simple AST walker using estraverse.
MozReview-Commit-ID: 9KQZwsNNOUl
--HG--
extra : rebase_source : 0f1cceca29ac398be97a55bbcd09fe58a8be1435
extra : source : 878db4caf845282f06542793bc4b5c24fa658c14
xpcshell tests used to use head_*.js files so this adds those for global
discovery.
MozReview-Commit-ID: BOsoGIpwdgu
--HG--
extra : rebase_source : 0071e0fa7361e67e6c84bca2f4a0c5b1a3c634db
This adds more of the scripts that browser.js relies on and also makes
browser-chrome head files import the browser.js globals.
The MOZ_JSDOWNLOADS block in contentAreaUtils only seems to hide a single
function, I don't see any need to keep hiding that now we're on by default.
MozReview-Commit-ID: 5zvF3JtJrZG
--HG--
extra : rebase_source : a99f752b053765b621cf03965bda0c586a9eb1cb
To properly lint XBL files we need to support things like import-globals-from
and other ESlint comment directives so we have to pass comments through to the
code blocks that ESlint parses. Unfortunately the way the XBL processor works
now is by passing a separate code block for every method/property/etc. in the
XBL and ESlint doesn't retain state across the blocks so we would have to prefix
every block with every comment. Instead this change makes us output just a
single block that roughly looks like this:
<comments>
var bindings = {
"<binding-id>": {
<binding-part-name>: function() { ... }
}
}
This has some interesting bonuses. Defining the same ID twice will cause a lint
failure. Same for the same field in a binding. The line mapping is a little
harder and there are still a few lines that won't map directly back to the
original file but they should be rare cases. The only downside is that since
some bindings have the same binding declared differently for different platforms
we have to exclude those from linting for now.
MozReview-Commit-ID: CAsPt5dtf6T
--HG--
extra : rebase_source : 700db61686d5eac3f05f758ad1ce505bcdb6aa7f
While working on turning on no-undef I discovered that the various rules we
have for defining globals are a little inconsistent in whether the files they
load recurse through import-globals-from directives and none of them imported
eslint globals directives.
I think we're better off putting all this global parsing code in a single place
rather than spread across multiple rules. Have one rule to turn it on for
parsed files and one function to load globals from other files and make them
share most of the code so we won't get inconsistent. If we find us needing to
turn on/off individual features we can figure out a way to do that in the
future.
This patch does that, the globals.js file does all global parsing with a shared
object that receives events from the AST, either through from an ESlint rule
or from a simple AST walker using estraverse.
MozReview-Commit-ID: 9KQZwsNNOUl
--HG--
extra : rebase_source : 7c77b808d711cc863ff682af8d2de0c4853319b8
We're attemping to find globals in JS from many places, this attempts to make
them all use the same methods. Since in some cases we're parsing new files we
can't use the eslint methods for getting the source so I've added a simple way
to convert from AST to a JS string.
--HG--
extra : commitid : DXo4A1fG3Gy
extra : rebase_source : 6a2a03d21d02331ae336c6b363d3951f4b6110aa
Fixing some XBL files turned up some bugs in the preprocessor:
* XBL fields aren't just simple JS assignements, they are entire JS blocks which
are evaluated and the result used for the field. So we don't need eslint to
parse them as an assignment.
* XBL text can contain entities, in general just replacing every entity with a
valid JS token should retain the meaning well enough for eslint's purposes.
* Events can have names that aren't valid JS identifiers so just don't use them.
--HG--
extra : commitid : 65gYzRiXqKe
extra : rebase_source : 9a6bcdd22f63b4aba52052f4f4ad0f20e6a2b446
Added use strict statements now that we are no longer set up for ES6 modules.
--HG--
extra : commitid : BjJFvuFTZXZ
extra : rebase_source : 7781800bce61036a04734b858c8d7d13910377f1