eslint: const notDefined = notDefined; doesn't trigger no-undef

Eslint 2.11.1 doesn’t show any errors (violations of rule no-undef) for:

const notDefined = notDefined;

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (11 by maintainers)

Most upvoted comments

👍 Let’s move it to no-undef.

I’m not sure I agree with this suggestion. no-undef doesn’t currently know anything about TDZ, it only warns when a variable hasn’t been defined at all. no-use-before-define is explicitly for this case. Plus, I think we cause more confusion by moving a check from one rule to another vs. just keeping it as-is.

@mhagmajer None of our rules are turned on by default. But no-use-before-define sounds like the right rule to put this in.

Either way, I believe that no-undef is the right rule to handle this to prevent runtime errors.

On Fri, Jun 10, 2016, 22:11 Marcin Hagmajer mhagmajer@gmail.com wrote:

I’m pretty sure I do. We’re using the Airbnb’s eslint config.

On Fri, Jun 10, 2016, 22:09 Kevin Partington notifications@github.com wrote:

@ilyavolodin https://github.com/ilyavolodin Based on my analysis of the issue (which @mhagmajer https://github.com/mhagmajer seems to agree is correct), I think we might have a bug here-- unless we think that no-undef is not the place to catch this issue.

Personally I’m wondering if this should actually be handled by no-use-before-define.

@mhagmajer https://github.com/mhagmajer Do you have no-use-before-define enabled? If not, can you try it and let us know if that helps you with your issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/eslint/eslint/issues/6363#issuecomment-225283168, or mute the thread https://github.com/notifications/unsubscribe/ACmsIp8pZFcq7lFuNhnLNzDv48trSHh1ks5qKcSFgaJpZM4Iy8Ue .