File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed
tests/rules/immutable-data/ts/object Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,15 @@ import {
77 hasID ,
88 hasKey ,
99 isAssignmentExpression ,
10+ isChainExpression ,
1011 isDefined ,
1112 isIdentifier ,
1213 isMemberExpression ,
1314 isPrivateIdentifier ,
14- isThisExpression ,
1515 isTSAsExpression ,
16+ isTSNonNullExpression ,
1617 isTSTypeAnnotation ,
18+ isThisExpression ,
1719 isUnaryExpression ,
1820 isVariableDeclaration ,
1921} from "#/utils/type-guards" ;
@@ -73,7 +75,9 @@ function getNodeIdentifierText(
7375 ? context . sourceCode
7476 . getText ( node . typeAnnotation as TSESTree . Node )
7577 . replaceAll ( / \s + / gmu, "" )
76- : isTSAsExpression ( node )
78+ : isTSAsExpression ( node ) ||
79+ isTSNonNullExpression ( node ) ||
80+ isChainExpression ( node )
7781 ? getNodeIdentifierText ( node . expression , context )
7882 : null ;
7983
Original file line number Diff line number Diff line change @@ -75,6 +75,12 @@ export function isCallExpression(
7575 return node . type === AST_NODE_TYPES . CallExpression ;
7676}
7777
78+ export function isChainExpression (
79+ node : TSESTree . Node ,
80+ ) : node is TSESTree . ChainExpression {
81+ return node . type === AST_NODE_TYPES . ChainExpression ;
82+ }
83+
7884export function isPropertyDefinition (
7985 node : TSESTree . Node ,
8086) : node is TSESTree . PropertyDefinition {
@@ -303,6 +309,12 @@ export function isTSInterfaceHeritage(
303309 return node . type === AST_NODE_TYPES . TSInterfaceHeritage ;
304310}
305311
312+ export function isTSNonNullExpression (
313+ node : TSESTree . Node ,
314+ ) : node is TSESTree . TSNonNullExpression {
315+ return node . type === AST_NODE_TYPES . TSNonNullExpression ;
316+ }
317+
306318export function isTSNullKeyword (
307319 node : TSESTree . Node ,
308320) : node is TSESTree . TSNullKeyword {
Original file line number Diff line number Diff line change @@ -282,6 +282,12 @@ const tests: Array<ValidTestCaseSet<OptionsOf<typeof rule>>> = [
282282 ` ,
283283 optionsSet : [ [ { ignoreAccessorPattern : "mutable*.*" } ] ] ,
284284 } ,
285+ {
286+ code : dedent `
287+ mutable_foo!.baz = "hello world";
288+ ` ,
289+ optionsSet : [ [ { ignoreAccessorPattern : "mutable*.*" } ] ] ,
290+ } ,
285291] ;
286292
287293export default tests ;
You can’t perform that action at this time.
0 commit comments