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

one-var rule doesn't work properly with separateRequires and const #11312

Closed
korneliakobiela opened this issue Jan 24, 2019 · 1 comment
Closed
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon

Comments

@korneliakobiela
Copy link

Tell us about your environment

  • ESLint Version: 5.12.1
  • Node Version: v10.15.0
  • npm Version: 6.5.0
  • operating system: Ubuntu 18.04

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

Configuration
{
    "env": {
        "browser": true,
        "commonjs": true,
        "es6": true,
        "node": true
    },
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaVersion": 2018
    },
    "rules": {
        "indent": [
            "error",
            4
        ],
        "linebreak-style": [
            "error",
            "unix"
        ],
        "quotes": [
            "error",
            "single"
        ],
        "semi": [
            "error",
            "always"
        ],
        "no-var": "error",
        "one-var": [
            "error",
            {
                "separateRequires": true,
                "const": "always"
            }
        ]   
    }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
I would like to attach my Gitlab repo with some demo about this issue.

const path = require('path');
const fs = require('fs');

fs.readFile(path.join(__dirname, 'package.json'), 'utf8', (err, data) => {
    if (err) {
        throw err;
    }
    const welcome = 'Hello';
    const devDependencies = JSON.parse(data).devDependencies;

    for (const dependency in devDependencies.devDependencies) {
        if (devDependencies.hasOwnProperty(dependency)) {
            const element = devDependencies[dependency];
            /* eslint-disable no-alert, no-console */
            console.log(`${welcome}, ${element}!`);
        }
    }
    
});
 ./node_modules/.bin/eslint index.js

What did you expect to happen?
One problem (error) into the eslint output

9:5 error Combine this with the previous 'const' statement one-var
What actually happened? Please include the actual, raw output from ESLint.

/home/kornelia/test/index.js
  2:1  error  Combine this with the previous 'const' statement  one-var
  9:5  error  Combine this with the previous 'const' statement  one-var

✖ 2 problems (2 errors, 0 warnings)
  2 errors and 0 warnings potentially fixable with the `--fix` option.

Are you willing to submit a pull request to fix this bug?
Yes, but I am not even started coding it :)

@korneliakobiela korneliakobiela added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jan 24, 2019
@g-plane
Copy link
Member

g-plane commented Jan 24, 2019

Duplicate of #10179

@g-plane g-plane marked this as a duplicate of #10179 Jan 24, 2019
@g-plane g-plane closed this as completed Jan 24, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 24, 2019
@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 Jul 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon
Projects
None yet
Development

No branches or pull requests

2 participants