Repository: eslint/eslint
Pull request #9394 (2017-10-05 16:05:10)

Docs: add installing prerequisites.
<!--
    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] Documentation update

**What changes did you make? (Give an overview)**


**Is there anything you'd like reviewers to focus on?**




eslintbot: LGTM

Patch:
diff --git a/docs/rules/class-methods-use-this.md b/docs/rules/class-methods-use-this.md
index d24925fbd..89f6762b2 100644
--- a/docs/rules/class-methods-use-this.md
+++ b/docs/rules/class-methods-use-this.md
@@ -1,6 +1,6 @@
 # Enforce that class methods utilize `this` (class-methods-use-this)
 
-If a class method does not use `this`, it can safely be made a static function.
+If a class method does not use `this`, it can *sometimes* be made into a static function. If you do convert the method into a static function, instances of the class that call that particular method have to be converted to a static call as well (`MyClass.callStaticMethod()`)
 
 It's possible to have a class method which doesn't use `this`, such as:
 
@@ -43,7 +43,7 @@ class A {
 A.sayHi(); // => "hi"
 ```
 
-Also note in the above examples that the code calling the function on an *instance* of the class (`let a = new A(); a.sayHi();`) changes to calling it on the *class* itself (`A.sayHi();`).
+Also note in the above examples that if you switch a method to a static method, *instances* of the class that call the static method (`let a = new A(); a.sayHi();`) have to be updated to being a static call (`A.sayHi();`) instead of having the instance of the *class* call the method
 
 ## Rule Details
 
@@ -94,7 +94,7 @@ class A {
 "class-methods-use-this": [<enabled>, { "exceptMethods": [<...exceptions>] }]
 ```
 
-The `exceptMethods` option allows you to pass an array of method names for which you would like to ignore warnings.
+The `exceptMethods` option allows you to pass an array of method names for which you would like to ignore warnings. For example, you might have a spec from an external library that requires you to overwrite a method as a regular function (and not as a static method) and does not use `this` inside the function body. In this case, you can add that method to ignore in the warnings.
 
 Examples of **incorrect** code for this rule when used without exceptMethods:
 
@@ -117,3 +117,8 @@ class A {
     }
 }
 ```
+
+## Further Reading
+
+* [Classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes)
+* [Static Methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static)
diff --git a/docs/rules/no-console.md b/docs/rules/no-console.md
index ab58cb846..1c36a85f9 100644
--- a/docs/rules/no-console.md
+++ b/docs/rules/no-console.md
@@ -49,6 +49,46 @@ console.error("Log an error level message.");
 
 If you're using Node.js, however, `console` is used to output information to the user and so is not strictly used for debugging purposes. If you are developing for Node.js then you most likely do not want this rule enabled.
 
+Another case where you might not use this rule is if you want to enforce console calls and not console overwrites. For example:
+
+```js
+/*eslint no-console: ["error", { allow: ["warn"] }] */
+console.error = function (message) {
+  throw new Error(message);
+};
+```
+
+With the `no-console` rule in the above example, ESLint will report an error. For the above example, you can disable the rule:
+
+```js
+// eslint-disable-next-line no-console
+console.error = function (message) {
+  throw new Error(message);
+};
+
+// or
+
+console.error = function (message) {  // eslint-disable-line no-console
+  throw new Error(message);
+};
+```
+
+However, you might not want to manually add `eslint-disable-next-line` or `eslint-disable-line`. You can achieve the effect of only receiving errors for console calls with the `no-restricted-syntax` rule:
+
+```json
+{
+    "rules": {
+        "no-restricted-syntax": [
+            "error",
+            {
+                "selector": "CallExpression[callee.object.name='console'][callee.property.name=/^(log|warn|error|info|trace)$/]",
+                "message": "Unexpected property on console object was called"
+            }
+        ]
+    }
+}
+```
+
 ## Related Rules
 
 * [no-alert](no-alert.md)
diff --git a/docs/user-guide/getting-started.md b/docs/user-guide/getting-started.md
index 52513bb84..8286468ba 100644
--- a/docs/user-guide/getting-started.md
+++ b/docs/user-guide/getting-started.md
@@ -13,6 +13,8 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J
 
 ## Installation and Usage
 
+Prerequisites: [Node.js](https://nodejs.org/en/) (>=4.x), npm version 2+.
+
 There are two ways to install ESLint: globally and locally.
 
 ### Local Installation and Usage
diff --git a/lib/ignored-paths.js b/lib/ignored-paths.js
index 3b7a00e9c..f43ce4642 100644
--- a/lib/ignored-paths.js
+++ b/lib/ignored-paths.js
@@ -184,7 +184,7 @@ class IgnoredPaths {
                                     addPattern(this.ig.default, pattern);
                                 });
                             } else {
-                                throw new Error("Package.json eslintIgnore property requires an array of paths");
+                                throw new TypeError("Package.json eslintIgnore property requires an array of paths");
                             }
                         }
                     }
diff --git a/lib/rules/array-bracket-newline.js b/lib/rules/array-bracket-newline.js
index 319ac60f2..adfce985f 100644
--- a/lib/rules/array-bracket-newline.js
+++ b/lib/rules/array-bracket-newline.js
@@ -194,6 +194,12 @@ module.exports = {
                     options.multiline &&
                     elements.length > 0 &&
                     firstIncComment.loc.start.line !== lastIncComment.loc.end.line
+                ) ||
+                (
+                    elements.length === 0 &&
+                    firstIncComment.type === "Block" &&
+                    firstIncComment.loc.start.line !== lastIncComment.loc.end.line &&
+                    firstIncComment === lastIncComment
                 )
             );
 
diff --git a/lib/util/node-event-generator.js b/lib/util/node-event-generator.js
index 05b343ae9..34ee78b49 100644
--- a/lib/util/node-event-generator.js
+++ b/lib/util/node-event-generator.js
@@ -160,7 +160,7 @@ function tryParseSelector(rawSelector) {
         return esquery.parse(rawSelector.replace(/:exit$/, ""));
     } catch (err) {
         if (typeof err.offset === "number") {
-            throw new Error(`Syntax error in selector "${rawSelector}" at position ${err.offset}: ${err.message}`);
+            throw new SyntaxError(`Syntax error in selector "${rawSelector}" at position ${err.offset}: ${err.message}`);
         }
         throw err;
     }


Test patch:
diff --git a/lib/testers/rule-tester.js b/lib/testers/rule-tester.js
index d7e14878c..5ba18d70c 100644
--- a/lib/testers/rule-tester.js
+++ b/lib/testers/rule-tester.js
@@ -178,7 +178,7 @@ class RuleTester {
      */
     static setDefaultConfig(config) {
         if (typeof config !== "object") {
-            throw new Error("RuleTester.setDefaultConfig: config must be an object");
+            throw new TypeError("RuleTester.setDefaultConfig: config must be an object");
         }
         defaultConfig = config;
 
@@ -254,7 +254,7 @@ class RuleTester {
             linter = this.linter;
 
         if (lodash.isNil(test) || typeof test !== "object") {
-            throw new Error(`Test Scenarios for rule ${ruleName} : Could not find test scenario object`);
+            throw new TypeError(`Test Scenarios for rule ${ruleName} : Could not find test scenario object`);
         }
 
         requiredScenarios.forEach(scenarioType => {
diff --git a/tests/lib/rules/array-bracket-newline.js b/tests/lib/rules/array-bracket-newline.js
index d4e76dfc6..cf02cbdf6 100644
--- a/tests/lib/rules/array-bracket-newline.js
+++ b/tests/lib/rules/array-bracket-newline.js
@@ -40,6 +40,8 @@ ruleTester.run("array-bracket-newline", rule, {
         "var foo = [\n1, 2\n// any comment\n];",
         "var foo = [\n1,\n2\n];",
         "var foo = [\nfunction foo() {\nreturn dosomething();\n}\n];",
+        "var foo = [/* \nany comment\n */];",
+        "var foo = [/* single line multiline comment for no real reason */];",
 
         // "always"
         { code: "var foo = [\n];", options: ["always"] },
@@ -72,6 +74,7 @@ ruleTester.run("array-bracket-newline", rule, {
         { code: "var foo = [\n1, 2\n// any comment\n];", options: [{ multiline: true }] },
         { code: "var foo = [\n1,\n2\n];", options: [{ multiline: true }] },
         { code: "var foo = [\nfunction foo() {\nreturn dosomething();\n}\n];", options: [{ multiline: true }] },
+        { code: "var foo = [/* \nany comment\n */];", options: [{ multiline: true }] },
 
         // { multiline: false }
         { code: "var foo = [];", options: [{ multiline: false }] },