Repository: eslint/eslint (js)

Issue:
'one-var': separateRequires does not work in consecutive mode
<!--
    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).

    This template is for bug reports. If you are here for another reason, please see below:

    1. To propose a new rule: https://eslint.org/docs/developer-guide/contributing/new-rules
    2. To request a rule change: https://eslint.org/docs/developer-guide/contributing/rule-changes
    3. To request a change that is not a bug fix, rule change, or new rule: https://eslint.org/docs/developer-guide/contributing/changes
    4. If you have any questions, please stop by our chatroom: https://gitter.im/eslint/eslint

    Note that leaving sections blank will make it difficult for us to troubleshoot and we may have to close the issue.
-->

**Tell us about your environment**

* **ESLint Version:**5.3.0
* **Node Version:**8.11.3
* **npm Version:**6.2.0

**What parser (default, Babel-ESLint, etc.) are you using?**
babel-eslint

**Please show your full configuration:**

<details>
<summary>Configuration</summary>

<!-- Paste your configuration below: -->
```js
module.exports = {
  env: {
    browser: true,
    commonjs: true,
    es6: true,
    node: true,
    jest: true
  },
  parser: 'babel-eslint',
  rules: {
    'one-var': [2, { var: 'consecutive', let: 'consecutive', const: 'consecutive', separateRequires: true }],
  }
};
```

</details>

**What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.**

<!-- Paste the source code below: -->
```js
const foo = require("foo");
const bar = "bar";
```

<!-- Paste the command you used to run ESLint: -->
```bash

```

**What did you expect to happen?**
no error
**What actually happened? Please include the actual, raw output from ESLint.**
[eslint] Combine this with the previous 'const' statement. (one-var)

Pull request:
Fix: make separateRequires work in consecutive mode (fixes #10784)
<!--
    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).
-->

**What is the purpose of this pull request? (put an "X" next to item)**

[x] Bug fix ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/bug-report.md))

<!--
    If the item you've checked above has a template, please paste the template questions below and answer them. (If this pull request is addressing an issue, you can just paste a link to the issue here instead.)
-->

