printer-notifications/node_modules/eslint-plugin-svelte/lib/rules/require-each-key.js
2023-11-13 16:10:04 -05:00

28 lines
775 B
JavaScript

"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'
});
}
}
};
}
});