Repository: eslint/eslint (js)

Issue:
object-curly-newline minProperties documentation clarification
**Tell us about your environment**

* **ESLint Version:** 4.1.1
* **Node Version:** 8.0.0
* **npm Version:** 5.0.4

**What parser (default, Babel-ESLint, etc.) are you using?** default

The documentation for `object-curly-newline`'s `minProperties` option states

```
"minProperties" requires line breaks if the number of properties is more than the given integer.
```

In practice I have found that it requires line breaks when the number of properties is not simply `more than` the given integer but *greater than or equal to* the given integer.

Here is an example:

```JavaScript
/* eslint object-curly-newline: [2, {minProperties: 1}] */
let obj = {a: 1};
```

This triggers errors:
* ESLint Error object-curly-newline Expected a line break after this opening brace.
* ESLint Error object-curly-newline Expected a line break before this closing brace.

This object has one property and `minProperties` is set to one.  One is not "more than" one.  So I believe the documentation is incorrect.

Pull request:
Docs: Fix wording of minProperties in object-curly-newline (fixes #8874)
Fixes #8874
Wording "at least" copied from array-bracket-newline docs.

<!--
    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
[ ] Bug fix ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/bug-report.md))
[ ] New rule ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/rule-proposal.md))
[ ] Changes an existing rule ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/rule-change-proposal.md))
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

