summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js')
-rw-r--r--tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js b/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js
new file mode 100644
index 0000000000..d8f6c31108
--- /dev/null
+++ b/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js
@@ -0,0 +1,37 @@
+/**
+ * @fileoverview Warn when using template string syntax in regular strings
+ * @author Jeroen Engels
+ */
+"use strict";
+
+//------------------------------------------------------------------------------
+// Rule Definition
+//------------------------------------------------------------------------------
+
+module.exports = {
+ meta: {
+ docs: {
+ description: "disallow template literal placeholder syntax in regular strings",
+ category: "Possible Errors",
+ recommended: false
+ },
+
+ schema: []
+ },
+
+ create(context) {
+ const regex = /\$\{[^}]+\}/;
+
+ return {
+ Literal(node) {
+ if (typeof node.value === "string" && regex.test(node.value)) {
+ context.report({
+ node,
+ message: "Unexpected template string expression."
+ });
+ }
+ }
+ };
+
+ }
+};