mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Lint for no interpolation in regular string (#5060) (no-changelog)
* ✨ Create rule `no-interpolation-in-regular-string` * 👕 Enable rule * ⚡ Run rule (no issues) and add exception * ⚡ Simplify regex To account for expressions and to make it less expensive
This commit is contained in:
@@ -139,6 +139,36 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
'no-interpolation-in-regular-string': {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description:
|
||||
'String interpolation `${...}` requires backticks, not single or double quotes.',
|
||||
recommended: 'error',
|
||||
},
|
||||
messages: {
|
||||
useBackticks: 'Use backticks to interpolate',
|
||||
},
|
||||
fixable: 'code',
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
Literal(node) {
|
||||
if (typeof node.value !== 'string') return;
|
||||
|
||||
if (/\$\{/.test(node.value)) {
|
||||
context.report({
|
||||
messageId: 'useBackticks',
|
||||
node,
|
||||
fix: (fixer) => fixer.replaceText(node, `\`${node.value}\``),
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const isJsonParseCall = (node) =>
|
||||
|
||||
Reference in New Issue
Block a user