Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ecmaFeatures.modules conflicts with block-scoped-var #2967

Closed
gmathieu opened this issue Jul 10, 2015 · 5 comments
Closed

ecmaFeatures.modules conflicts with block-scoped-var #2967

gmathieu opened this issue Jul 10, 2015 · 5 comments
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@gmathieu
Copy link

When ecmaFeatures.module=true, functions calls before declaration throws a block-scoped-var error. This test is using the default parser v0.24.1 but I believe I've seen something similar using babel-eslint.

(function () {
    fnDeclaredBelow(); // error: fnDeclaredBelow used outside of binding context
})();

function fnDeclaredBelow () {
    return true;
}

Here's the associated .eslintrc. If you switch module to false the above code validates properly.

{
  "env": {
    "es6": true,
  },
  "rules": {
    "block-scoped-var": 2,
    "no-use-before-define": [2, "nofunc"],
    "strict": [2, "never"],
  },
  "ecmaFeatures": {
    "modules": true,
  },
}
@gyandeeps gyandeeps added the triage An ESLint team member will look at this issue soon label Jul 10, 2015
@gyandeeps
Copy link
Member

@eslint/eslint-team input please.

@nzakas
Copy link
Member

nzakas commented Jul 25, 2015

@gmathieu what about if modules is false? Is the behavior different?

@mysticatea
Copy link
Member

I confirmed this issue, and #3126 fixes this.

(If modules flag is false, both are no errors as expected.)

test.js

(function () {
    fnDeclaredBelow(); // error: fnDeclaredBelow used outside of binding context
})();

function fnDeclaredBelow () {
    return true;
}

.eslintrc

ecmaFeatures:
    modules: true
rules:
    block-scoped-var: 2

Command & Actual

> eslint -v
v1.0.0-rc-3
> eslint test.js

test.js
  3:5  error  "fnDeclaredBelow" used outside of binding context  block-scoped-var

✖ 1 problem (1 error, 0 warnings)
> git log -1
commit 6a77f79f507fddb574a438e9ab29118caeb4d7a8
Author: Toru Nagashima <star.ctor@gmail.com>
Date:   Wed Jul 22 22:38:06 2015 +0900

    Fix: `block-scoped-var` issues (fixes #2253, fixes #2747)
> node bin/eslint.js test.js
>

No errors.

Expected

No errors.

@nzakas nzakas added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jul 27, 2015
@nzakas
Copy link
Member

nzakas commented Jul 27, 2015

@mysticatea can you add a test case for this in #3126?

@mysticatea
Copy link
Member

@nzakas Sure.

mysticatea added a commit to mysticatea/eslint that referenced this issue Jul 27, 2015
mysticatea added a commit to mysticatea/eslint that referenced this issue Jul 27, 2015
@mysticatea mysticatea self-assigned this Jul 27, 2015
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

4 participants