UNPKG

819 BJavaScriptView Raw
1const {docsUrl, polarisComponentFromJSX} = require('../utilities');
2
3module.exports = {
4 meta: {
5 docs: {
6 description:
7 'Disallow the use of Polaris’s `Stack.Item` without any custom props.',
8 category: 'Best Practices',
9 recommended: true,
10 uri: docsUrl('polaris-no-bare-stack-item'),
11 },
12 schema: [],
13 },
14
15 create(context) {
16 return {
17 JSXElement(node) {
18 const component = polarisComponentFromJSX(node, context);
19 if (
20 component === 'Stack.Item' &&
21 node.openingElement.attributes.length === 0
22 ) {
23 context.report({
24 node,
25 message:
26 'You don’t need to wrap content in a Stack.Item unless you need to customize one of its props.',
27 });
28 }
29 },
30 };
31 },
32};