mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Lint for no unneeded backticks (#5057) (no-changelog)
* ✨ Create rule `no-unneeded-backticks` * 👕 Enable rule * ⚡ Run rule on `cli` * ⚡ Run rule on `core` * ⚡ Run rule on `workflow` * ⚡ Rule rule on `design-system` * ⚡ Run rule on `node-dev` * ⚡ Run rule on `editor-ui` * ⚡ Run rule on `nodes-base`
This commit is contained in:
@@ -106,6 +106,39 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
'no-unneeded-backticks': {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description:
|
||||
'Template literal backticks may only be used for string interpolation or multiline strings.',
|
||||
recommended: 'error',
|
||||
},
|
||||
messages: {
|
||||
noUneededBackticks: 'Use single or double quotes, not backticks',
|
||||
},
|
||||
fixable: 'code',
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
TemplateLiteral(node) {
|
||||
if (node.expressions.length > 0) return;
|
||||
if (node.quasis.every((q) => q.loc.start.line !== q.loc.end.line)) return;
|
||||
|
||||
node.quasis.forEach((q) => {
|
||||
const escaped = q.value.raw.replace(/(?<!\\)'/g, "\\'");
|
||||
|
||||
context.report({
|
||||
messageId: 'noUneededBackticks',
|
||||
node,
|
||||
fix: (fixer) => fixer.replaceText(q, `'${escaped}'`),
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const isJsonParseCall = (node) =>
|
||||
|
||||
Reference in New Issue
Block a user