Repository: eslint/eslint
Pull request #9450 (2017-10-16 03:08:17)

Fix: multiline-comment-style reports block comments followed by code
<!--
    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

<!--
    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.)
-->

**Tell us about your environment**

* **ESLint Version:** 4.9.0
* **Node Version:** 8.7.0
* **npm Version:** 5.4.2

**What parser (default, Babel-ESLint, etc.) are you using?**

default

**Please show your full configuration:**

```yml
rules:
  multiline-comment-style: [error, separate-lines]
```

**What did you do? Please include the actual source code causing the issue.**

```js
/* foo
  bar */ baz;
```

**What did you expect to happen?**

I expected no error to be reported, because that comment can't safely be converted into line comments.

**What actually happened? Please include the actual, raw output from ESLint.**

ESLint autofixed the code to:

```js
// foo
// bar baz
```

In other words, the `baz` statement was incorrectly converted into a comment.

[Demo](https://eslint.org/demo/#eyJ0ZXh0IjoiLyogZXNsaW50IG11bHRpbGluZS1jb21tZW50LXN0eWxlOiBbZXJyb3IsIHNlcGFyYXRlLWxpbmVzXSAqL1xuXG4vKiBmb29cbiAgYmFyICovIGJhejsiLCJvcHRpb25zIjp7InBhcnNlck9wdGlvbnMiOnsiZWNtYVZlcnNpb24iOjYsInNvdXJjZVR5cGUiOiJtb2R1bGUiLCJlY21hRmVhdHVyZXMiOnsianN4Ijp0cnVlfX0sInJ1bGVzIjp7fSwiZW52Ijp7fX19)

<!--
    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)**

This updates the `multiline-comment-style` rule to ignore block comments which are followed by code on the same line when using the `separate-lines` option.

This bug was detected using the fuzzer with `npm run fuzz`, which produced 7 errors caused by this issue.

**Is there anything you'd like reviewers to focus on?**

Nothing in particular

eslintbot: LGTM

Patch:
diff --git a/docs/developer-guide/contributing/pull-requests.md b/docs/developer-guide/contributing/pull-requests.md
index 3fb32146d..07a42b697 100644
--- a/docs/developer-guide/contributing/pull-requests.md
+++ b/docs/developer-guide/contributing/pull-requests.md
@@ -77,7 +77,7 @@ Here are some good commit message summary examples:
 ```
 Build: Update Travis to only test Node 0.10 (refs #734)
 Fix: Semi rule incorrectly flagging extra semicolon (fixes #840)
-Upgrade: Esprima to 1.2, switch to using Esprima comment attachment (fixes #730)
+Upgrade: Esprima to 1.2, switch to using comment attachment (fixes #730)
 ```
 
 The commit message format is important because these messages are used to create a changelog for each release. The tag and issue number help to create more consistent and useful changelogs.
diff --git a/docs/developer-guide/development-environment.md b/docs/developer-guide/development-environment.md
index afbab5641..0f56f15fa 100644
--- a/docs/developer-guide/development-environment.md
+++ b/docs/developer-guide/development-environment.md
@@ -21,8 +21,6 @@ $ npm install
 
 You must be connected to the Internet for this step to work. You'll see a lot of utilities being downloaded.
 
-If you have an ESLint configuration file in your home directory (such as `~/.eslintrc.js`), either delete or rename it. This will help ensure that all the tests in Step 5 pass. It will also prevent ESLint from running with an incorrect configuration in case the configuration file in your development environment becomes misnamed, moved, or deleted.
-
 ## Step 3: Add the upstream source
 
 The *upstream source* is the main ESLint repository that active development happens on. While you won't have push access to upstream, you will have pull access, allowing you to pull in the latest code whenever you want.
diff --git a/docs/user-guide/README.md b/docs/user-guide/README.md
index 50d33e149..36e059a48 100644
--- a/docs/user-guide/README.md
+++ b/docs/user-guide/README.md
@@ -2,7 +2,7 @@
 
 This guide is intended for those who wish to use ESLint as an end-user. If you're looking for how to extend ESLint or work with the ESLint source code, please see the [Developer Guide](../developer-guide).
 
-## [Getting Started](getting-started)
+## [Getting Started](getting-started.md)
 
 Want to skip ahead and just start using ESLint? This section gives a high-level overview of installation, setup, and configuration options.
 
