@blumintinc/eslint-plugin-blumint 1.12.1 → 1.12.2

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.1',
109
+ version: '1.12.2',
110
110
  },
111
111
  parseOptions: {
112
112
  ecmaVersion: 2020,
@@ -119,9 +119,48 @@ exports.enforceBooleanNamingPrefixes = (0, createRule_1.createRule)({
119
119
  ['===', '!==', '==', '!=', '>', '<', '>=', '<='].includes(node.init.operator)) {
120
120
  return true;
121
121
  }
122
- // Check for logical expressions (&&, ||)
122
+ // Check for logical expressions (&&)
123
123
  if (node.init.type === utils_1.AST_NODE_TYPES.LogicalExpression &&
124
124
  node.init.operator === '&&') {
125
+ // Check if the right side is a method call that might return a non-boolean value
126
+ const rightSide = node.init.right;
127
+ if (rightSide.type === utils_1.AST_NODE_TYPES.CallExpression) {
128
+ // If the method name doesn't suggest it returns a boolean, don't flag it
129
+ if (rightSide.callee.type === utils_1.AST_NODE_TYPES.MemberExpression &&
130
+ rightSide.callee.property.type === utils_1.AST_NODE_TYPES.Identifier) {
131
+ const methodName = rightSide.callee.property.name;
132
+ // Check if the method name suggests it returns a boolean
133
+ const isBooleanMethod = approvedPrefixes.some((prefix) => methodName.toLowerCase().startsWith(prefix.toLowerCase()));
134
+ // If the method name suggests it returns a boolean (starts with a boolean prefix or contains 'boolean' or 'enabled'),
135
+ // then the variable should be treated as a boolean
136
+ if (isBooleanMethod ||
137
+ methodName.toLowerCase().includes('boolean') ||
138
+ methodName.toLowerCase().includes('enabled') ||
139
+ methodName.toLowerCase().includes('auth') ||
140
+ methodName.toLowerCase().includes('valid') ||
141
+ methodName.toLowerCase().includes('check')) {
142
+ return true;
143
+ }
144
+ // For methods like getVolume(), getData(), etc., assume they return non-boolean values
145
+ if (methodName.toLowerCase().startsWith('get') ||
146
+ methodName.toLowerCase().startsWith('fetch') ||
147
+ methodName.toLowerCase().startsWith('retrieve') ||
148
+ methodName.toLowerCase().startsWith('load') ||
149
+ methodName.toLowerCase().startsWith('read')) {
150
+ return false;
151
+ }
152
+ }
153
+ }
154
+ // For property access like user.isAuthenticated, treat as boolean
155
+ if (rightSide.type === utils_1.AST_NODE_TYPES.MemberExpression &&
156
+ rightSide.property.type === utils_1.AST_NODE_TYPES.Identifier) {
157
+ const propertyName = rightSide.property.name;
158
+ const isBooleanProperty = approvedPrefixes.some((prefix) => propertyName.toLowerCase().startsWith(prefix.toLowerCase()));
159
+ if (isBooleanProperty) {
160
+ return true;
161
+ }
162
+ }
163
+ // Default to true for other cases with && to avoid false negatives
125
164
  return true;
126
165
  }
127
166
  // Special case for logical OR (||) - only consider it boolean if:
@@ -930,9 +930,12 @@ exports.enforcePositiveNaming = (0, createRule_1.createRule)({
930
930
  // Split the name into words
931
931
  const words = splitNameIntoWords(name);
932
932
  // Check if this follows the pattern IS_NOT_SOMETHING or HAS_NO_SOMETHING
933
- const secondWord = words[1].toLowerCase();
934
- if (EXCEPTION_WORDS.some((exception) => secondWord === exception.toLowerCase())) {
935
- return { isNegative: false, alternatives: [] };
933
+ // Make sure words[1] exists before trying to access it
934
+ if (words.length > 1) {
935
+ const secondWord = words[1].toLowerCase();
936
+ if (EXCEPTION_WORDS.some((exception) => secondWord === exception.toLowerCase())) {
937
+ return { isNegative: false, alternatives: [] };
938
+ }
936
939
  }
937
940
  const nameLowercase = name.toLowerCase();
938
941
  // Check for negative prefixes in boolean-like variables
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blumintinc/eslint-plugin-blumint",
3
- "version": "1.12.1",
3
+ "version": "1.12.2",
4
4
  "description": "Custom eslint rules for use within BluMint",
5
5
  "author": {
6
6
  "name": "Brodie McGuire",