diff options
Diffstat (limited to 'tools/node_modules/eslint/lib/rules/object-shorthand.js')
-rw-r--r-- | tools/node_modules/eslint/lib/rules/object-shorthand.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/lib/rules/object-shorthand.js b/tools/node_modules/eslint/lib/rules/object-shorthand.js index 8cd3978ca35..b755aea3f48 100644 --- a/tools/node_modules/eslint/lib/rules/object-shorthand.js +++ b/tools/node_modules/eslint/lib/rules/object-shorthand.js @@ -78,6 +78,9 @@ module.exports = { ignoreConstructors: { type: "boolean" }, + methodsIgnorePattern: { + type: "string" + }, avoidQuotes: { type: "boolean" }, @@ -115,6 +118,9 @@ module.exports = { const PARAMS = context.options[1] || {}; const IGNORE_CONSTRUCTORS = PARAMS.ignoreConstructors; + const METHODS_IGNORE_PATTERN = PARAMS.methodsIgnorePattern + ? new RegExp(PARAMS.methodsIgnorePattern, "u") + : null; const AVOID_QUOTES = PARAMS.avoidQuotes; const AVOID_EXPLICIT_RETURN_ARROWS = !!PARAMS.avoidExplicitReturnArrows; const sourceCode = context.getSourceCode(); @@ -457,6 +463,15 @@ module.exports = { if (IGNORE_CONSTRUCTORS && node.key.type === "Identifier" && isConstructor(node.key.name)) { return; } + + if (METHODS_IGNORE_PATTERN) { + const propertyName = astUtils.getStaticPropertyName(node); + + if (propertyName !== null && METHODS_IGNORE_PATTERN.test(propertyName)) { + return; + } + } + if (AVOID_QUOTES && isStringLiteral(node.key)) { return; } |