@@ -10,22 +10,27 @@ Want to skip ahead and just start using ESLint? This section gives a high-level
 
 ESLint has a lot of rules that you can configure to fine-tune it to your project. This section is an exhaustive list of every rule and link to each rule's documentation.
 
-## [Configuring](configuring)
+## [Configuring](configuring.md)
 
 Once you've got ESLint running, you'll probably want to adjust the configuration to better suit your project. This section explains all the different ways you can configure ESLint.
 
-## [Command Line Interface](command-line-interface)
+## [Command Line Interface](command-line-interface.md)
 
 There are a lot of command line flags for ESLint and this section explains what they do.
 
-## [Integrations](integrations)
+## [Integrations](integrations.md)
 
 Wondering if ESLint will work with your favorite editor or build system? This section has a list of all known integrations (submitted by their authors).
 
-## [Rule Deprecation](rule-deprecation)
+## [Rule Deprecation](rule-deprecation.md)
 
 The ESLint team is committed to making upgrading as easy and painless as possible. This section outlines the guidelines the team has set in place for the deprecation of rules in future releases.
 
-## [Migrating to 1.0.0](migrating-to-1.0.0)
+## Migrating
 
-If you were using a version of ESLint prior to v1.0.0, this section helps you with the transition.
+If you were using a prior version of ESLint, you can get help with the transition by reading:
+
+- [migrating-to-1.0.0](migrating-to-1.0.0.md)
+- [migrating-to-2.0.0](migrating-to-2.0.0.md)
+- [migrating-to-3.0.0](migrating-to-3.0.0.md)
+- [migrating-to-4.0.0](migrating-to-4.0.0.md)
diff --git a/docs/user-guide/configuring.md b/docs/user-guide/configuring.md
index ed1f573fa..3561502d0 100644
--- a/docs/user-guide/configuring.md
+++ b/docs/user-guide/configuring.md
@@ -3,7 +3,9 @@
 ESLint is designed to be completely configurable, meaning you can turn off every rule and run only with basic syntax validation, or mix and match the bundled rules and your custom rules to make ESLint perfect for your project. There are two primary ways to configure ESLint:
 
 1. **Configuration Comments** - use JavaScript comments to embed configuration information directly into a file.
