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[] = [
7878 "no-process-exit" : "error" ,
7979 "no-restricted-syntax" : [
8080 "error" ,
81- {
82- message : "no let" ,
83- selector : "VariableDeclaration[kind=let]" ,
84- } ,
8581 {
8682 message : "no else" ,
8783 selector : "IfStatement[alternate]" ,
@@ -90,6 +86,10 @@ const config: FlatConfig[] = [
9086 message : "no optional" ,
9187 selector : "TSPropertySignature[optional=true]" ,
9288 } ,
89+ {
90+ message : "no undefined" ,
91+ selector : "Identifier[name='undefined']" ,
92+ } ,
9393 ] ,
9494 "no-undef" : "off" ,
9595 "one-var" : [ "error" , "never" ] ,
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ export default createRule<[], MessageID>({
124124 . otherwise ( ( ) => "other" ) ;
125125 }
126126 const functionStack = MutList . make < [ node : TSESTreeFunction , kind : FunctionKind ] > ( ) ;
127- const effectFunctionRef = MutRef . make < TSESTreeFunction | null > ( null ) ;
127+ const effectFunctionRef = MutRef . make < null | TSESTreeFunction > ( null ) ;
128128 const effectFunctionIdentifiers : TSESTree . Identifier [ ] = [ ] ;
129129 const indirectFunctionCalls : TSESTree . CallExpression [ ] = [ ] ;
130130 const indirectSetStateCalls = new WeakMap < TSESTreeFunction , TSESTree . CallExpression [ ] > ( ) ;
@@ -179,7 +179,7 @@ export default createRule<[], MessageID>({
179179 . otherwise ( F . constVoid ) ;
180180 } ,
181181 "Program:exit" ( ) {
182- const getSetStateCalls = ( id : TSESTree . Identifier | string , initialScope : Scope . Scope ) => {
182+ const getSetStateCalls = ( id : string | TSESTree . Identifier , initialScope : Scope . Scope ) => {
183183 return F . pipe (
184184 findVariable ( id , initialScope ) ,
185185 O . flatMap ( getVariableNode ( 0 ) ) ,
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ export default createRule<[], MessageID>({
125125 . otherwise ( ( ) => "other" ) ;
126126 }
127127 const functionStack = MutList . make < [ node : TSESTreeFunction , kind : FunctionKind ] > ( ) ;
128- const effectFunctionRef = MutRef . make < TSESTreeFunction | null > ( null ) ;
128+ const effectFunctionRef = MutRef . make < null | TSESTreeFunction > ( null ) ;
129129 const effectFunctionIdentifiers : TSESTree . Identifier [ ] = [ ] ;
130130 const indirectFunctionCalls : TSESTree . CallExpression [ ] = [ ] ;
131131 const indirectSetStateCalls = new WeakMap < TSESTreeFunction , TSESTree . CallExpression [ ] > ( ) ;
@@ -180,7 +180,7 @@ export default createRule<[], MessageID>({
180180 . otherwise ( F . constVoid ) ;
181181 } ,
182182 "Program:exit" ( ) {
183- const getSetStateCalls = ( id : TSESTree . Identifier | string , initialScope : Scope . Scope ) => {
183+ const getSetStateCalls = ( id : string | TSESTree . Identifier , initialScope : Scope . Scope ) => {
184184 return F . pipe (
185185 findVariable ( id , initialScope ) ,
186186 O . flatMap ( getVariableNode ( 0 ) ) ,
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export type MessageID =
1515 | "FILENAME_CASE_MISMATCH_SUGGESTION"
1616 | "FILENAME_EMPTY" ;
1717
18- type Case = "PascalCase " | "camelCase " | "kebab-case " | "snake_case" ;
18+ type Case = "camelCase " | "kebab-case " | "PascalCase " | "snake_case" ;
1919
2020/* eslint-disable no-restricted-syntax */
2121type Options = readonly [
Original file line number Diff line number Diff line change @@ -119,6 +119,9 @@ export default createRule<[], MessageID>({
119119 }
120120 O . map ( checkExpression ( fn . body ) , context . report ) ;
121121 } ,
122+ [ childrenToArraySelector ] ( ) {
123+ MutRef . set ( isWithinChildrenToArrayRef , true ) ;
124+ } ,
122125 JSXFragment ( node ) {
123126 if ( MutRef . get ( isWithinChildrenToArrayRef ) ) return ;
124127 if ( node . parent . type === NodeType . ArrayExpression ) {
@@ -128,9 +131,6 @@ export default createRule<[], MessageID>({
128131 } ) ;
129132 }
130133 } ,
131- [ childrenToArraySelector ] ( ) {
132- MutRef . set ( isWithinChildrenToArrayRef , true ) ;
133- } ,
134134 } ;
135135 } ,
136136 defaultOptions : [ ] ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export type Narrow<TType> =
1616 | { [ K in keyof TType ] : Narrow < TType [ K ] > }
1717 | ( TType extends [ ] ? [ ] : never )
1818 | ( TType extends Function ? TType : never )
19+ // eslint-disable-next-line perfectionist/sort-union-types
1920 | ( TType extends bigint | boolean | number | string ? TType : never ) ;
2021
2122/**
Original file line number Diff line number Diff line change 1+ import { Pred } from "@eslint-react/tools" ;
12import type { TSESTree } from "@typescript-eslint/types" ;
23
34import { NodeType } from "./types" ;
@@ -12,7 +13,7 @@ export function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTre
1213 if ( node . type === NodeType . ReturnStatement ) {
1314 returnStatements . push ( node ) ;
1415 }
15- if ( "body" in node && node . body !== undefined && node . body !== null ) {
16+ if ( "body" in node && ! Pred . isNullable ( node . body ) ) {
1617 const chunk = Array . isArray ( node . body )
1718 ? node . body . map ( getNestedReturnStatements ) . flat ( 1 )
1819 : getNestedReturnStatements ( node . body ) ;
Original file line number Diff line number Diff line change 1+ /* eslint-disable perfectionist/sort-object-types */
12declare module "@eslint-community/eslint-utils" {
23 export const findVariable : unknown ;
34 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
4646 * @returns boolean
4747 */
4848export function isJSXValue (
49- node : TSESTree . Node | null | undefined ,
49+ node : null | TSESTree . Node | undefined ,
5050 context : RuleContext ,
5151 hint : bigint = DEFAULT_JSX_VALUE_HINT ,
5252) : boolean {
You can’t perform that action at this time.
0 commit comments