1 |
|
2 |
|
3 |
|
4 |
|
5 | "use strict";
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | module.exports = {
|
12 | meta: {
|
13 | docs: {
|
14 | description: "disallow template literal placeholder syntax in regular strings",
|
15 | category: "Possible Errors",
|
16 | recommended: false,
|
17 | url: "https://eslint.org/docs/rules/no-template-curly-in-string"
|
18 | },
|
19 |
|
20 | schema: []
|
21 | },
|
22 |
|
23 | create(context) {
|
24 | const regex = /\$\{[^}]+\}/;
|
25 |
|
26 | return {
|
27 | Literal(node) {
|
28 | if (typeof node.value === "string" && regex.test(node.value)) {
|
29 | context.report({
|
30 | node,
|
31 | message: "Unexpected template string expression."
|
32 | });
|
33 | }
|
34 | }
|
35 | };
|
36 |
|
37 | }
|
38 | };
|