File tree Expand file tree Collapse file tree 9 files changed +17
-14
lines changed
eslint-plugin-react-naming-convention/src/rules
eslint-plugin-react-x/src/rules Expand file tree Collapse file tree 9 files changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -78,10 +78,6 @@ const config: FlatConfig[] = [
78
78
"no-process-exit" : "error" ,
79
79
"no-restricted-syntax" : [
80
80
"error" ,
81
- {
82
- message : "no let" ,
83
- selector : "VariableDeclaration[kind=let]" ,
84
- } ,
85
81
{
86
82
message : "no else" ,
87
83
selector : "IfStatement[alternate]" ,
@@ -90,6 +86,10 @@ const config: FlatConfig[] = [
90
86
message : "no optional" ,
91
87
selector : "TSPropertySignature[optional=true]" ,
92
88
} ,
89
+ {
90
+ message : "no undefined" ,
91
+ selector : "Identifier[name='undefined']" ,
92
+ } ,
93
93
] ,
94
94
"no-undef" : "off" ,
95
95
"one-var" : [ "error" , "never" ] ,
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ export default createRule<[], MessageID>({
124
124
. otherwise ( ( ) => "other" ) ;
125
125
}
126
126
const functionStack = MutList . make < [ node : TSESTreeFunction , kind : FunctionKind ] > ( ) ;
127
- const effectFunctionRef = MutRef . make < TSESTreeFunction | null > ( null ) ;
127
+ const effectFunctionRef = MutRef . make < null | TSESTreeFunction > ( null ) ;
128
128
const effectFunctionIdentifiers : TSESTree . Identifier [ ] = [ ] ;
129
129
const indirectFunctionCalls : TSESTree . CallExpression [ ] = [ ] ;
130
130
const indirectSetStateCalls = new WeakMap < TSESTreeFunction , TSESTree . CallExpression [ ] > ( ) ;
@@ -179,7 +179,7 @@ export default createRule<[], MessageID>({
179
179
. otherwise ( F . constVoid ) ;
180
180
} ,
181
181
"Program:exit" ( ) {
182
- const getSetStateCalls = ( id : TSESTree . Identifier | string , initialScope : Scope . Scope ) => {
182
+ const getSetStateCalls = ( id : string | TSESTree . Identifier , initialScope : Scope . Scope ) => {
183
183
return F . pipe (
184
184
findVariable ( id , initialScope ) ,
185
185
O . flatMap ( getVariableNode ( 0 ) ) ,
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ export default createRule<[], MessageID>({
125
125
. otherwise ( ( ) => "other" ) ;
126
126
}
127
127
const functionStack = MutList . make < [ node : TSESTreeFunction , kind : FunctionKind ] > ( ) ;
128
- const effectFunctionRef = MutRef . make < TSESTreeFunction | null > ( null ) ;
128
+ const effectFunctionRef = MutRef . make < null | TSESTreeFunction > ( null ) ;
129
129
const effectFunctionIdentifiers : TSESTree . Identifier [ ] = [ ] ;
130
130
const indirectFunctionCalls : TSESTree . CallExpression [ ] = [ ] ;
131
131
const indirectSetStateCalls = new WeakMap < TSESTreeFunction , TSESTree . CallExpression [ ] > ( ) ;
@@ -180,7 +180,7 @@ export default createRule<[], MessageID>({
180
180
. otherwise ( F . constVoid ) ;
181
181
} ,
182
182
"Program:exit" ( ) {
183
- const getSetStateCalls = ( id : TSESTree . Identifier | string , initialScope : Scope . Scope ) => {
183
+ const getSetStateCalls = ( id : string | TSESTree . Identifier , initialScope : Scope . Scope ) => {
184
184
return F . pipe (
185
185
findVariable ( id , initialScope ) ,
186
186
O . flatMap ( getVariableNode ( 0 ) ) ,
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export type MessageID =
15
15
| "FILENAME_CASE_MISMATCH_SUGGESTION"
16
16
| "FILENAME_EMPTY" ;
17
17
18
- type Case = "PascalCase " | "camelCase " | "kebab-case " | "snake_case" ;
18
+ type Case = "camelCase " | "kebab-case " | "PascalCase " | "snake_case" ;
19
19
20
20
/* eslint-disable no-restricted-syntax */
21
21
type Options = readonly [
Original file line number Diff line number Diff line change @@ -119,6 +119,9 @@ export default createRule<[], MessageID>({
119
119
}
120
120
O . map ( checkExpression ( fn . body ) , context . report ) ;
121
121
} ,
122
+ [ childrenToArraySelector ] ( ) {
123
+ MutRef . set ( isWithinChildrenToArrayRef , true ) ;
124
+ } ,
122
125
JSXFragment ( node ) {
123
126
if ( MutRef . get ( isWithinChildrenToArrayRef ) ) return ;
124
127
if ( node . parent . type === NodeType . ArrayExpression ) {
@@ -128,9 +131,6 @@ export default createRule<[], MessageID>({
128
131
} ) ;
129
132
}
130
133
} ,
131
- [ childrenToArraySelector ] ( ) {
132
- MutRef . set ( isWithinChildrenToArrayRef , true ) ;
133
- } ,
134
134
} ;
135
135
} ,
136
136
defaultOptions : [ ] ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export type Narrow<TType> =
16
16
| { [ K in keyof TType ] : Narrow < TType [ K ] > }
17
17
| ( TType extends [ ] ? [ ] : never )
18
18
| ( TType extends Function ? TType : never )
19
+ // eslint-disable-next-line perfectionist/sort-union-types
19
20
| ( TType extends bigint | boolean | number | string ? TType : never ) ;
20
21
21
22
/**
Original file line number Diff line number Diff line change
1
+ import { Pred } from "@eslint-react/tools" ;
1
2
import type { TSESTree } from "@typescript-eslint/types" ;
2
3
3
4
import { NodeType } from "./types" ;
@@ -12,7 +13,7 @@ export function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTre
12
13
if ( node . type === NodeType . ReturnStatement ) {
13
14
returnStatements . push ( node ) ;
14
15
}
15
- if ( "body" in node && node . body !== undefined && node . body !== null ) {
16
+ if ( "body" in node && ! Pred . isNullable ( node . body ) ) {
16
17
const chunk = Array . isArray ( node . body )
17
18
? node . body . map ( getNestedReturnStatements ) . flat ( 1 )
18
19
: getNestedReturnStatements ( node . body ) ;
Original file line number Diff line number Diff line change
1
+ /* eslint-disable perfectionist/sort-object-types */
1
2
declare module "@eslint-community/eslint-utils" {
2
3
export const findVariable : unknown ;
3
4
export const getFunctionHeadLocation : unknown ;
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ export const DEFAULT_JSX_VALUE_HINT = 0n
46
46
* @returns boolean
47
47
*/
48
48
export function isJSXValue (
49
- node : TSESTree . Node | null | undefined ,
49
+ node : null | TSESTree . Node | undefined ,
50
50
context : RuleContext ,
51
51
hint : bigint = DEFAULT_JSX_VALUE_HINT ,
52
52
) : boolean {
You can’t perform that action at this time.
0 commit comments