eslint-plugin-crisp 1.7.18 → 1.7.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-crisp",
3
- "version": "1.7.18",
3
+ "version": "1.7.19",
4
4
  "description": "Custom ESLint Rules for Crisp",
5
5
  "author": "Crisp IM SAS",
6
6
  "main": "index.js",
@@ -18,9 +18,10 @@ export default {
18
18
 
19
19
  const patterns = [
20
20
  // Search for `foo && foo.` or `foo && foo[`
21
- // Notice: do not match `foo && foo.bar !==` or `foo && foo[bar] !==`, \
22
- // as the version with optional chaining would be unsafe
23
- /\b(\w\S+)\s&&\s+\1\b[\[\.](?!\w\S+\s\!\=\=)/g,
21
+ // Notice: do not match when the accessed value is compared, as the \
22
+ // version with optional chaining could change the result for falsy \
23
+ // non-nullish values
24
+ /\b(\w\S+)\s&&\s+\1\b[\[\.](?!\S+\s*(?:[=!]==?|[<>]=?))/g,
24
25
 
25
26
  // Search for patterns like `foo || {}).bar`, `foo || {})[`, \
26
27
  // `foo || []).bar` or `foo || [])[`
@@ -7,6 +7,9 @@ ruleTester.run("enforce-optional", rule, {
7
7
  valid: [
8
8
  "const result = foo?.bar;",
9
9
  "const result = foo && foo.bar !== null;",
10
+ "const result = foo && foo.bar <= maximum;",
11
+ "const result = foo && foo[bar] === value;",
12
+ "if (_header_value && _header_value.length <= ORIGINAL_HEADER_MAX_LENGTH) {}",
10
13
  "const keys = Object.keys(foo || {});",
11
14
  "const filtered = (foo || []).filter(Boolean);"
12
15
  ],