eslint-plugin-th-rules 2.7.0 → 2.7.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.7.1](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v2.7.0...v2.7.1) (2026-01-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update no-boolean-coercion rule to enforce explicit checks with negation ([a9e7752](https://github.com/tomerh2001/eslint-plugin-th-rules/commit/a9e77524035efbd023330168e2d070a6419cde70))
7
+
1
8
  # [2.7.0](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v2.6.1...v2.7.0) (2026-01-14)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-th-rules",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "description": "A List of custom ESLint rules created by Tomer Horowitz",
5
5
  "keywords": [
6
6
  "eslint",
@@ -2,7 +2,7 @@ const meta = {
2
2
  type: 'problem',
3
3
  docs: {
4
4
  description:
5
- 'Disallow Boolean(value) or !!value. Enforce _.isNil(value) for scalar values and _.isEmpty(value) for strings, arrays, and objects.',
5
+ 'Disallow Boolean(value) or !!value. Enforce explicit checks: !_.isNil(value) for scalar values and !_.isEmpty(value) for strings, arrays, and objects.',
6
6
  category: 'Best Practices',
7
7
  recommended: true,
8
8
  url: 'https://github.com/tomerh2001/eslint-plugin-th-rules/blob/main/docs/rules/no-boolean-coercion.md',
@@ -11,9 +11,9 @@ const meta = {
11
11
  schema: [],
12
12
  messages: {
13
13
  useIsEmpty:
14
- 'Boolean coercion is not allowed. Use _.isEmpty(value) for strings, arrays, and objects.',
14
+ 'Boolean coercion is not allowed. Use !_.isEmpty(value) for strings, arrays, and objects.',
15
15
  useIsNil:
16
- 'Boolean coercion is not allowed. Use _.isNil(value) for scalar values.',
16
+ 'Boolean coercion is not allowed. Use !_.isNil(value) for scalar values.',
17
17
  },
18
18
  };
19
19
 
@@ -51,7 +51,6 @@ function create(context) {
51
51
  }
52
52
 
53
53
  const type = checker.getTypeAtLocation(tsNode);
54
-
55
54
  const typeString = checker.typeToString(type);
56
55
 
57
56
  return (
@@ -67,7 +66,7 @@ function create(context) {
67
66
  return (
68
67
  node.type === 'ArrayExpression'
69
68
  || node.type === 'ObjectExpression'
70
- || node.type === 'Literal' && typeof node.value === 'string'
69
+ || (node.type === 'Literal' && typeof node.value === 'string')
71
70
  );
72
71
  }
73
72
 
@@ -77,7 +76,7 @@ function create(context) {
77
76
  || isCollectionLikeByTS(valueNode);
78
77
 
79
78
  const suggestedFn = isCollection ? '_.isEmpty' : '_.isNil';
80
- const replacement = `${suggestedFn}(${sourceCode.getText(valueNode)})`;
79
+ const replacement = `!${suggestedFn}(${sourceCode.getText(valueNode)})`;
81
80
 
82
81
  context.report({
83
82
  node,
@@ -27,8 +27,8 @@ ruleTester.run('no-boolean-coercion', rule, {
27
27
  messageId: 'useIsNil',
28
28
  suggestions: [
29
29
  {
30
- desc: 'Replace with _.isNil(foo)',
31
- output: '_.isNil(foo);',
30
+ desc: 'Replace with !_.isNil(foo)',
31
+ output: '!_.isNil(foo);',
32
32
  },
33
33
  ],
34
34
  },
@@ -42,8 +42,8 @@ ruleTester.run('no-boolean-coercion', rule, {
42
42
  messageId: 'useIsNil',
43
43
  suggestions: [
44
44
  {
45
- desc: 'Replace with _.isNil(bar)',
46
- output: 'const x = _.isNil(bar);',
45
+ desc: 'Replace with !_.isNil(bar)',
46
+ output: 'const x = !_.isNil(bar);',
47
47
  },
48
48
  ],
49
49
  },
@@ -57,8 +57,8 @@ ruleTester.run('no-boolean-coercion', rule, {
57
57
  messageId: 'useIsNil',
58
58
  suggestions: [
59
59
  {
60
- desc: 'Replace with _.isNil(value)',
61
- output: '_.isNil(value);',
60
+ desc: 'Replace with !_.isNil(value)',
61
+ output: '!_.isNil(value);',
62
62
  },
63
63
  ],
64
64
  },
@@ -72,8 +72,8 @@ ruleTester.run('no-boolean-coercion', rule, {
72
72
  messageId: 'useIsEmpty',
73
73
  suggestions: [
74
74
  {
75
- desc: 'Replace with _.isEmpty([])',
76
- output: '_.isEmpty([]);',
75
+ desc: 'Replace with !_.isEmpty([])',
76
+ output: '!_.isEmpty([]);',
77
77
  },
78
78
  ],
79
79
  },