| Summary: | [eslint] erroneous "variable is not defined" warnings from ESLint | ||
|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Manu Sridharan <m.sridharan> |
| Component: | JS Tools | Assignee: | Mark Macdonald <mamacdon> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | mamacdon |
| Version: | unspecified | ||
| Target Milestone: | 5.0 M1 | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| Whiteboard: | |||
|
Description
Manu Sridharan
Thanks Manu, I can reproduce this too. The problematic rule is 'no-undef', which is used in both ESLint master and Orion, but our drop of ESLint is several months behind master, so this bug may've been fixed upstream there. Might also be a bug in escope (one of ESLint's dependencies), as we're using an old version of that as well. Anyway, I'll have a look. > Is there some way to run eslint with Orion's custom rules from the command > line? If so, I can try to find a smaller input that reproduces the behavior. Yes: in the Orion client repo, cd to bundles/org.eclipse.orion.client.javascript/web/eslint/ and run > npm install To grab the dependencies. The tests are in tests/lib/rules/ -- to run them just do > mocha tests/lib/rules or for a single file: > mocha tests/lib/rules/no-undef.js Cool, here's a much smaller input that shows the problem, minimized from the previous one:
(function() {
var MODE_RECORD = 1;
function callAsNativeConstructorWithEval() {
return eval();
}
})();
Thanks! It looks like this issue in escope: https://github.com/Constellation/escope/issues/27 The fix is to use the 'optimistic' option, but... that doesn't exist in escope v0.0.14, which is what we have approved. I will try opening another CQ to pick up a newer release. It looks like in eslint, they passed an 'ignoreEval' option to escope to address the related bug: https://github.com/nzakas/eslint/commit/736d0eed4ccfbd886673ba551412f92904db8e5e But it looks like the ignoreEval option isn't in the version of escope currently packaged with Orion either...oh well. Yes, I think ignoreEval was the original name for 'optimistic' in older versions of escope. https://github.com/Constellation/escope/pull/18#issuecomment-20326035 I'm hoping to just move up to escope 1.0.0 and refactor no-undef to take advantage of the new globalScope.implicit data structure that they now provide. Updated eslint and escope, so this should be fixed now. \ |