File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
packages/plugins/eslint-plugin-react-naming-convention/src/rules Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1- import * as AST from "@eslint-react/ast" ;
21import { isCreateContextCall } from "@eslint-react/core" ;
2+ import { _ , identity } from "@eslint-react/eff" ;
33import type { RuleFeature } from "@eslint-react/shared" ;
44import * as VAR from "@eslint-react/var" ;
5+ import { AST_NODE_TYPES as T } from "@typescript-eslint/types" ;
56import type { CamelCase } from "string-ts" ;
7+ import { match , P } from "ts-pattern" ;
68
79import { createRule } from "../utils" ;
810
@@ -33,7 +35,11 @@ export default createRule<[], MessageID>({
3335 if ( ! isCreateContextCall ( context , node ) ) return ;
3436 const id = VAR . getVariableId ( node ) ;
3537 if ( id == null ) return ;
36- const name = context . sourceCode . getText ( AST . getEcmaExpression ( id ) ) ;
38+ const name = match ( id )
39+ . with ( { type : T . Identifier , name : P . select ( ) } , identity )
40+ . with ( { type : T . MemberExpression , property : { name : P . select ( P . string ) } } , identity )
41+ . otherwise ( ( ) => _ ) ;
42+ if ( name == null ) return ;
3743 if ( name . endsWith ( "Context" ) ) return ;
3844 context . report ( {
3945 messageId : "contextName" ,
You can’t perform that action at this time.
0 commit comments