printer-notifications/node_modules/eslint-plugin-svelte/lib/rules/require-each-key.js

28 lines
775 B
JavaScript
Raw Normal View History

2023-11-13 21:10:04 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../utils");
exports.default = (0, utils_1.createRule)('require-each-key', {
meta: {
docs: {
description: 'require keyed `{#each}` block',
category: 'Best Practices',
recommended: false
},
schema: [],
messages: { expectedKey: 'Each block should have a key' },
type: 'suggestion'
},
create(context) {
return {
SvelteEachBlock(node) {
if (node.key == null) {
context.report({
node,
messageId: 'expectedKey'
});
}
}
};
}
});