source: imaps-frontend/node_modules/eslint/lib/rules/no-template-curly-in-string.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @fileoverview Warn when using template string syntax in regular strings
3 * @author Jeroen Engels
4 */
5"use strict";
6
7//------------------------------------------------------------------------------
8// Rule Definition
9//------------------------------------------------------------------------------
10
11/** @type {import('../shared/types').Rule} */
12module.exports = {
13 meta: {
14 type: "problem",
15
16 docs: {
17 description: "Disallow template literal placeholder syntax in regular strings",
18 recommended: false,
19 url: "https://eslint.org/docs/latest/rules/no-template-curly-in-string"
20 },
21
22 schema: [],
23
24 messages: {
25 unexpectedTemplateExpression: "Unexpected template string expression."
26 }
27 },
28
29 create(context) {
30 const regex = /\$\{[^}]+\}/u;
31
32 return {
33 Literal(node) {
34 if (typeof node.value === "string" && regex.test(node.value)) {
35 context.report({
36 node,
37 messageId: "unexpectedTemplateExpression"
38 });
39 }
40 }
41 };
42
43 }
44};
Note: See TracBrowser for help on using the repository browser.