intial
This commit is contained in:
49
node_modules/eslint-plugin-svelte/lib/rules/no-object-in-text-mustaches.js
generated
vendored
Normal file
49
node_modules/eslint-plugin-svelte/lib/rules/no-object-in-text-mustaches.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import { createRule } from '../utils/index.js';
|
||||
const PHRASES = {
|
||||
ObjectExpression: 'object',
|
||||
ArrayExpression: 'array',
|
||||
ArrowFunctionExpression: 'function',
|
||||
FunctionExpression: 'function',
|
||||
ClassExpression: 'class'
|
||||
};
|
||||
export default createRule('no-object-in-text-mustaches', {
|
||||
meta: {
|
||||
docs: {
|
||||
description: 'disallow objects in text mustache interpolation',
|
||||
category: 'Possible Errors',
|
||||
recommended: true
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
unexpected: 'Unexpected {{phrase}} in text mustache interpolation.'
|
||||
},
|
||||
type: 'problem'
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
SvelteMustacheTag(node) {
|
||||
const { expression } = node;
|
||||
if (expression.type !== 'ObjectExpression' &&
|
||||
expression.type !== 'ArrayExpression' &&
|
||||
expression.type !== 'ArrowFunctionExpression' &&
|
||||
expression.type !== 'FunctionExpression' &&
|
||||
expression.type !== 'ClassExpression') {
|
||||
return;
|
||||
}
|
||||
if (node.parent.type === 'SvelteAttribute') {
|
||||
if (node.parent.value.length === 1) {
|
||||
// Maybe props
|
||||
return;
|
||||
}
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'unexpected',
|
||||
data: {
|
||||
phrase: PHRASES[expression.type]
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user