@blumintinc/eslint-plugin-blumint 1.12.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js
CHANGED
|
@@ -106,7 +106,7 @@ const enforce_boolean_naming_prefixes_1 = require("./rules/enforce-boolean-namin
|
|
|
106
106
|
module.exports = {
|
|
107
107
|
meta: {
|
|
108
108
|
name: '@blumintinc/eslint-plugin-blumint',
|
|
109
|
-
version: '1.12.
|
|
109
|
+
version: '1.12.1',
|
|
110
110
|
},
|
|
111
111
|
parseOptions: {
|
|
112
112
|
ecmaVersion: 2020,
|
|
@@ -121,9 +121,45 @@ exports.enforceBooleanNamingPrefixes = (0, createRule_1.createRule)({
|
|
|
121
121
|
}
|
|
122
122
|
// Check for logical expressions (&&, ||)
|
|
123
123
|
if (node.init.type === utils_1.AST_NODE_TYPES.LogicalExpression &&
|
|
124
|
-
|
|
124
|
+
node.init.operator === '&&') {
|
|
125
125
|
return true;
|
|
126
126
|
}
|
|
127
|
+
// Special case for logical OR (||) - only consider it boolean if:
|
|
128
|
+
// 1. It's used with boolean literals or
|
|
129
|
+
// 2. It's not used with array/object literals as fallbacks
|
|
130
|
+
if (node.init.type === utils_1.AST_NODE_TYPES.LogicalExpression &&
|
|
131
|
+
node.init.operator === '||') {
|
|
132
|
+
// Check if right side is a non-boolean literal (array, object, string, number)
|
|
133
|
+
const rightSide = node.init.right;
|
|
134
|
+
if (rightSide.type === utils_1.AST_NODE_TYPES.ArrayExpression ||
|
|
135
|
+
rightSide.type === utils_1.AST_NODE_TYPES.ObjectExpression ||
|
|
136
|
+
(rightSide.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
137
|
+
typeof rightSide.value !== 'boolean')) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
// If right side is a boolean literal, it's likely a boolean variable
|
|
141
|
+
if (rightSide.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
142
|
+
typeof rightSide.value === 'boolean') {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
// For other cases, we need to be more careful
|
|
146
|
+
// If we can determine the left side is a boolean, then it's a boolean variable
|
|
147
|
+
const leftSide = node.init.left;
|
|
148
|
+
if ((leftSide.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
149
|
+
typeof leftSide.value === 'boolean') ||
|
|
150
|
+
(leftSide.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
|
|
151
|
+
leftSide.operator === '!')) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
// For function calls, check if the function name suggests it returns a boolean
|
|
155
|
+
if (leftSide.type === utils_1.AST_NODE_TYPES.CallExpression &&
|
|
156
|
+
leftSide.callee.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
157
|
+
const calleeName = leftSide.callee.name;
|
|
158
|
+
return approvedPrefixes.some((prefix) => calleeName.toLowerCase().startsWith(prefix.toLowerCase()));
|
|
159
|
+
}
|
|
160
|
+
// Default to false for other cases with || to avoid false positives
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
127
163
|
// Check for unary expressions with ! operator
|
|
128
164
|
if (node.init.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
|
|
129
165
|
node.init.operator === '!') {
|
|
@@ -37,7 +37,7 @@ exports.noCompositingLayerProps = (0, createRule_1.createRule)({
|
|
|
37
37
|
meta: {
|
|
38
38
|
type: 'suggestion',
|
|
39
39
|
docs: {
|
|
40
|
-
description: 'Warn when using CSS properties that trigger compositing layers, which can impact performance. Properties like transform, opacity, filter, and will-change create new GPU layers. While sometimes beneficial for animations, excessive layer creation can increase memory usage and hurt performance. Consider alternatives or explicitly document intentional layer promotion.',
|
|
40
|
+
description: 'Warn when using CSS properties that trigger compositing layers, which can impact performance. Properties like transform, opacity, filter, and will-change create new GPU layers. While sometimes beneficial for animations, excessive layer creation can increase memory usage and hurt performance. This rule checks both regular style objects and MUI sx props. Consider alternatives or explicitly document intentional layer promotion.',
|
|
41
41
|
recommended: 'error',
|
|
42
42
|
},
|
|
43
43
|
schema: [],
|
|
@@ -79,7 +79,7 @@ exports.noCompositingLayerProps = (0, createRule_1.createRule)({
|
|
|
79
79
|
// Check for JSX style attribute
|
|
80
80
|
if (current.parent.type === utils_1.AST_NODE_TYPES.JSXAttribute &&
|
|
81
81
|
current.parent.name.type === utils_1.AST_NODE_TYPES.JSXIdentifier &&
|
|
82
|
-
current.parent.name.name === 'style') {
|
|
82
|
+
(current.parent.name.name === 'style' || current.parent.name.name === 'sx')) {
|
|
83
83
|
return true;
|
|
84
84
|
}
|
|
85
85
|
// Check for style-related variable names or properties
|
|
@@ -91,7 +91,7 @@ exports.noCompositingLayerProps = (0, createRule_1.createRule)({
|
|
|
91
91
|
// Check for style-related object property assignments
|
|
92
92
|
if (current.parent.type === utils_1.AST_NODE_TYPES.Property &&
|
|
93
93
|
current.parent.key.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
94
|
-
/style/i.test(current.parent.key.name)) {
|
|
94
|
+
(/style/i.test(current.parent.key.name) || current.parent.key.name === 'sx')) {
|
|
95
95
|
return true;
|
|
96
96
|
}
|
|
97
97
|
// Skip if we're in a TypeScript type definition
|
|
@@ -142,9 +142,9 @@ exports.noCompositingLayerProps = (0, createRule_1.createRule)({
|
|
|
142
142
|
return;
|
|
143
143
|
checkNode(node);
|
|
144
144
|
},
|
|
145
|
-
// Handle JSX style attributes
|
|
145
|
+
// Handle JSX style and sx attributes
|
|
146
146
|
JSXAttribute(node) {
|
|
147
|
-
if (node.name.name !== 'style')
|
|
147
|
+
if (node.name.name !== 'style' && node.name.name !== 'sx')
|
|
148
148
|
return;
|
|
149
149
|
if (node.value?.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer &&
|
|
150
150
|
node.value.expression.type === utils_1.AST_NODE_TYPES.ObjectExpression) {
|