|
1 | | -import { isPandaAttribute, isPandaIsh, isPandaProp, resolveLonghand } from '../utils/helpers' |
| 1 | +import { isPandaAttribute, isPandaProp, resolveLonghand } from '../utils/helpers' |
2 | 2 | import { type Rule, createRule } from '../utils' |
3 | | -import { isCallExpression, isIdentifier, isJSXIdentifier, isMemberExpression } from '../utils/nodes' |
| 3 | +import { isIdentifier, isJSXIdentifier } from '../utils/nodes' |
4 | 4 | import type { TSESTree } from '@typescript-eslint/utils' |
5 | 5 |
|
6 | 6 | export const RULE_NAME = 'no-margin-properties' |
@@ -46,61 +46,6 @@ const rule: Rule = createRule({ |
46 | 46 |
|
47 | 47 | sendReport(node.key) |
48 | 48 | }, |
49 | | - |
50 | | - TaggedTemplateExpression(node) { |
51 | | - const handleExpression = (caller: string) => { |
52 | | - if (!isPandaIsh(caller, context)) return |
53 | | - |
54 | | - const quasis = node.quasi.quasis[0] |
55 | | - const styles = quasis.value.raw |
56 | | - |
57 | | - const propertyRegex = /([a-zA-Z-]+):/g |
58 | | - const propertyMatches = [...styles.matchAll(propertyRegex)] |
59 | | - const properties = propertyMatches.map((match) => match[1].trim()) |
60 | | - |
61 | | - properties.forEach((property, i, arr) => { |
62 | | - if (!property.includes('margin')) return |
63 | | - |
64 | | - // Avoid duplicate reports on the same token |
65 | | - if (arr.indexOf(property) < i) return |
66 | | - |
67 | | - let index = styles.indexOf(property) |
68 | | - |
69 | | - while (index !== -1) { |
70 | | - const start = quasis.range[0] + 1 + index |
71 | | - const end = start + property.length |
72 | | - |
73 | | - context.report({ |
74 | | - loc: { |
75 | | - start: context.sourceCode.getLocFromIndex(start), |
76 | | - end: context.sourceCode.getLocFromIndex(end), |
77 | | - }, |
78 | | - messageId: 'noMargin', |
79 | | - }) |
80 | | - |
81 | | - // Check for other occurences of the invalid token |
82 | | - index = styles.indexOf(property, index + 1) |
83 | | - } |
84 | | - }) |
85 | | - } |
86 | | - |
87 | | - // css`` |
88 | | - if (isIdentifier(node.tag)) { |
89 | | - handleExpression(node.tag.name) |
90 | | - } |
91 | | - |
92 | | - // styled.h1`` |
93 | | - if (isMemberExpression(node.tag)) { |
94 | | - if (!isIdentifier(node.tag.object)) return |
95 | | - handleExpression(node.tag.object.name) |
96 | | - } |
97 | | - |
98 | | - // styled(Comp)`` |
99 | | - if (isCallExpression(node.tag)) { |
100 | | - if (!isIdentifier(node.tag.callee)) return |
101 | | - handleExpression(node.tag.callee.name) |
102 | | - } |
103 | | - }, |
104 | 49 | } |
105 | 50 | }, |
106 | 51 | }) |
|
0 commit comments