feat: 前端集成 Prettier 代码格式化
This commit is contained in:
@@ -10,4 +10,4 @@ const plugin = {
|
||||
},
|
||||
}
|
||||
|
||||
export default plugin
|
||||
export default plugin
|
||||
|
||||
@@ -42,10 +42,7 @@ function isHardcodedColor(value) {
|
||||
function extractStyleProperties(expression) {
|
||||
const properties = []
|
||||
|
||||
if (
|
||||
expression.type === 'ObjectExpression' &&
|
||||
expression.properties
|
||||
) {
|
||||
if (expression.type === 'ObjectExpression' && expression.properties) {
|
||||
for (const styleProp of expression.properties) {
|
||||
if (
|
||||
styleProp.type === 'Property' &&
|
||||
@@ -92,9 +89,7 @@ export default ESLintUtils.RuleCreator((name) => {
|
||||
node.value?.type === 'JSXExpressionContainer' &&
|
||||
node.value.expression
|
||||
) {
|
||||
const styleProps = extractStyleProperties(
|
||||
node.value.expression,
|
||||
)
|
||||
const styleProps = extractStyleProperties(node.value.expression)
|
||||
|
||||
for (const prop of styleProps) {
|
||||
if (isHardcodedColor(prop.value)) {
|
||||
@@ -109,4 +104,4 @@ export default ESLintUtils.RuleCreator((name) => {
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user