massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / eslint / lib / rules / object-curly-newline.js
index e870a69a954180dbfc3b5c761d0e76780bb9d662..1fbea00c5d7e403db78c1f25b1c43dc93ec3052f 100644 (file)
@@ -10,7 +10,6 @@
 //------------------------------------------------------------------------------
 
 const astUtils = require("./utils/ast-utils");
-const lodash = require("lodash");
 
 //------------------------------------------------------------------------------
 // Helpers
@@ -69,6 +68,24 @@ function normalizeOptionValue(value) {
     return { multiline, minProperties, consistent };
 }
 
+/**
+ * Checks if a value is an object.
+ * @param {any} value The value to check
+ * @returns {boolean} `true` if the value is an object, otherwise `false`
+ */
+function isObject(value) {
+    return typeof value === "object" && value !== null;
+}
+
+/**
+ * Checks if an option is a node-specific option
+ * @param {any} option The option to check
+ * @returns {boolean} `true` if the option is node-specific, otherwise `false`
+ */
+function isNodeSpecificOption(option) {
+    return isObject(option) || typeof option === "string";
+}
+
 /**
  * Normalizes a given option value.
  * @param {string|Object|undefined} options An option value to parse.
@@ -80,9 +97,7 @@ function normalizeOptionValue(value) {
  * }} Normalized option object.
  */
 function normalizeOptions(options) {
-    const isNodeSpecificOption = lodash.overSome([lodash.isPlainObject, lodash.isString]);
-
-    if (lodash.isPlainObject(options) && lodash.some(options, isNodeSpecificOption)) {
+    if (isObject(options) && Object.values(options).some(isNodeSpecificOption)) {
         return {
             ObjectExpression: normalizeOptionValue(options.ObjectExpression),
             ObjectPattern: normalizeOptionValue(options.ObjectPattern),
@@ -134,7 +149,7 @@ module.exports = {
         type: "layout",
 
         docs: {
-            description: "enforce consistent line breaks inside braces",
+            description: "enforce consistent line breaks after opening and before closing braces",
             category: "Stylistic Issues",
             recommended: false,
             url: "https://eslint.org/docs/rules/object-curly-newline"
@@ -159,7 +174,14 @@ module.exports = {
                     }
                 ]
             }
-        ]
+        ],
+
+        messages: {
+            unexpectedLinebreakBeforeClosingBrace: "Unexpected line break before this closing brace.",
+            unexpectedLinebreakAfterOpeningBrace: "Unexpected line break after this opening brace.",
+            expectedLinebreakBeforeClosingBrace: "Expected a line break before this closing brace.",
+            expectedLinebreakAfterOpeningBrace: "Expected a line break after this opening brace."
+        }
     },
 
     create(context) {
@@ -215,9 +237,9 @@ module.exports = {
             if (needsLineBreaks) {
                 if (astUtils.isTokenOnSameLine(openBrace, first)) {
                     context.report({
-                        message: "Expected a line break after this opening brace.",
+                        messageId: "expectedLinebreakAfterOpeningBrace",
                         node,
-                        loc: openBrace.loc.start,
+                        loc: openBrace.loc,
                         fix(fixer) {
                             if (hasCommentsFirstToken) {
                                 return null;
@@ -229,9 +251,9 @@ module.exports = {
                 }
                 if (astUtils.isTokenOnSameLine(last, closeBrace)) {
                     context.report({
-                        message: "Expected a line break before this closing brace.",
+                        messageId: "expectedLinebreakBeforeClosingBrace",
                         node,
-                        loc: closeBrace.loc.start,
+                        loc: closeBrace.loc,
                         fix(fixer) {
                             if (hasCommentsLastToken) {
                                 return null;
@@ -251,9 +273,9 @@ module.exports = {
                     (consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast)
                 ) {
                     context.report({
-                        message: "Unexpected line break after this opening brace.",
+                        messageId: "unexpectedLinebreakAfterOpeningBrace",
                         node,
-                        loc: openBrace.loc.start,
+                        loc: openBrace.loc,
                         fix(fixer) {
                             if (hasCommentsFirstToken) {
                                 return null;
@@ -271,9 +293,9 @@ module.exports = {
                     (consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast)
                 ) {
                     context.report({
-                        message: "Unexpected line break before this closing brace.",
+                        messageId: "unexpectedLinebreakBeforeClosingBrace",
                         node,
-                        loc: closeBrace.loc.start,
+                        loc: closeBrace.loc,
                         fix(fixer) {
                             if (hasCommentsLastToken) {
                                 return null;