<!--
    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 (http://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)**
Documentation wording change to object-curly-newline.

**Is there anything you'd like reviewers to focus on?**
The one line of documentation that was changed.



Patch:
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 8675e4491..16822fd97 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -20,14 +20,18 @@
 
 **Please show your full configuration:**
 
-<!-- Paste your configuration below: -->
-```
+<details>
+<summary>Configuration</summary>
 
+<!-- Paste your configuration below: -->
+```js
 
 
 
 ```
 
+</details>
+
 **What did you do? Please include the actual source code causing the issue.**
 
 <!-- Paste the source code below: -->
diff --git a/docs/rules/object-curly-newline.md b/docs/rules/object-curly-newline.md
index 40f5368e5..a4907046f 100644
--- a/docs/rules/object-curly-newline.md
+++ b/docs/rules/object-curly-newline.md
@@ -16,7 +16,7 @@ This rule has either a string option:
 Or an object option:
 
 * `"multiline": true` (default) requires line breaks if there are line breaks inside properties or between properties
-* `"minProperties"` requires line breaks if the number of properties is more than the given integer. By default, an error will also be reported if an object contains linebreaks and has fewer properties than the given integer. However, the second behavior is disabled if the `consistent` option is set to `true`
+* `"minProperties"` requires line breaks if the number of properties is at least the given integer. By default, an error will also be reported if an object contains linebreaks and has fewer properties than the given integer. However, the second behavior is disabled if the `consistent` option is set to `true`
 * `"consistent": true` requires that either both curly braces, or neither, directly enclose newlines. Note that enabling this option will also change the behavior of the `minProperties` option. (See `minProperties` above for more information)
 
 You can specify different options for object literals and destructuring assignments:
diff --git a/lib/cli.js b/lib/cli.js
index 530bfbc42..d39847718 100644
--- a/lib/cli.js
+++ b/lib/cli.js
@@ -28,6 +28,17 @@ const debug = require("debug")("eslint:cli");
 // Helpers
 //------------------------------------------------------------------------------
 
+/**
+ * Predicate function for whether or not to apply fixes in quiet mode.
+ * If a message is a warning, do not apply a fix.
+ * @param {LintResult} lintResult The lint result.
+ * @returns {boolean} True if the lint message is an error (and thus should be
+ * autofixed), false otherwise.
+ */
+function quietFixPredicate(lintResult) {
+    return lintResult.severity === 2;
+}
+
 /**
  * Translates the CLI options into the options expected by the CLIEngine.
  * @param {Object} cliOptions The CLI options to translate.
@@ -52,7 +63,7 @@ function translateOptions(cliOptions) {
         cache: cliOptions.cache,
         cacheFile: cliOptions.cacheFile,
         cacheLocation: cliOptions.cacheLocation,
-        fix: cliOptions.fix,
+        fix: cliOptions.fix && (cliOptions.quiet ? quietFixPredicate : true),
         allowInlineConfig: cliOptions.inlineConfig
     };
 }


Test patch:
diff --git a/tests/bin/eslint.js b/tests/bin/eslint.js
index c7e97a00c..7c5cd6552 100644
--- a/tests/bin/eslint.js
+++ b/tests/bin/eslint.js
@@ -112,6 +112,7 @@ describe("bin/eslint.js", () => {
         const tempFilePath = `${fixturesPath}/temp.js`;
         const startingText = fs.readFileSync(`${fixturesPath}/left-pad.js`).toString();
         const expectedFixedText = fs.readFileSync(`${fixturesPath}/left-pad-expected.js`).toString();
+        const expectedFixedTextQuiet = fs.readFileSync(`${fixturesPath}/left-pad-expected-quiet.js`).toString();
 
         beforeEach(() => {
             fs.writeFileSync(tempFilePath, startingText);
@@ -127,6 +128,17 @@ describe("bin/eslint.js", () => {
             return Promise.all([exitCodeAssertion, outputFileAssertion]);
         });
 
+        it("has exit code 0, fixes errors in a file, and does not report or fix warnings if --quiet and --fix are used", () => {
+            const child = runESLint(["--fix", "--quiet", "--no-eslintrc", "--no-ignore", tempFilePath]);
+            const exitCodeAssertion = assertExitCode(child, 0);
+            const stdoutAssertion = getStdout(child).then(stdout => assert.strictEqual(stdout, ""));
+            const outputFileAssertion = awaitExit(child).then(() => {
+                assert.strictEqual(fs.readFileSync(tempFilePath).toString(), expectedFixedTextQuiet);
+            });
+
+            return Promise.all([exitCodeAssertion, stdoutAssertion, outputFileAssertion]);
+        });
+
         it("has exit code 1 and fixes a file if not all rules can be fixed", () => {
             const child = runESLint(["--fix", "--no-eslintrc", "--no-ignore", "--rule", "max-len: [2, 10]", tempFilePath]);
             const exitCodeAssertion = assertExitCode(child, 1);
diff --git a/tests/fixtures/autofix-integration/left-pad-expected-quiet.js b/tests/fixtures/autofix-integration/left-pad-expected-quiet.js
new file mode 100644
index 000000000..b189698bf
--- /dev/null
+++ b/tests/fixtures/autofix-integration/left-pad-expected-quiet.js
@@ -0,0 +1,33 @@
+/* eslint dot-notation: 2 */
+/* eslint indent: [2, 2] */
+/* eslint no-extra-parens: 2 */
+/* eslint no-implicit-coercion: 2 */
+/* eslint no-whitespace-before-property: 2 */
+/* eslint quotes: [2, "single"] */
+/* eslint semi: 2 */
+/* eslint semi-spacing: 2 */
+/* eslint space-before-function-paren: 2 */
+/* eslint space-before-blocks: 1 */
+
+/*
+* left-pad@0.0.3
+* WTFPL https://github.com/stevemao/left-pad/blob/aff6d744155a70b81f09effb8185a1564f348462/COPYING
+*/
+
+module.exports = leftpad;
+
+function leftpad (str, len, ch){
+  str = String(str);
+
+  var i = -1;
+
+  ch || (ch = ' ');
+  len = len - str.length;
+
+
+  while (++i < len) {
+    str = ch + str;
+  }
+
+  return str;
+}
diff --git a/tests/fixtures/autofix-integration/left-pad-expected.js b/tests/fixtures/autofix-integration/left-pad-expected.js
index 9e2a8321d..24da3ce17 100644
--- a/tests/fixtures/autofix-integration/left-pad-expected.js
+++ b/tests/fixtures/autofix-integration/left-pad-expected.js
@@ -7,6 +7,7 @@
 /* eslint semi: 2 */
 /* eslint semi-spacing: 2 */
 /* eslint space-before-function-paren: 2 */
+/* eslint space-before-blocks: 1 */
 
 /*
 * left-pad@0.0.3
diff --git a/tests/fixtures/autofix-integration/left-pad.js b/tests/fixtures/autofix-integration/left-pad.js
index 1dd798ff8..7b673577e 100644
--- a/tests/fixtures/autofix-integration/left-pad.js
+++ b/tests/fixtures/autofix-integration/left-pad.js
@@ -7,6 +7,7 @@
 /* eslint semi: 2 */
 /* eslint semi-spacing: 2 */
 /* eslint space-before-function-paren: 2 */
+/* eslint space-before-blocks: 1 */
 
 /*
 * left-pad@0.0.3
@@ -15,7 +16,7 @@
 
 module.exports = (leftpad)
 
-   function leftpad(str, len, ch) {
+   function leftpad(str, len, ch){
   str = ("" + str);
 
          var i = -1 ;
diff --git a/tests/lib/cli.js b/tests/lib/cli.js
index a0bcb37cf..b75640d4a 100644
--- a/tests/lib/cli.js
+++ b/tests/lib/cli.js
@@ -804,7 +804,7 @@ describe("cli", () => {
 
         });
 
-        it("should rewrite files when in fix mode and quiet mode", () => {
+        it("should provide fix predicate and rewrite files when in fix mode and quiet mode", () => {
 
             const report = {
                 errorCount: 0,
@@ -822,7 +822,7 @@ describe("cli", () => {
             };
 
             // create a fake CLIEngine to test with
-            const fakeCLIEngine = sandbox.mock().withExactArgs(sinon.match({ fix: true }));
+            const fakeCLIEngine = sandbox.mock().withExactArgs(sinon.match({ fix: sinon.match.func }));
 
             fakeCLIEngine.prototype = leche.fake(CLIEngine.prototype);
             sandbox.stub(fakeCLIEngine.prototype, "executeOnFiles").returns(report);