<!--
    Please ensure your pull request is ready:

    - Read the pull request guide (https://eslint.org/docs/developer-guide/contributing/pull-requests)
    - Include tests for this change
    - Update documentation for this change (if appropriate)
-->

<!--
    The following is required for all pull requests:
-->

**What changes did you make? (Give an overview)**
Fixes #10784 


Patch:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 411e7fb52..d0db77ccf 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -15,6 +15,8 @@ Before filing an issue, please be sure to read the guidelines for what you're re
 * [Proposing a Rule Change](https://eslint.org/docs/developer-guide/contributing/rule-changes)
 * [Request a Change](https://eslint.org/docs/developer-guide/contributing/changes)
 
+To report a security vulnerability in ESLint, please use our [HackerOne program](https://hackerone.com/eslint).
+
 ## Contributing Code
 
 Please sign our [Contributor License Agreement](https://cla.js.foundation/eslint/eslint) and read over the [Pull Request Guidelines](https://eslint.org/docs/developer-guide/contributing/pull-requests).
diff --git a/docs/developer-guide/contributing/README.md b/docs/developer-guide/contributing/README.md
index a4e331ef9..a22ea5d90 100644
--- a/docs/developer-guide/contributing/README.md
+++ b/docs/developer-guide/contributing/README.md
@@ -28,6 +28,10 @@ Want to make a change to an existing rule? This section explains the process and
 
 If you'd like to request a change other than a bug fix or new rule, this section explains that process.
 
+## Reporting a security vulnerability
+
+To report a security vulnerability in ESLint, please use our [HackerOne program](https://hackerone.com/eslint).
+
 ## [Working on Issues](working-on-issues.md)
 
 Have some extra time and want to contribute? This section talks about the process of working on issues.
diff --git a/lib/rules/one-var.js b/lib/rules/one-var.js
index 13ab72b04..15b664d77 100644
--- a/lib/rules/one-var.js
+++ b/lib/rules/one-var.js
@@ -384,8 +384,13 @@ module.exports = {
             if (nodeIndex > 0) {
                 const previousNode = parent.body[nodeIndex - 1];
                 const isPreviousNodeDeclaration = previousNode.type === "VariableDeclaration";
+                const declarationsWithPrevious = declarations.concat(previousNode.declarations || []);
 
-                if (isPreviousNodeDeclaration && previousNode.kind === type) {
+                if (
+                    isPreviousNodeDeclaration &&
+                    previousNode.kind === type &&
+                    !(declarationsWithPrevious.some(isRequire) && !declarationsWithPrevious.every(isRequire))
+                ) {
                     const previousDeclCounts = countDeclarations(previousNode.declarations);
 
                     if (options[type].initialized === MODE_CONSECUTIVE && options[type].uninitialized === MODE_CONSECUTIVE) {
diff --git a/package.json b/package.json
index 1a37b3c21..ebee08a93 100644
--- a/package.json
+++ b/package.json
@@ -39,7 +39,7 @@
     "ajv": "^6.5.3",
     "chalk": "^2.1.0",
     "cross-spawn": "^6.0.5",
-    "debug": "^3.1.0",
+    "debug": "^4.0.1",
     "doctrine": "^2.1.0",
     "eslint-scope": "^4.0.0",
     "eslint-utils": "^1.3.1",


Test patch:
diff --git a/tests/lib/config/config-validator.js b/tests/lib/config/config-validator.js
index 456b15183..b4cb2e41d 100644
--- a/tests/lib/config/config-validator.js
+++ b/tests/lib/config/config-validator.js
@@ -342,7 +342,7 @@ describe("Validator", () => {
             it("should throw if override has an empty files array", () => {
                 const fn = validator.validate.bind(null, { overrides: [{ files: [] }] }, "tests", ruleMapper, linter.environments);
 
-                assert.throws(fn, "ESLint configuration in tests is invalid:\n\t- Property \"overrides[0].files\" is the wrong type (expected string but got `[]`).\n\t- \"overrides[0].files\" should NOT have less than 1 items. Value: [].\n\t- \"overrides[0].files\" should match exactly one schema in oneOf. Value: [].\n");
+                assert.throws(fn, "ESLint configuration in tests is invalid:\n\t- Property \"overrides[0].files\" is the wrong type (expected string but got `[]`).\n\t- \"overrides[0].files\" should NOT have fewer than 1 items. Value: [].\n\t- \"overrides[0].files\" should match exactly one schema in oneOf. Value: [].\n");
             });
 
             it("should throw if override has nested overrides", () => {
diff --git a/tests/lib/rules/one-var.js b/tests/lib/rules/one-var.js
index 1f6626ad8..b628f512a 100644
--- a/tests/lib/rules/one-var.js
+++ b/tests/lib/rules/one-var.js
@@ -263,6 +263,13 @@ ruleTester.run("one-var", rule, {
             options: ["consecutive"],
             parserOptions: { ecmaVersion: 6 }
         },
+
+        // https://github.com/eslint/eslint/issues/10784
+        {
+            code: "const foo = require('foo'); const bar = 'bar';",
+            options: [{ const: "consecutive", separateRequires: true }],
+            parserOptions: { ecmaVersion: 6 }
+        },
         {
             code: "var a = 0, b = 1; var c, d;",
             options: [{ initialized: "consecutive", uninitialized: "always" }]
diff --git a/tests/lib/testers/rule-tester.js b/tests/lib/testers/rule-tester.js
index 4a8608906..5a582f976 100644
--- a/tests/lib/testers/rule-tester.js
+++ b/tests/lib/testers/rule-tester.js
@@ -640,7 +640,7 @@ describe("RuleTester", () => {
                     { code: "var answer = 6 * 7;", options: ["bar"], errors: [{ message: "Expected nothing." }] }
                 ]
             });
-        }, "Schema for rule no-invalid-schema is invalid:,\titems: should be object\n\titems[0].enum: should NOT have less than 1 items\n\titems: should match some schema in anyOf");
+        }, "Schema for rule no-invalid-schema is invalid:,\titems: should be object\n\titems[0].enum: should NOT have fewer than 1 items\n\titems: should match some schema in anyOf");
 
     });