Urara-Blog/node_modules/.pnpm-store/v3/files/73/6157f5ee5493f60d98026b46d07be5189b262bf81b46d876b792d78f273d6dacc243b16c5e0aee37cfa1f846298e8e2b73126ef1e002a2111d69b01418ad56
2022-08-14 01:14:53 +08:00

44 lines
1.1 KiB
Text

/**
* @fileoverview Warn when using template string syntax in regular strings
* @author Jeroen Engels
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "problem",
docs: {
description: "Disallow template literal placeholder syntax in regular strings",
recommended: false,
url: "https://eslint.org/docs/rules/no-template-curly-in-string"
},
schema: [],
messages: {
unexpectedTemplateExpression: "Unexpected template string expression."
}
},
create(context) {
const regex = /\$\{[^}]+\}/u;
return {
Literal(node) {
if (typeof node.value === "string" && regex.test(node.value)) {
context.report({
node,
messageId: "unexpectedTemplateExpression"
});
}
}
};
}
};