You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/no-get.md
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,10 @@ Examples of **correct** code for this rule:
50
50
constfoo=this.someProperty;
51
51
```
52
52
53
+
```js
54
+
constfoo=this.nested?.path; // Optional chaining can be useful if the nested path can have null or undefined properties in it.
55
+
```
56
+
53
57
```js
54
58
constfoo=this.get('some.nested.property'); // Allowed if `ignoreNestedPaths` option is enabled.
55
59
```
@@ -89,6 +93,7 @@ This rule takes an optional object containing:
89
93
90
94
* `boolean` -- `ignoreGetProperties` -- whether the rule should ignore `getProperties` (default `false`)
91
95
* `boolean` -- `ignoreNestedPaths` -- whether the rule should ignore `this.get('some.nested.property')` (default `false`)
96
+
* `boolean` -- `useOptionalChaining` -- whether the rule should use the [optional chaining operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) `?.` to autofix nested paths such as `this.get('some.nested.property')` to `this.some?.nested?.property` (when this option is off, these nested paths won't be autofixed at all) (default `false`)
0 commit comments