-1. **Configuration Files** - use a JavaScript, JSON or YAML file to specify configuration information for an entire directory and all of its subdirectories. This can be in the form of an [.eslintrc.*](#configuration-file-formats) file or an `eslintConfig` field in a [`package.json`](https://docs.npmjs.com/files/package.json) file, both of which ESLint will look for and read automatically, or you can specify a configuration file on the [command line](command-line-interface).
+1. **Configuration Files** - use a JavaScript, JSON or YAML file to specify configuration information for an entire directory (other than your home directory) and all of its subdirectories. This can be in the form of an [.eslintrc.*](#configuration-file-formats) file or an `eslintConfig` field in a [`package.json`](https://docs.npmjs.com/files/package.json) file, both of which ESLint will look for and read automatically, or you can specify a configuration file on the [command line](command-line-interface).
+
+    If you have a configuration file in your home directory (generally `~/`), ESLint uses it **only** if ESLint cannot find any other configuration file.
 
 There are several pieces of information that can be configured:
 
diff --git a/lib/rules/generator-star-spacing.js b/lib/rules/generator-star-spacing.js
index 5c6120224..a718b59af 100644
--- a/lib/rules/generator-star-spacing.js
+++ b/lib/rules/generator-star-spacing.js
@@ -68,7 +68,7 @@ module.exports = {
 
         /**
          * Returns resolved option definitions based on an option and defaults
-         * 
+         *
          * @param {any} option - The option object or string value
          * @param {Object} defaults - The defaults to use if options are not present
          * @returns {Object} the resolved object definition
@@ -121,7 +121,7 @@ module.exports = {
 
         /**
          * Checks the spacing between two tokens before or after the star token.
-         * 
+         *
          * @param {string} kind Either "named", "anonymous", or "method"
          * @param {string} side Either "before" or "after".
          * @param {Token} leftToken `function` keyword token if side is "before", or
@@ -161,7 +161,7 @@ module.exports = {
 
         /**
          * Enforces the spacing around the star if node is a generator function.
-         * 
+         *
          * @param {ASTNode} node A function expression or declaration node.
          * @returns {void}
          */
diff --git a/lib/rules/multiline-comment-style.js b/lib/rules/multiline-comment-style.js
index d323d882a..cde28fd88 100644
--- a/lib/rules/multiline-comment-style.js
+++ b/lib/rules/multiline-comment-style.js
@@ -188,6 +188,11 @@ module.exports = {
                 if (!isJSDoc(commentGroup) && commentGroup[0].type === "Block") {
                     const commentLines = getCommentLines(commentGroup);
                     const block = commentGroup[0];
+                    const tokenAfter = sourceCode.getTokenAfter(block, { includeComments: true });
+
+                    if (tokenAfter && block.loc.end.line === tokenAfter.loc.start.line) {
+                        return;
+                    }
 
                     context.report({
                         loc: {
diff --git a/lib/rules/no-constant-condition.js b/lib/rules/no-constant-condition.js
index 31e5b372c..0cd445dfd 100644
--- a/lib/rules/no-constant-condition.js
+++ b/lib/rules/no-constant-condition.js
@@ -138,7 +138,7 @@ module.exports = {
         function checkConstantConditionLoopInSet(node) {
             if (loopsInCurrentScope.has(node)) {
                 loopsInCurrentScope.delete(node);
-                context.report({ node, message: "Unexpected constant condition." });
+                context.report({ node: node.test, message: "Unexpected constant condition." });
             }
         }
 
@@ -150,7 +150,7 @@ module.exports = {
          */
         function reportIfConstant(node) {
             if (node.test && isConstant(node.test, true)) {
-                context.report({ node, message: "Unexpected constant condition." });
+                context.report({ node: node.test, message: "Unexpected constant condition." });
             }
         }
 
diff --git a/lib/rules/no-trailing-spaces.js b/lib/rules/no-trailing-spaces.js
index b5d2f8d1b..598bbea4f 100644
--- a/lib/rules/no-trailing-spaces.js
+++ b/lib/rules/no-trailing-spaces.js
@@ -49,7 +49,7 @@ module.exports = {
 
         const options = context.options[0] || {},
             skipBlankLines = options.skipBlankLines || false,
-            ignoreComments = typeof options.ignoreComments === "undefined" || options.ignoreComments;
+            ignoreComments = typeof options.ignoreComments === "boolean" && options.ignoreComments;
 
         /**
          * Report the error message


Test patch:
diff --git a/tests/bench/bench.js b/tests/bench/bench.js
index ccae42fc6..be574cf33 100644
--- a/tests/bench/bench.js
+++ b/tests/bench/bench.js
@@ -33,7 +33,6 @@ function benchmark(grep, times) {
 
 function run(content, times) {
     while(times--) {
-        linter.reset();
         linter.verify(content, config);
     }
 }
diff --git a/tests/bench/xform-rules.js b/tests/bench/xform-rules.js
index fa13aa7f7..9456f3258 100644
--- a/tests/bench/xform-rules.js
+++ b/tests/bench/xform-rules.js
@@ -3,7 +3,7 @@ module.exports = transform;
 var fs = require("fs"),
     path = require("path"),
     through = require("through");
-    
+
 var target = path.resolve(__dirname, "..", "..", "lib", "load-rules.js");
 
 
@@ -23,10 +23,14 @@ function inject() {
     var output = "module.exports = function() {\n";
     output += "    var rules = Object.create(null);\n";
 
-    fs.readdirSync(path.resolve(__dirname, "..", "..", "lib", "rules")).forEach(function(filename) {
-        var basename = path.basename(filename, ".js");
-        output += "    rules[\"" + basename + "\"] = require(\"./rules/" + basename + "\");\n";
-    });
+    fs.readdirSync(path.resolve(__dirname, "..", "..", "lib", "rules"))
+        .filter(function(filename) {
+            return filename.endsWith(".js");
+        })
+        .forEach(function(filename) {
+            var basename = path.basename(filename, ".js");
+            output += "    rules[\"" + basename + "\"] = require(\"./rules/" + basename + "\");\n";
+        });
 
     output += "\n    return rules;\n};";
 
diff --git a/tests/bin/eslint.js b/tests/bin/eslint.js
index 6c7cd0990..7d6bbaf69 100644
--- a/tests/bin/eslint.js
+++ b/tests/bin/eslint.js
@@ -122,21 +122,35 @@ describe("bin/eslint.js", () => {
             return assertExitCode(child, 1);
         });
 
-        it("gives a detailed error message if no config file is found in / or in ~/", () => {
-
-            // Assumes the root and home directories have no .eslintrc file.
-            const child = runESLint(["--stdin"], { cwd: "/" });
-
-            const exitCodePromise = assertExitCode(child, 1);
-            const stdoutPromise = getOutput(child).then(output => {
-                assert.match(output.stderr, /ESLint couldn't find a configuration file/);
-            });
+        it(
+            "gives a detailed error message if no config file is found in /",
+            () => {
+                if (
+                    fs.readdirSync("/").some(
+                        fileName =>
+                            /^\.eslintrc(?:\.(?:js|yaml|yml|json))?$/
+                                .test(fileName)
+                    )
+                ) {
+                    return Promise.resolve(true);
+                }
+                const child = runESLint(
+                    ["--stdin"], { cwd: "/", env: { HOME: "/" } }
+                );
 
-            child.stdin.write("var foo = bar\n");
-            child.stdin.end();
+                const exitCodePromise = assertExitCode(child, 1);
+                const stderrPromise = getOutput(child).then(output => {
+                    assert.match(
+                        output.stderr,
+                        /ESLint couldn't find a configuration file/
+                    );
+                });
 
-            return Promise.all([exitCodePromise, stdoutPromise]);
-        });
+                child.stdin.write("1 < 3;\n");
+                child.stdin.end();
+                return Promise.all([exitCodePromise, stderrPromise]);
+            }
+        );
 
     });
 
diff --git a/tests/lib/rules/multiline-comment-style.js b/tests/lib/rules/multiline-comment-style.js
index f5c23bad1..37739a4c9 100644
--- a/tests/lib/rules/multiline-comment-style.js
+++ b/tests/lib/rules/multiline-comment-style.js
@@ -144,6 +144,13 @@ ruleTester.run("multiline-comment-style", rule, {
             `,
             options: ["separate-lines"]
         },
+        {
+            code: `
+                /* this is
+                   a comment */ foo;
+            `,
+            options: ["separate-lines"]
+        },
         {
             code: `
                 /* eslint semi: "error" */
@@ -325,6 +332,21 @@ ruleTester.run("multiline-comment-style", rule, {
             `,
             errors: [{ message: ALIGNMENT_ERROR, line: 5 }]
         },
+        {
+            code: `
+                /*
+                 * the last line of this comment
+                 * is misaligned
+                   */ foo
+            `,
+            output: `
+                /*
+                 * the last line of this comment
+                 * is misaligned
+                 */ foo
+            `,
+            errors: [{ message: ALIGNMENT_ERROR, line: 5 }]
+        },
         {
             code: `
                 /*
diff --git a/tests/lib/rules/no-constant-condition.js b/tests/lib/rules/no-constant-condition.js
index b113ebb09..9f7bc4c0d 100644
--- a/tests/lib/rules/no-constant-condition.js
+++ b/tests/lib/rules/no-constant-condition.js
@@ -71,90 +71,90 @@ ruleTester.run("no-constant-condition", rule, {
         "function* foo() { for (let x = yield; ; x++) { yield; }}"
     ],
     invalid: [
-        { code: "for(;true;);", errors: [{ message: "Unexpected constant condition.", type: "ForStatement" }] },
-        { code: "do{}while(true)", errors: [{ message: "Unexpected constant condition.", type: "DoWhileStatement" }] },
-        { code: "do{}while(t = -2)", errors: [{ message: "Unexpected constant condition.", type: "DoWhileStatement" }] },
-        { code: "true ? 1 : 2;", errors: [{ message: "Unexpected constant condition.", type: "ConditionalExpression" }] },
-        { code: "q = 0 ? 1 : 2;", errors: [{ message: "Unexpected constant condition.", type: "ConditionalExpression" }] },
-        { code: "(q = 0) ? 1 : 2;", errors: [{ message: "Unexpected constant condition.", type: "ConditionalExpression" }] },
-        { code: "if(-2);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(true);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if({});", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(0 < 1);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(0 || 1);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(a, 1);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-
-        { code: "while([]);", errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }] },
-        { code: "while(~!0);", errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }] },
-        { code: "while(x = 1);", errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }] },
-        { code: "while(function(){});", errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }] },
-        { code: "while(true);", errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }] },
-        { code: "while(() => {});", errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }] },
+        { code: "for(;true;);", errors: [{ message: "Unexpected constant condition.", type: "Literal" }] },
+        { code: "do{}while(true)", errors: [{ message: "Unexpected constant condition.", type: "Literal" }] },
+        { code: "do{}while(t = -2)", errors: [{ message: "Unexpected constant condition.", type: "AssignmentExpression" }] },
+        { code: "true ? 1 : 2;", errors: [{ message: "Unexpected constant condition.", type: "Literal" }] },
+        { code: "q = 0 ? 1 : 2;", errors: [{ message: "Unexpected constant condition.", type: "Literal" }] },
+        { code: "(q = 0) ? 1 : 2;", errors: [{ message: "Unexpected constant condition.", type: "AssignmentExpression" }] },
+        { code: "if(-2);", errors: [{ message: "Unexpected constant condition.", type: "UnaryExpression" }] },
+        { code: "if(true);", errors: [{ message: "Unexpected constant condition.", type: "Literal" }] },
+        { code: "if({});", errors: [{ message: "Unexpected constant condition.", type: "ObjectExpression" }] },
+        { code: "if(0 < 1);", errors: [{ message: "Unexpected constant condition.", type: "BinaryExpression" }] },
+        { code: "if(0 || 1);", errors: [{ message: "Unexpected constant condition.", type: "LogicalExpression" }] },
+        { code: "if(a, 1);", errors: [{ message: "Unexpected constant condition.", type: "SequenceExpression" }] },
+
+        { code: "while([]);", errors: [{ message: "Unexpected constant condition.", type: "ArrayExpression" }] },
+        { code: "while(~!0);", errors: [{ message: "Unexpected constant condition.", type: "UnaryExpression" }] },
+        { code: "while(x = 1);", errors: [{ message: "Unexpected constant condition.", type: "AssignmentExpression" }] },
+        { code: "while(function(){});", errors: [{ message: "Unexpected constant condition.", type: "FunctionExpression" }] },
+        { code: "while(true);", errors: [{ message: "Unexpected constant condition.", type: "Literal" }] },
+        { code: "while(() => {});", errors: [{ message: "Unexpected constant condition.", type: "ArrowFunctionExpression" }] },
 
         // #5228 , typeof conditions
-        { code: "if(typeof x){}", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(typeof 'abc' === 'string'){}", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(a = typeof b){}", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(a, typeof b){}", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(typeof 'a' == 'string' || typeof 'b' == 'string'){}", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "while(typeof x){}", errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }] },
+        { code: "if(typeof x){}", errors: [{ message: "Unexpected constant condition.", type: "UnaryExpression" }] },
+        { code: "if(typeof 'abc' === 'string'){}", errors: [{ message: "Unexpected constant condition.", type: "BinaryExpression" }] },
+        { code: "if(a = typeof b){}", errors: [{ message: "Unexpected constant condition.", type: "AssignmentExpression" }] },
+        { code: "if(a, typeof b){}", errors: [{ message: "Unexpected constant condition.", type: "SequenceExpression" }] },
+        { code: "if(typeof 'a' == 'string' || typeof 'b' == 'string'){}", errors: [{ message: "Unexpected constant condition.", type: "LogicalExpression" }] },
+        { code: "while(typeof x){}", errors: [{ message: "Unexpected constant condition.", type: "UnaryExpression" }] },
 
         // #5726, void conditions
-        { code: "if(1 || void x);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(void x);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(y = void x);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(x, void x);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(void x === void y);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(void x && a);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(a && void x);", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
+        { code: "if(1 || void x);", errors: [{ message: "Unexpected constant condition.", type: "LogicalExpression" }] },
+        { code: "if(void x);", errors: [{ message: "Unexpected constant condition.", type: "UnaryExpression" }] },
+        { code: "if(y = void x);", errors: [{ message: "Unexpected constant condition.", type: "AssignmentExpression" }] },
+        { code: "if(x, void x);", errors: [{ message: "Unexpected constant condition.", type: "SequenceExpression" }] },
+        { code: "if(void x === void y);", errors: [{ message: "Unexpected constant condition.", type: "BinaryExpression" }] },
+        { code: "if(void x && a);", errors: [{ message: "Unexpected constant condition.", type: "LogicalExpression" }] },
+        { code: "if(a && void x);", errors: [{ message: "Unexpected constant condition.", type: "LogicalExpression" }] },
 
         // #5693
-        { code: "if(false && abc==='str'){}", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(true || abc==='str'){}", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(abc==='str' || true){}", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(abc==='str' || true || def ==='str'){}", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(false || true){}", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
-        { code: "if(typeof abc==='str' || true){}", errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }] },
+        { code: "if(false && abc==='str'){}", errors: [{ message: "Unexpected constant condition.", type: "LogicalExpression" }] },
+        { code: "if(true || abc==='str'){}", errors: [{ message: "Unexpected constant condition.", type: "LogicalExpression" }] },
+        { code: "if(abc==='str' || true){}", errors: [{ message: "Unexpected constant condition.", type: "LogicalExpression" }] },
+        { code: "if(abc==='str' || true || def ==='str'){}", errors: [{ message: "Unexpected constant condition.", type: "LogicalExpression" }] },
+        { code: "if(false || true){}", errors: [{ message: "Unexpected constant condition.", type: "LogicalExpression" }] },
+        { code: "if(typeof abc==='str' || true){}", errors: [{ message: "Unexpected constant condition.", type: "LogicalExpression" }] },
 
         {
             code: "function* foo(){while(true){} yield 'foo';}",
-            errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }]
+            errors: [{ message: "Unexpected constant condition.", type: "Literal" }]
         },
         {
             code: "function* foo(){while(true){if (true) {yield 'foo';}}}",
-            errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }]
+            errors: [{ message: "Unexpected constant condition.", type: "Literal" }]
         },
         {
             code: "function* foo(){while(true){yield 'foo';} while(true) {}}",
-            errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }]
+            errors: [{ message: "Unexpected constant condition.", type: "Literal" }]
         },
         {
             code: "var a = function* foo(){while(true){} yield 'foo';}",
-            errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }]
+            errors: [{ message: "Unexpected constant condition.", type: "Literal" }]
         },
         {
             code: "while (true) { function* foo() {yield;}}",
-            errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }]
+            errors: [{ message: "Unexpected constant condition.", type: "Literal" }]
         },
         {
             code: "function* foo(){if (true) {yield 'foo';}}",
-            errors: [{ message: "Unexpected constant condition.", type: "IfStatement" }]
+            errors: [{ message: "Unexpected constant condition.", type: "Literal" }]
         },
         {
             code: "function* foo() {for (let foo = yield; true;) {}}",
-            errors: [{ message: "Unexpected constant condition.", type: "ForStatement" }]
+            errors: [{ message: "Unexpected constant condition.", type: "Literal" }]
         },
         {
             code: "function* foo() {for (foo = yield; true;) {}}",
-            errors: [{ message: "Unexpected constant condition.", type: "ForStatement" }]
+            errors: [{ message: "Unexpected constant condition.", type: "Literal" }]
         },
         {
             code: "function foo() {while (true) {function* bar() {while (true) {yield;}}}}",
-            errors: [{ message: "Unexpected constant condition.", type: "WhileStatement" }]
+            errors: [{ message: "Unexpected constant condition.", type: "Literal" }]
         },
         {
             code: "function* foo() { for (let foo = 1 + 2 + 3 + (yield); true; baz) {}}",
-            errors: [{ message: "Unexpected constant condition.", type: "ForStatement" }]
+            errors: [{ message: "Unexpected constant condition.", type: "Literal" }]
         }
     ]
 });
diff --git a/tests/lib/rules/no-trailing-spaces.js b/tests/lib/rules/no-trailing-spaces.js
index d33af0c25..37c81f327 100644
--- a/tests/lib/rules/no-trailing-spaces.js
+++ b/tests/lib/rules/no-trailing-spaces.js
@@ -71,6 +71,14 @@ ruleTester.run("no-trailing-spaces", rule, {
             code: "// Trailing comment test. ",
             options: [{ ignoreComments: true }]
         },
+        {
+            code: "// Trailing comment test.",
+            options: [{ ignoreComments: false }]
+        },
+        {
+            code: "// Trailing comment test.",
+            options: []
+        },
         {
             code: "/* \nTrailing comments test. \n*/",
             options: [{ ignoreComments: true }]
@@ -484,6 +492,19 @@ ruleTester.run("no-trailing-spaces", rule, {
                     column: 20
                 }
             ]
+        },
+        {
+            code: "// Trailing comment default test. ",
+            output: "// Trailing comment default test.",
+            options: [],
+            errors: [
+                {
+                    message: "Trailing spaces not allowed.",
+                    type: "Program",
+                    line: 1,
+                    column: 34
+                }
+            ]
         }
     ]
 });