eslint 9.37.0 → 9.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,18 +30,65 @@ import type {
30
30
  CustomRuleDefinitionType,
31
31
  CustomRuleTypeDefinitions,
32
32
  DeprecatedInfo,
33
- Language,
34
33
  LanguageOptions as GenericLanguageOptions,
35
34
  RuleContext as CoreRuleContext,
36
35
  RuleDefinition,
37
- RuleVisitor,
38
36
  SourceRange,
39
37
  TextSourceCode,
40
38
  TraversalStep,
39
+ RulesConfig,
40
+ GlobalAccess,
41
+ GlobalsConfig,
42
+ LinterOptionsConfig,
43
+ EnvironmentConfig,
44
+ ObjectMetaProperties as CoreObjectMetaProperties,
45
+ Plugin as CorePlugin,
46
+ LintMessage as CoreLintMessage,
47
+ Processor as CoreProcessor,
48
+ ConfigObject,
49
+ LegacyConfigObject,
50
+ SeverityName,
51
+ SeverityLevel,
52
+ Severity as CoreSeverity,
53
+ EcmaVersion as CoreEcmaVersion,
54
+ ConfigOverride as CoreConfigOverride,
55
+ ProcessorFile as CoreProcessorFile,
56
+ JavaScriptParserOptionsConfig,
57
+ RulesMeta,
58
+ RuleConfig,
59
+ RuleTextEditor,
60
+ RuleTextEdit,
61
+ RuleVisitor,
62
+ BaseConfig as CoreBaseConfig,
63
+ RuleFixer as CoreRuleFixer,
64
+ ViolationReportBase,
65
+ ViolationMessage,
66
+ ViolationLocation,
67
+ SuggestionMessage,
68
+ LintSuggestion as CoreLintSuggestion,
69
+ JavaScriptSourceType,
70
+ HasRules as CoreHasRules,
71
+ SuggestedEditBase,
72
+ SuggestedEdit,
73
+ ViolationReport,
41
74
  } from "@eslint/core";
42
- import { JSONSchema4 } from "json-schema";
43
75
  import { LegacyESLint } from "./use-at-your-own-risk.js";
44
76
 
77
+ //------------------------------------------------------------------------------
78
+ // Helpers
79
+ //------------------------------------------------------------------------------
80
+
81
+ /** Adds matching `:exit` selectors for all properties of a `RuleVisitor`. */
82
+ type WithExit<RuleVisitorType extends RuleVisitor> = {
83
+ [Key in keyof RuleVisitorType as
84
+ | Key
85
+ | `${Key & string}:exit`]: RuleVisitorType[Key];
86
+ };
87
+
88
+ //------------------------------------------------------------------------------
89
+ // Exports
90
+ //------------------------------------------------------------------------------
91
+
45
92
  export namespace AST {
46
93
  type TokenType =
47
94
  | "Boolean"
@@ -114,6 +161,10 @@ export namespace Scope {
114
161
  references: Reference[];
115
162
  through: Reference[];
116
163
  functionExpressionScope: boolean;
164
+ implicit?: {
165
+ variables: Variable[];
166
+ set: Map<string, Variable>;
167
+ };
117
168
  }
118
169
 
119
170
  interface Variable {
@@ -154,7 +205,14 @@ export namespace Scope {
154
205
  node: ESTree.FunctionDeclaration | ESTree.FunctionExpression;
155
206
  parent: null;
156
207
  }
157
- | { type: "ImplicitGlobalVariable"; node: ESTree.Program; parent: null }
208
+ | {
209
+ type: "ImplicitGlobalVariable";
210
+ node:
211
+ | ESTree.AssignmentExpression
212
+ | ESTree.ForInStatement
213
+ | ESTree.ForOfStatement;
214
+ parent: null;
215
+ }
158
216
  | {
159
217
  type: "ImportBinding";
160
218
  node:
@@ -222,11 +280,16 @@ export class SourceCode
222
280
 
223
281
  getDeclaredVariables(node: ESTree.Node): Scope.Variable[];
224
282
 
283
+ /** @deprecated */
225
284
  getJSDocComment(node: ESTree.Node): ESTree.Comment | null;
226
285
 
227
286
  getNodeByRangeIndex(index: number): ESTree.Node | null;
228
287
 
229
- isSpaceBetweenTokens(first: AST.Token, second: AST.Token): boolean;
288
+ /** @deprecated Use `isSpaceBetween()` instead. */
289
+ isSpaceBetweenTokens(
290
+ first: ESTree.Node | AST.Token,
291
+ second: ESTree.Node | AST.Token,
292
+ ): boolean;
230
293
 
231
294
  getLocFromIndex(index: number): ESTree.Position;
232
295
 
@@ -260,6 +323,18 @@ export class SourceCode
260
323
 
261
324
  getTokensAfter: SourceCode.UnaryCursorWithCountOptions;
262
325
 
326
+ /** @deprecated Use `getTokenBefore()` instead. */
327
+ getTokenOrCommentBefore(
328
+ node: ESTree.Node | AST.Token | ESTree.Comment,
329
+ skip?: number | undefined,
330
+ ): AST.Token | ESTree.Comment | null;
331
+
332
+ /** @deprecated Use `getTokenAfter()` instead. */
333
+ getTokenOrCommentAfter(
334
+ node: ESTree.Node | AST.Token | ESTree.Comment,
335
+ skip?: number | undefined,
336
+ ): AST.Token | ESTree.Comment | null;
337
+
263
338
  getFirstTokenBetween: SourceCode.BinaryCursorWithSkipOptions;
264
339
 
265
340
  getFirstTokensBetween: SourceCode.BinaryCursorWithCountOptions;
@@ -306,9 +381,10 @@ export namespace SourceCode {
306
381
  interface Config {
307
382
  text: string;
308
383
  ast: AST.Program;
309
- parserServices?: ParserServices | undefined;
310
- scopeManager?: Scope.ScopeManager | undefined;
311
- visitorKeys?: VisitorKeys | undefined;
384
+ hasBOM?: boolean | undefined;
385
+ parserServices?: ParserServices | null | undefined;
386
+ scopeManager?: Scope.ScopeManager | null | undefined;
387
+ visitorKeys?: VisitorKeys | null | undefined;
312
388
  }
313
389
 
314
390
  type ParserServices = any;
@@ -603,480 +679,35 @@ export namespace Rule {
603
679
  LangOptions: Linter.LanguageOptions;
604
680
  Code: SourceCode;
605
681
  RuleOptions: any[];
606
- Visitor: NodeListener;
682
+ Visitor: RuleListener;
607
683
  Node: JSSyntaxElement;
608
684
  MessageIds: string;
609
685
  ExtRuleDocs: {};
610
686
  }> {
611
- create(context: RuleContext): NodeListener;
687
+ create(context: RuleContext): RuleListener;
612
688
  }
613
689
 
614
690
  type NodeTypes = ESTree.Node["type"];
615
- interface NodeListener extends RuleVisitor {
616
- ArrayExpression?:
617
- | ((node: ESTree.ArrayExpression & NodeParentExtension) => void)
618
- | undefined;
619
- "ArrayExpression:exit"?:
620
- | ((node: ESTree.ArrayExpression & NodeParentExtension) => void)
621
- | undefined;
622
- ArrayPattern?:
623
- | ((node: ESTree.ArrayPattern & NodeParentExtension) => void)
624
- | undefined;
625
- "ArrayPattern:exit"?:
626
- | ((node: ESTree.ArrayPattern & NodeParentExtension) => void)
627
- | undefined;
628
- ArrowFunctionExpression?:
629
- | ((
630
- node: ESTree.ArrowFunctionExpression & NodeParentExtension,
631
- ) => void)
632
- | undefined;
633
- "ArrowFunctionExpression:exit"?:
634
- | ((
635
- node: ESTree.ArrowFunctionExpression & NodeParentExtension,
636
- ) => void)
637
- | undefined;
638
- AssignmentExpression?:
639
- | ((
640
- node: ESTree.AssignmentExpression & NodeParentExtension,
641
- ) => void)
642
- | undefined;
643
- "AssignmentExpression:exit"?:
644
- | ((
645
- node: ESTree.AssignmentExpression & NodeParentExtension,
646
- ) => void)
647
- | undefined;
648
- AssignmentPattern?:
649
- | ((node: ESTree.AssignmentPattern & NodeParentExtension) => void)
650
- | undefined;
651
- "AssignmentPattern:exit"?:
652
- | ((node: ESTree.AssignmentPattern & NodeParentExtension) => void)
653
- | undefined;
654
- AwaitExpression?:
655
- | ((node: ESTree.AwaitExpression & NodeParentExtension) => void)
656
- | undefined;
657
- "AwaitExpression:exit"?:
658
- | ((node: ESTree.AwaitExpression & NodeParentExtension) => void)
659
- | undefined;
660
- BinaryExpression?:
661
- | ((node: ESTree.BinaryExpression & NodeParentExtension) => void)
662
- | undefined;
663
- "BinaryExpression:exit"?:
664
- | ((node: ESTree.BinaryExpression & NodeParentExtension) => void)
665
- | undefined;
666
- BlockStatement?:
667
- | ((node: ESTree.BlockStatement & NodeParentExtension) => void)
668
- | undefined;
669
- "BlockStatement:exit"?:
670
- | ((node: ESTree.BlockStatement & NodeParentExtension) => void)
671
- | undefined;
672
- BreakStatement?:
673
- | ((node: ESTree.BreakStatement & NodeParentExtension) => void)
674
- | undefined;
675
- "BreakStatement:exit"?:
676
- | ((node: ESTree.BreakStatement & NodeParentExtension) => void)
677
- | undefined;
678
- CallExpression?:
679
- | ((node: ESTree.CallExpression & NodeParentExtension) => void)
680
- | undefined;
681
- "CallExpression:exit"?:
682
- | ((node: ESTree.CallExpression & NodeParentExtension) => void)
683
- | undefined;
684
- CatchClause?:
685
- | ((node: ESTree.CatchClause & NodeParentExtension) => void)
686
- | undefined;
687
- "CatchClause:exit"?:
688
- | ((node: ESTree.CatchClause & NodeParentExtension) => void)
689
- | undefined;
690
- ChainExpression?:
691
- | ((node: ESTree.ChainExpression & NodeParentExtension) => void)
692
- | undefined;
693
- "ChainExpression:exit"?:
694
- | ((node: ESTree.ChainExpression & NodeParentExtension) => void)
695
- | undefined;
696
- ClassBody?:
697
- | ((node: ESTree.ClassBody & NodeParentExtension) => void)
698
- | undefined;
699
- "ClassBody:exit"?:
700
- | ((node: ESTree.ClassBody & NodeParentExtension) => void)
701
- | undefined;
702
- ClassDeclaration?:
703
- | ((node: ESTree.ClassDeclaration & NodeParentExtension) => void)
704
- | undefined;
705
- "ClassDeclaration:exit"?:
706
- | ((node: ESTree.ClassDeclaration & NodeParentExtension) => void)
707
- | undefined;
708
- ClassExpression?:
709
- | ((node: ESTree.ClassExpression & NodeParentExtension) => void)
710
- | undefined;
711
- "ClassExpression:exit"?:
712
- | ((node: ESTree.ClassExpression & NodeParentExtension) => void)
713
- | undefined;
714
- ConditionalExpression?:
715
- | ((
716
- node: ESTree.ConditionalExpression & NodeParentExtension,
717
- ) => void)
718
- | undefined;
719
- "ConditionalExpression:exit"?:
720
- | ((
721
- node: ESTree.ConditionalExpression & NodeParentExtension,
722
- ) => void)
723
- | undefined;
724
- ContinueStatement?:
725
- | ((node: ESTree.ContinueStatement & NodeParentExtension) => void)
726
- | undefined;
727
- "ContinueStatement:exit"?:
728
- | ((node: ESTree.ContinueStatement & NodeParentExtension) => void)
729
- | undefined;
730
- DebuggerStatement?:
731
- | ((node: ESTree.DebuggerStatement & NodeParentExtension) => void)
732
- | undefined;
733
- "DebuggerStatement:exit"?:
734
- | ((node: ESTree.DebuggerStatement & NodeParentExtension) => void)
735
- | undefined;
736
- DoWhileStatement?:
737
- | ((node: ESTree.DoWhileStatement & NodeParentExtension) => void)
738
- | undefined;
739
- "DoWhileStatement:exit"?:
740
- | ((node: ESTree.DoWhileStatement & NodeParentExtension) => void)
741
- | undefined;
742
- EmptyStatement?:
743
- | ((node: ESTree.EmptyStatement & NodeParentExtension) => void)
744
- | undefined;
745
- "EmptyStatement:exit"?:
746
- | ((node: ESTree.EmptyStatement & NodeParentExtension) => void)
747
- | undefined;
748
- ExportAllDeclaration?:
749
- | ((
750
- node: ESTree.ExportAllDeclaration & NodeParentExtension,
751
- ) => void)
752
- | undefined;
753
- "ExportAllDeclaration:exit"?:
754
- | ((
755
- node: ESTree.ExportAllDeclaration & NodeParentExtension,
756
- ) => void)
757
- | undefined;
758
- ExportDefaultDeclaration?:
759
- | ((
760
- node: ESTree.ExportDefaultDeclaration & NodeParentExtension,
761
- ) => void)
762
- | undefined;
763
- "ExportDefaultDeclaration:exit"?:
764
- | ((
765
- node: ESTree.ExportDefaultDeclaration & NodeParentExtension,
766
- ) => void)
767
- | undefined;
768
- ExportNamedDeclaration?:
769
- | ((
770
- node: ESTree.ExportNamedDeclaration & NodeParentExtension,
771
- ) => void)
772
- | undefined;
773
- "ExportNamedDeclaration:exit"?:
774
- | ((
775
- node: ESTree.ExportNamedDeclaration & NodeParentExtension,
776
- ) => void)
777
- | undefined;
778
- ExportSpecifier?:
779
- | ((node: ESTree.ExportSpecifier & NodeParentExtension) => void)
780
- | undefined;
781
- "ExportSpecifier:exit"?:
782
- | ((node: ESTree.ExportSpecifier & NodeParentExtension) => void)
783
- | undefined;
784
- ExpressionStatement?:
785
- | ((node: ESTree.ExpressionStatement & NodeParentExtension) => void)
786
- | undefined;
787
- "ExpressionStatement:exit"?:
788
- | ((node: ESTree.ExpressionStatement & NodeParentExtension) => void)
789
- | undefined;
790
- ForInStatement?:
791
- | ((node: ESTree.ForInStatement & NodeParentExtension) => void)
792
- | undefined;
793
- "ForInStatement:exit"?:
794
- | ((node: ESTree.ForInStatement & NodeParentExtension) => void)
795
- | undefined;
796
- ForOfStatement?:
797
- | ((node: ESTree.ForOfStatement & NodeParentExtension) => void)
798
- | undefined;
799
- "ForOfStatement:exit"?:
800
- | ((node: ESTree.ForOfStatement & NodeParentExtension) => void)
801
- | undefined;
802
- ForStatement?:
803
- | ((node: ESTree.ForStatement & NodeParentExtension) => void)
804
- | undefined;
805
- "ForStatement:exit"?:
806
- | ((node: ESTree.ForStatement & NodeParentExtension) => void)
807
- | undefined;
808
- FunctionDeclaration?:
809
- | ((node: ESTree.FunctionDeclaration & NodeParentExtension) => void)
810
- | undefined;
811
- "FunctionDeclaration:exit"?:
812
- | ((node: ESTree.FunctionDeclaration & NodeParentExtension) => void)
813
- | undefined;
814
- FunctionExpression?:
815
- | ((node: ESTree.FunctionExpression & NodeParentExtension) => void)
816
- | undefined;
817
- "FunctionExpression:exit"?:
818
- | ((node: ESTree.FunctionExpression & NodeParentExtension) => void)
819
- | undefined;
820
- Identifier?:
821
- | ((node: ESTree.Identifier & NodeParentExtension) => void)
822
- | undefined;
823
- "Identifier:exit"?:
824
- | ((node: ESTree.Identifier & NodeParentExtension) => void)
825
- | undefined;
826
- IfStatement?:
827
- | ((node: ESTree.IfStatement & NodeParentExtension) => void)
828
- | undefined;
829
- "IfStatement:exit"?:
830
- | ((node: ESTree.IfStatement & NodeParentExtension) => void)
831
- | undefined;
832
- ImportDeclaration?:
833
- | ((node: ESTree.ImportDeclaration & NodeParentExtension) => void)
834
- | undefined;
835
- "ImportDeclaration:exit"?:
836
- | ((node: ESTree.ImportDeclaration & NodeParentExtension) => void)
837
- | undefined;
838
- ImportDefaultSpecifier?:
839
- | ((
840
- node: ESTree.ImportDefaultSpecifier & NodeParentExtension,
841
- ) => void)
842
- | undefined;
843
- "ImportDefaultSpecifier:exit"?:
844
- | ((
845
- node: ESTree.ImportDefaultSpecifier & NodeParentExtension,
846
- ) => void)
847
- | undefined;
848
- ImportExpression?:
849
- | ((node: ESTree.ImportExpression & NodeParentExtension) => void)
850
- | undefined;
851
- "ImportExpression:exit"?:
852
- | ((node: ESTree.ImportExpression & NodeParentExtension) => void)
853
- | undefined;
854
- ImportNamespaceSpecifier?:
855
- | ((
856
- node: ESTree.ImportNamespaceSpecifier & NodeParentExtension,
857
- ) => void)
858
- | undefined;
859
- "ImportNamespaceSpecifier:exit"?:
860
- | ((
861
- node: ESTree.ImportNamespaceSpecifier & NodeParentExtension,
862
- ) => void)
863
- | undefined;
864
- ImportSpecifier?:
865
- | ((node: ESTree.ImportSpecifier & NodeParentExtension) => void)
866
- | undefined;
867
- "ImportSpecifier:exit"?:
868
- | ((node: ESTree.ImportSpecifier & NodeParentExtension) => void)
869
- | undefined;
870
- LabeledStatement?:
871
- | ((node: ESTree.LabeledStatement & NodeParentExtension) => void)
872
- | undefined;
873
- "LabeledStatement:exit"?:
874
- | ((node: ESTree.LabeledStatement & NodeParentExtension) => void)
875
- | undefined;
876
- Literal?:
877
- | ((node: ESTree.Literal & NodeParentExtension) => void)
878
- | undefined;
879
- "Literal:exit"?:
880
- | ((node: ESTree.Literal & NodeParentExtension) => void)
881
- | undefined;
882
- LogicalExpression?:
883
- | ((node: ESTree.LogicalExpression & NodeParentExtension) => void)
884
- | undefined;
885
- "LogicalExpression:exit"?:
886
- | ((node: ESTree.LogicalExpression & NodeParentExtension) => void)
887
- | undefined;
888
- MemberExpression?:
889
- | ((node: ESTree.MemberExpression & NodeParentExtension) => void)
890
- | undefined;
891
- "MemberExpression:exit"?:
892
- | ((node: ESTree.MemberExpression & NodeParentExtension) => void)
893
- | undefined;
894
- MetaProperty?:
895
- | ((node: ESTree.MetaProperty & NodeParentExtension) => void)
896
- | undefined;
897
- "MetaProperty:exit"?:
898
- | ((node: ESTree.MetaProperty & NodeParentExtension) => void)
899
- | undefined;
900
- MethodDefinition?:
901
- | ((node: ESTree.MethodDefinition & NodeParentExtension) => void)
902
- | undefined;
903
- "MethodDefinition:exit"?:
904
- | ((node: ESTree.MethodDefinition & NodeParentExtension) => void)
905
- | undefined;
906
- NewExpression?:
907
- | ((node: ESTree.NewExpression & NodeParentExtension) => void)
908
- | undefined;
909
- "NewExpression:exit"?:
910
- | ((node: ESTree.NewExpression & NodeParentExtension) => void)
911
- | undefined;
912
- ObjectExpression?:
913
- | ((node: ESTree.ObjectExpression & NodeParentExtension) => void)
914
- | undefined;
915
- "ObjectExpression:exit"?:
916
- | ((node: ESTree.ObjectExpression & NodeParentExtension) => void)
917
- | undefined;
918
- ObjectPattern?:
919
- | ((node: ESTree.ObjectPattern & NodeParentExtension) => void)
920
- | undefined;
921
- "ObjectPattern:exit"?:
922
- | ((node: ESTree.ObjectPattern & NodeParentExtension) => void)
923
- | undefined;
924
- PrivateIdentifier?:
925
- | ((node: ESTree.PrivateIdentifier & NodeParentExtension) => void)
926
- | undefined;
927
- "PrivateIdentifier:exit"?:
928
- | ((node: ESTree.PrivateIdentifier & NodeParentExtension) => void)
929
- | undefined;
930
- Program?: ((node: ESTree.Program) => void) | undefined;
931
- "Program:exit"?: ((node: ESTree.Program) => void) | undefined;
932
- Property?:
933
- | ((node: ESTree.Property & NodeParentExtension) => void)
934
- | undefined;
935
- "Property:exit"?:
936
- | ((node: ESTree.Property & NodeParentExtension) => void)
937
- | undefined;
938
- PropertyDefinition?:
939
- | ((node: ESTree.PropertyDefinition & NodeParentExtension) => void)
940
- | undefined;
941
- "PropertyDefinition:exit"?:
942
- | ((node: ESTree.PropertyDefinition & NodeParentExtension) => void)
943
- | undefined;
944
- RestElement?:
945
- | ((node: ESTree.RestElement & NodeParentExtension) => void)
946
- | undefined;
947
- "RestElement:exit"?:
948
- | ((node: ESTree.RestElement & NodeParentExtension) => void)
949
- | undefined;
950
- ReturnStatement?:
951
- | ((node: ESTree.ReturnStatement & NodeParentExtension) => void)
952
- | undefined;
953
- "ReturnStatement:exit"?:
954
- | ((node: ESTree.ReturnStatement & NodeParentExtension) => void)
955
- | undefined;
956
- SequenceExpression?:
957
- | ((node: ESTree.SequenceExpression & NodeParentExtension) => void)
958
- | undefined;
959
- "SequenceExpression:exit"?:
960
- | ((node: ESTree.SequenceExpression & NodeParentExtension) => void)
961
- | undefined;
962
- SpreadElement?:
963
- | ((node: ESTree.SpreadElement & NodeParentExtension) => void)
964
- | undefined;
965
- "SpreadElement:exit"?:
966
- | ((node: ESTree.SpreadElement & NodeParentExtension) => void)
967
- | undefined;
968
- StaticBlock?:
969
- | ((node: ESTree.StaticBlock & NodeParentExtension) => void)
970
- | undefined;
971
- "StaticBlock:exit"?:
972
- | ((node: ESTree.StaticBlock & NodeParentExtension) => void)
973
- | undefined;
974
- Super?:
975
- | ((node: ESTree.Super & NodeParentExtension) => void)
976
- | undefined;
977
- "Super:exit"?:
978
- | ((node: ESTree.Super & NodeParentExtension) => void)
979
- | undefined;
980
- SwitchCase?:
981
- | ((node: ESTree.SwitchCase & NodeParentExtension) => void)
982
- | undefined;
983
- "SwitchCase:exit"?:
984
- | ((node: ESTree.SwitchCase & NodeParentExtension) => void)
985
- | undefined;
986
- SwitchStatement?:
987
- | ((node: ESTree.SwitchStatement & NodeParentExtension) => void)
988
- | undefined;
989
- "SwitchStatement:exit"?:
990
- | ((node: ESTree.SwitchStatement & NodeParentExtension) => void)
991
- | undefined;
992
- TaggedTemplateExpression?:
993
- | ((
994
- node: ESTree.TaggedTemplateExpression & NodeParentExtension,
995
- ) => void)
996
- | undefined;
997
- "TaggedTemplateExpression:exit"?:
998
- | ((
999
- node: ESTree.TaggedTemplateExpression & NodeParentExtension,
1000
- ) => void)
1001
- | undefined;
1002
- TemplateElement?:
1003
- | ((node: ESTree.TemplateElement & NodeParentExtension) => void)
1004
- | undefined;
1005
- "TemplateElement:exit"?:
1006
- | ((node: ESTree.TemplateElement & NodeParentExtension) => void)
1007
- | undefined;
1008
- TemplateLiteral?:
1009
- | ((node: ESTree.TemplateLiteral & NodeParentExtension) => void)
1010
- | undefined;
1011
- "TemplateLiteral:exit"?:
1012
- | ((node: ESTree.TemplateLiteral & NodeParentExtension) => void)
1013
- | undefined;
1014
- ThisExpression?:
1015
- | ((node: ESTree.ThisExpression & NodeParentExtension) => void)
1016
- | undefined;
1017
- "ThisExpression:exit"?:
1018
- | ((node: ESTree.ThisExpression & NodeParentExtension) => void)
1019
- | undefined;
1020
- ThrowStatement?:
1021
- | ((node: ESTree.ThrowStatement & NodeParentExtension) => void)
1022
- | undefined;
1023
- "ThrowStatement:exit"?:
1024
- | ((node: ESTree.ThrowStatement & NodeParentExtension) => void)
1025
- | undefined;
1026
- TryStatement?:
1027
- | ((node: ESTree.TryStatement & NodeParentExtension) => void)
1028
- | undefined;
1029
- "TryStatement:exit"?:
1030
- | ((node: ESTree.TryStatement & NodeParentExtension) => void)
1031
- | undefined;
1032
- UnaryExpression?:
1033
- | ((node: ESTree.UnaryExpression & NodeParentExtension) => void)
1034
- | undefined;
1035
- "UnaryExpression:exit"?:
1036
- | ((node: ESTree.UnaryExpression & NodeParentExtension) => void)
1037
- | undefined;
1038
- UpdateExpression?:
1039
- | ((node: ESTree.UpdateExpression & NodeParentExtension) => void)
1040
- | undefined;
1041
- "UpdateExpression:exit"?:
1042
- | ((node: ESTree.UpdateExpression & NodeParentExtension) => void)
1043
- | undefined;
1044
- VariableDeclaration?:
1045
- | ((node: ESTree.VariableDeclaration & NodeParentExtension) => void)
1046
- | undefined;
1047
- "VariableDeclaration:exit"?:
1048
- | ((node: ESTree.VariableDeclaration & NodeParentExtension) => void)
1049
- | undefined;
1050
- VariableDeclarator?:
1051
- | ((node: ESTree.VariableDeclarator & NodeParentExtension) => void)
1052
- | undefined;
1053
- "VariableDeclarator:exit"?:
1054
- | ((node: ESTree.VariableDeclarator & NodeParentExtension) => void)
1055
- | undefined;
1056
- WhileStatement?:
1057
- | ((node: ESTree.WhileStatement & NodeParentExtension) => void)
1058
- | undefined;
1059
- "WhileStatement:exit"?:
1060
- | ((node: ESTree.WhileStatement & NodeParentExtension) => void)
1061
- | undefined;
1062
- WithStatement?:
1063
- | ((node: ESTree.WithStatement & NodeParentExtension) => void)
1064
- | undefined;
1065
- "WithStatement:exit"?:
1066
- | ((node: ESTree.WithStatement & NodeParentExtension) => void)
1067
- | undefined;
1068
- YieldExpression?:
1069
- | ((node: ESTree.YieldExpression & NodeParentExtension) => void)
1070
- | undefined;
1071
- "YieldExpression:exit"?:
1072
- | ((node: ESTree.YieldExpression & NodeParentExtension) => void)
1073
- | undefined;
1074
- }
691
+
692
+ interface NodeListener
693
+ extends WithExit<
694
+ {
695
+ [Node in Rule.Node as Node["type"]]?:
696
+ | ((node: Node) => void)
697
+ | undefined;
698
+ } & {
699
+ // A `Program` visitor's node type has no `parent` property.
700
+ Program?: ((node: AST.Program) => void) | undefined;
701
+ }
702
+ > {}
1075
703
 
1076
704
  interface NodeParentExtension {
1077
705
  parent: Node;
1078
706
  }
1079
- type Node = ESTree.Node & NodeParentExtension;
707
+
708
+ type Node =
709
+ | (AST.Program & { parent: null })
710
+ | (Exclude<ESTree.Node, ESTree.Program> & NodeParentExtension);
1080
711
 
1081
712
  interface RuleListener extends NodeListener {
1082
713
  onCodePathStart?(codePath: CodePath, node: Node): void;
@@ -1087,6 +718,16 @@ export namespace Rule {
1087
718
 
1088
719
  onCodePathSegmentEnd?(segment: CodePathSegment, node: Node): void;
1089
720
 
721
+ onUnreachableCodePathSegmentStart?(
722
+ segment: CodePathSegment,
723
+ node: Node,
724
+ ): void;
725
+
726
+ onUnreachableCodePathSegmentEnd?(
727
+ segment: CodePathSegment,
728
+ node: Node,
729
+ ): void;
730
+
1090
731
  onCodePathSegmentLoop?(
1091
732
  fromSegment: CodePathSegment,
1092
733
  toSegment: CodePathSegment,
@@ -1130,60 +771,7 @@ export namespace Rule {
1130
771
  reachable: boolean;
1131
772
  }
1132
773
 
1133
- interface RuleMetaData {
1134
- /** Properties often used for documentation generation and tooling. */
1135
- docs?:
1136
- | {
1137
- /** Provides a short description of the rule. Commonly used when generating lists of rules. */
1138
- description?: string | undefined;
1139
- /** Historically used by some plugins that divide rules into categories in their documentation. */
1140
- category?: string | undefined;
1141
- /** Historically used by some plugins to indicate a rule belongs in their `recommended` configuration. */
1142
- recommended?: boolean | undefined;
1143
- /** Specifies the URL at which the full documentation can be accessed. Code editors often use this to provide a helpful link on highlighted rule violations. */
1144
- url?: string | undefined;
1145
- }
1146
- | undefined;
1147
- /** Violation and suggestion messages. */
1148
- messages?: { [messageId: string]: string } | undefined;
1149
- /**
1150
- * Specifies if the `--fix` option on the command line automatically fixes problems reported by the rule.
1151
- * Mandatory for fixable rules.
1152
- */
1153
- fixable?: "code" | "whitespace" | undefined;
1154
- /**
1155
- * Specifies the [options](https://eslint.org/docs/latest/extend/custom-rules#options-schemas)
1156
- * so ESLint can prevent invalid [rule configurations](https://eslint.org/docs/latest/use/configure/rules#configuring-rules).
1157
- * Mandatory for rules with options.
1158
- */
1159
- schema?: JSONSchema4 | JSONSchema4[] | false | undefined;
1160
-
1161
- /** Any default options to be recursively merged on top of any user-provided options. */
1162
- defaultOptions?: unknown[];
1163
-
1164
- /** Indicates whether the rule has been deprecated or provides additional metadata about the deprecation. Omit if not deprecated. */
1165
- deprecated?: boolean | DeprecatedInfo | undefined;
1166
- /**
1167
- * @deprecated Use deprecated.replacedBy instead.
1168
- * The name of the rule(s) this rule was replaced by, if it was deprecated.
1169
- */
1170
- replacedBy?: readonly string[];
1171
-
1172
- /**
1173
- * Indicates the type of rule:
1174
- * - `"problem"` means the rule is identifying code that either will cause an error or may cause a confusing behavior. Developers should consider this a high priority to resolve.
1175
- * - `"suggestion"` means the rule is identifying something that could be done in a better way but no errors will occur if the code isn't changed.
1176
- * - `"layout"` means the rule cares primarily about whitespace, semicolons, commas, and parentheses,
1177
- * all the parts of the program that determine how the code looks rather than how it executes.
1178
- * These rules work on parts of the code that aren't specified in the AST.
1179
- */
1180
- type?: "problem" | "suggestion" | "layout" | undefined;
1181
- /**
1182
- * Specifies whether the rule can return suggestions (defaults to `false` if omitted).
1183
- * Mandatory for rules that provide suggestions.
1184
- */
1185
- hasSuggestions?: boolean | undefined;
1186
- }
774
+ type RuleMetaData = RulesMeta;
1187
775
 
1188
776
  interface RuleContext
1189
777
  extends CoreRuleContext<{
@@ -1194,66 +782,24 @@ export namespace Rule {
1194
782
  MessageIds: string;
1195
783
  }> {}
1196
784
 
1197
- type ReportFixer = (
1198
- fixer: RuleFixer,
1199
- ) => null | Fix | IterableIterator<Fix> | Fix[];
1200
-
1201
- interface ReportDescriptorOptionsBase {
1202
- data?: { [key: string]: string };
1203
-
1204
- fix?: null | ReportFixer;
1205
- }
1206
-
1207
- interface SuggestionReportOptions {
1208
- data?: { [key: string]: string };
1209
-
1210
- fix: ReportFixer;
1211
- }
1212
-
1213
- type SuggestionDescriptorMessage = { desc: string } | { messageId: string };
1214
- type SuggestionReportDescriptor = SuggestionDescriptorMessage &
1215
- SuggestionReportOptions;
1216
-
1217
- interface ReportDescriptorOptions extends ReportDescriptorOptionsBase {
1218
- suggest?: SuggestionReportDescriptor[] | null | undefined;
1219
- }
1220
-
1221
- type ReportDescriptor = ReportDescriptorMessage &
1222
- ReportDescriptorLocation &
1223
- ReportDescriptorOptions;
1224
- type ReportDescriptorMessage = { message: string } | { messageId: string };
1225
- type ReportDescriptorLocation =
1226
- | { node: ESTree.Node }
1227
- | { loc: AST.SourceLocation | { line: number; column: number } };
1228
-
1229
- interface RuleFixer {
1230
- insertTextAfter(
1231
- nodeOrToken: ESTree.Node | AST.Token,
1232
- text: string,
1233
- ): Fix;
785
+ type ReportFixer = CoreRuleFixer;
1234
786
 
1235
- insertTextAfterRange(range: AST.Range, text: string): Fix;
787
+ /** @deprecated Use `ReportDescriptorOptions` instead. */
788
+ type ReportDescriptorOptionsBase = ViolationReportBase;
1236
789
 
1237
- insertTextBefore(
1238
- nodeOrToken: ESTree.Node | AST.Token,
1239
- text: string,
1240
- ): Fix;
790
+ type SuggestionReportOptions = SuggestedEditBase;
791
+ type SuggestionDescriptorMessage = SuggestionMessage;
792
+ type SuggestionReportDescriptor = SuggestedEdit;
1241
793
 
1242
- insertTextBeforeRange(range: AST.Range, text: string): Fix;
794
+ // redundant with ReportDescriptorOptionsBase but kept for clarity
795
+ type ReportDescriptorOptions = ViolationReportBase;
1243
796
 
1244
- remove(nodeOrToken: ESTree.Node | AST.Token): Fix;
797
+ type ReportDescriptor = ViolationReport<ESTree.Node>;
798
+ type ReportDescriptorMessage = ViolationMessage;
799
+ type ReportDescriptorLocation = ViolationLocation<ESTree.Node>;
1245
800
 
1246
- removeRange(range: AST.Range): Fix;
1247
-
1248
- replaceText(nodeOrToken: ESTree.Node | AST.Token, text: string): Fix;
1249
-
1250
- replaceTextRange(range: AST.Range, text: string): Fix;
1251
- }
1252
-
1253
- interface Fix {
1254
- range: AST.Range;
1255
- text: string;
1256
- }
801
+ type RuleFixer = RuleTextEditor<ESTree.Node | AST.Token>;
802
+ type Fix = RuleTextEdit;
1257
803
  }
1258
804
 
1259
805
  export type JSRuleDefinitionTypeOptions = CustomRuleTypeDefinitions;
@@ -1264,7 +810,7 @@ export type JSRuleDefinition<
1264
810
  {
1265
811
  LangOptions: Linter.LanguageOptions;
1266
812
  Code: SourceCode;
1267
- Visitor: Rule.NodeListener;
813
+ Visitor: Rule.RuleListener;
1268
814
  Node: JSSyntaxElement;
1269
815
  },
1270
816
  Options
@@ -1329,21 +875,21 @@ export namespace Linter {
1329
875
  *
1330
876
  * @see [Rule Severities](https://eslint.org/docs/latest/use/configure/rules#rule-severities)
1331
877
  */
1332
- type Severity = 0 | 1 | 2;
878
+ type Severity = SeverityLevel;
1333
879
 
1334
880
  /**
1335
881
  * The human readable severity level for a rule.
1336
882
  *
1337
883
  * @see [Rule Severities](https://eslint.org/docs/latest/use/configure/rules#rule-severities)
1338
884
  */
1339
- type StringSeverity = "off" | "warn" | "error";
885
+ type StringSeverity = SeverityName;
1340
886
 
1341
887
  /**
1342
888
  * The numeric or human readable severity level for a rule.
1343
889
  *
1344
890
  * @see [Rule Severities](https://eslint.org/docs/latest/use/configure/rules#rule-severities)
1345
891
  */
1346
- type RuleSeverity = Severity | StringSeverity;
892
+ type RuleSeverity = CoreSeverity;
1347
893
 
1348
894
  /**
1349
895
  * An array containing the rule severity level, followed by the rule options.
@@ -1360,167 +906,44 @@ export namespace Linter {
1360
906
  *
1361
907
  * @see [Rules](https://eslint.org/docs/latest/use/configure/rules)
1362
908
  */
1363
- type RuleEntry<Options extends any[] = any[]> =
1364
- | RuleSeverity
1365
- | RuleSeverityAndOptions<Options>;
909
+ type RuleEntry<Options extends any[] = any[]> = RuleConfig<Options>;
1366
910
 
1367
911
  /**
1368
912
  * The rules config object is a key/value map of rule names and their severity and options.
1369
913
  */
1370
- interface RulesRecord {
1371
- [rule: string]: RuleEntry;
1372
- }
914
+ type RulesRecord = RulesConfig;
1373
915
 
1374
916
  /**
1375
917
  * A configuration object that may have a `rules` block.
1376
918
  */
1377
- interface HasRules<Rules extends RulesRecord = RulesRecord> {
1378
- rules?: Partial<Rules> | undefined;
1379
- }
919
+ type HasRules<Rules extends RulesConfig = RulesConfig> =
920
+ CoreHasRules<Rules>;
1380
921
 
1381
922
  /**
1382
923
  * The ECMAScript version of the code being linted.
1383
924
  */
1384
- type EcmaVersion =
1385
- | 3
1386
- | 5
1387
- | 6
1388
- | 7
1389
- | 8
1390
- | 9
1391
- | 10
1392
- | 11
1393
- | 12
1394
- | 13
1395
- | 14
1396
- | 15
1397
- | 16
1398
- | 17
1399
- | 2015
1400
- | 2016
1401
- | 2017
1402
- | 2018
1403
- | 2019
1404
- | 2020
1405
- | 2021
1406
- | 2022
1407
- | 2023
1408
- | 2024
1409
- | 2025
1410
- | 2026
1411
- | "latest";
925
+ type EcmaVersion = CoreEcmaVersion;
1412
926
 
1413
927
  /**
1414
928
  * The type of JavaScript source code.
1415
929
  */
1416
- type SourceType = "script" | "module" | "commonjs";
930
+ type SourceType = JavaScriptSourceType;
1417
931
 
1418
932
  /**
1419
933
  * ESLint legacy configuration.
1420
934
  *
1421
935
  * @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
1422
936
  */
1423
- interface BaseConfig<
1424
- Rules extends RulesRecord = RulesRecord,
1425
- OverrideRules extends RulesRecord = Rules,
1426
- > extends HasRules<Rules> {
1427
- $schema?: string | undefined;
1428
-
1429
- /**
1430
- * An environment provides predefined global variables.
1431
- *
1432
- * @see [Environments](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-environments)
1433
- */
1434
- env?: { [name: string]: boolean } | undefined;
1435
-
1436
- /**
1437
- * Extending configuration files.
1438
- *
1439
- * @see [Extends](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#extending-configuration-files)
1440
- */
1441
- extends?: string | string[] | undefined;
1442
-
1443
- /**
1444
- * Specifying globals.
1445
- *
1446
- * @see [Globals](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-globals)
1447
- */
1448
- globals?: Linter.Globals | undefined;
1449
-
1450
- /**
1451
- * Disable processing of inline comments.
1452
- *
1453
- * @see [Disabling Inline Comments](https://eslint.org/docs/latest/use/configure/rules-deprecated#disabling-inline-comments)
1454
- */
1455
- noInlineConfig?: boolean | undefined;
1456
-
1457
- /**
1458
- * Overrides can be used to use a differing configuration for matching sub-directories and files.
1459
- *
1460
- * @see [How do overrides work](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#how-do-overrides-work)
1461
- */
1462
- overrides?: Array<ConfigOverride<OverrideRules>> | undefined;
1463
-
1464
- /**
1465
- * Parser.
1466
- *
1467
- * @see [Working with Custom Parsers](https://eslint.org/docs/latest/extend/custom-parsers)
1468
- * @see [Specifying Parser](https://eslint.org/docs/latest/use/configure/parser-deprecated)
1469
- */
1470
- parser?: string | undefined;
1471
-
1472
- /**
1473
- * Parser options.
1474
- *
1475
- * @see [Working with Custom Parsers](https://eslint.org/docs/latest/extend/custom-parsers)
1476
- * @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options)
1477
- */
1478
- parserOptions?: ParserOptions | undefined;
1479
-
1480
- /**
1481
- * Which third-party plugins define additional rules, environments, configs, etc. for ESLint to use.
1482
- *
1483
- * @see [Configuring Plugins](https://eslint.org/docs/latest/use/configure/plugins-deprecated#configure-plugins)
1484
- */
1485
- plugins?: string[] | undefined;
1486
-
1487
- /**
1488
- * Specifying processor.
1489
- *
1490
- * @see [processor](https://eslint.org/docs/latest/use/configure/plugins-deprecated#specify-a-processor)
1491
- */
1492
- processor?: string | undefined;
1493
-
1494
- /**
1495
- * Report unused eslint-disable comments as warning.
1496
- *
1497
- * @see [Report unused eslint-disable comments](https://eslint.org/docs/latest/use/configure/rules-deprecated#report-unused-eslint-disable-comments)
1498
- */
1499
- reportUnusedDisableDirectives?: boolean | undefined;
1500
-
1501
- /**
1502
- * Settings.
1503
- *
1504
- * @see [Settings](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#adding-shared-settings)
1505
- */
1506
- settings?: { [name: string]: any } | undefined;
1507
- }
937
+ type BaseConfig<
938
+ Rules extends RulesConfig = RulesConfig,
939
+ OverrideRules extends RulesConfig = Rules,
940
+ > = CoreBaseConfig<Rules, OverrideRules>;
1508
941
 
1509
942
  /**
1510
943
  * The overwrites that apply more differing configuration to specific files or directories.
1511
944
  */
1512
- interface ConfigOverride<Rules extends RulesRecord = RulesRecord>
1513
- extends BaseConfig<Rules> {
1514
- /**
1515
- * The glob patterns for excluded files.
1516
- */
1517
- excludedFiles?: string | string[] | undefined;
1518
-
1519
- /**
1520
- * The glob patterns for target files.
1521
- */
1522
- files: string | string[];
1523
- }
945
+ type ConfigOverride<Rules extends RulesConfig = RulesConfig> =
946
+ CoreConfigOverride<Rules>;
1524
947
 
1525
948
  /**
1526
949
  * ESLint legacy configuration.
@@ -1528,78 +951,21 @@ export namespace Linter {
1528
951
  * @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
1529
952
  */
1530
953
  // https://github.com/eslint/eslint/blob/v8.57.0/conf/config-schema.js
1531
- interface LegacyConfig<
1532
- Rules extends RulesRecord = RulesRecord,
1533
- OverrideRules extends RulesRecord = Rules,
1534
- > extends BaseConfig<Rules, OverrideRules> {
1535
- /**
1536
- * Tell ESLint to ignore specific files and directories.
1537
- *
1538
- * @see [Ignore Patterns](https://eslint.org/docs/latest/use/configure/ignore-deprecated#ignorepatterns-in-config-files)
1539
- */
1540
- ignorePatterns?: string | string[] | undefined;
1541
-
1542
- /**
1543
- * @see [Using Configuration Files](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#using-configuration-files)
1544
- */
1545
- root?: boolean | undefined;
1546
- }
954
+ type LegacyConfig<
955
+ Rules extends RulesConfig = RulesConfig,
956
+ OverrideRules extends RulesConfig = Rules,
957
+ > = LegacyConfigObject<Rules, OverrideRules>;
1547
958
 
1548
959
  /**
1549
960
  * Parser options.
1550
961
  *
1551
962
  * @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options)
1552
963
  */
1553
- interface ParserOptions {
1554
- /**
1555
- * Allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
1556
- *
1557
- * @default false
1558
- */
1559
- allowReserved?: boolean | undefined;
1560
-
1561
- /**
1562
- * Accepts any valid ECMAScript version number or `'latest'`:
1563
- *
1564
- * - A version: es3, es5, es6, es7, es8, es9, es10, es11, es12, es13, es14, ..., or
1565
- * - A year: es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, ..., or
1566
- * - `'latest'`
1567
- *
1568
- * When it's a version or a year, the value must be a number - so do not include the `es` prefix.
1569
- *
1570
- * Specifies the version of ECMAScript syntax you want to use. This is used by the parser to determine how to perform scope analysis, and it affects the default
1571
- *
1572
- * @default 5
1573
- */
1574
- ecmaVersion?: EcmaVersion | undefined;
1575
-
1576
- /**
1577
- * The type of JavaScript source code. Possible values are "script" for
1578
- * traditional script files, "module" for ECMAScript modules (ESM), and
1579
- * "commonjs" for CommonJS files.
1580
- *
1581
- * @default 'script'
1582
- *
1583
- * @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
1584
- */
1585
- sourceType?: SourceType | undefined;
1586
-
1587
- /**
1588
- * An object indicating which additional language features you'd like to use.
1589
- *
1590
- * @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
1591
- */
1592
- ecmaFeatures?:
1593
- | {
1594
- globalReturn?: boolean | undefined;
1595
- impliedStrict?: boolean | undefined;
1596
- jsx?: boolean | undefined;
1597
- [key: string]: any;
1598
- }
1599
- | undefined;
1600
- [key: string]: any;
1601
- }
964
+ type ParserOptions = JavaScriptParserOptionsConfig;
1602
965
 
966
+ /**
967
+ * Options used for linting code with `Linter#verify` and `Linter#verifyAndFix`.
968
+ */
1603
969
  interface LintOptions {
1604
970
  filename?: string | undefined;
1605
971
  preprocess?: ((code: string) => string[]) | undefined;
@@ -1614,57 +980,8 @@ export namespace Linter {
1614
980
  reportUnusedDisableDirectives?: boolean | undefined;
1615
981
  }
1616
982
 
1617
- interface LintSuggestion {
1618
- /** A short description. */
1619
- desc: string;
1620
-
1621
- /** Fix result info. */
1622
- fix: Rule.Fix;
1623
-
1624
- /** Id referencing a message for the description. */
1625
- messageId?: string | undefined;
1626
- }
1627
-
1628
- interface LintMessage {
1629
- /** The 1-based column number. */
1630
- column: number;
1631
-
1632
- /** The 1-based line number. */
1633
- line: number;
1634
-
1635
- /** The 1-based column number of the end location. */
1636
- endColumn?: number | undefined;
1637
-
1638
- /** The 1-based line number of the end location. */
1639
- endLine?: number | undefined;
1640
-
1641
- /** The ID of the rule which makes this message. */
1642
- ruleId: string | null;
1643
-
1644
- /** The reported message. */
1645
- message: string;
1646
-
1647
- /** The ID of the message in the rule's meta. */
1648
- messageId?: string | undefined;
1649
-
1650
- /**
1651
- * Type of node.
1652
- * @deprecated `nodeType` is deprecated and will be removed in the next major version.
1653
- */
1654
- nodeType?: string | undefined;
1655
-
1656
- /** If `true` then this is a fatal error. */
1657
- fatal?: true | undefined;
1658
-
1659
- /** The severity of this message. */
1660
- severity: Exclude<Severity, 0>;
1661
-
1662
- /** Information for autofix. */
1663
- fix?: Rule.Fix | undefined;
1664
-
1665
- /** Information for suggestions. */
1666
- suggestions?: LintSuggestion[] | undefined;
1667
- }
983
+ type LintSuggestion = CoreLintSuggestion;
984
+ type LintMessage = CoreLintMessage;
1668
985
 
1669
986
  interface LintSuppression {
1670
987
  kind: string;
@@ -1725,114 +1042,19 @@ export namespace Linter {
1725
1042
  visitorKeys?: SourceCode.VisitorKeys | undefined;
1726
1043
  }
1727
1044
 
1728
- interface ProcessorFile {
1729
- text: string;
1730
- filename: string;
1731
- }
1045
+ type ProcessorFile = CoreProcessorFile;
1732
1046
 
1733
1047
  // https://eslint.org/docs/latest/extend/plugins#processors-in-plugins
1734
- interface Processor<
1735
- T extends string | ProcessorFile = string | ProcessorFile,
1736
- > extends ESLint.ObjectMetaProperties {
1737
- /** If `true` then it means the processor supports autofix. */
1738
- supportsAutofix?: boolean | undefined;
1739
-
1740
- /** The function to extract code blocks. */
1741
- preprocess?(text: string, filename: string): T[];
1742
-
1743
- /** The function to merge messages. */
1744
- postprocess?(
1745
- messages: LintMessage[][],
1746
- filename: string,
1747
- ): LintMessage[];
1748
- }
1749
-
1750
- interface Config<Rules extends RulesRecord = RulesRecord> {
1751
- /**
1752
- * An string to identify the configuration object. Used in error messages and
1753
- * inspection tools.
1754
- */
1755
- name?: string;
1048
+ type Processor<T extends string | ProcessorFile = string | ProcessorFile> =
1049
+ CoreProcessor<T>;
1756
1050
 
1757
- /**
1758
- * Path to the directory where the configuration object should apply.
1759
- * `files` and `ignores` patterns in the configuration object are
1760
- * interpreted as relative to this path.
1761
- */
1762
- basePath?: string;
1763
-
1764
- /**
1765
- * An array of glob patterns indicating the files that the configuration
1766
- * object should apply to. If not specified, the configuration object applies
1767
- * to all files
1768
- */
1769
- files?: Array<string | string[]>;
1770
-
1771
- /**
1772
- * An array of glob patterns indicating the files that the configuration
1773
- * object should not apply to. If not specified, the configuration object
1774
- * applies to all files matched by files
1775
- */
1776
- ignores?: string[];
1777
-
1778
- /**
1779
- * The name of the language used for linting. This is used to determine the
1780
- * parser and other language-specific settings.
1781
- * @since 9.7.0
1782
- */
1783
- language?: string;
1784
-
1785
- /**
1786
- * An object containing settings related to how JavaScript is configured for
1787
- * linting.
1788
- */
1789
- languageOptions?: LanguageOptions;
1790
-
1791
- /**
1792
- * An object containing settings related to the linting process
1793
- */
1794
- linterOptions?: LinterOptions;
1795
-
1796
- /**
1797
- * Either an object containing preprocess() and postprocess() methods or a
1798
- * string indicating the name of a processor inside of a plugin
1799
- * (i.e., "pluginName/processorName").
1800
- */
1801
- processor?: string | Processor;
1802
-
1803
- /**
1804
- * An object containing a name-value mapping of plugin names to plugin objects.
1805
- * When files is specified, these plugins are only available to the matching files.
1806
- */
1807
- plugins?: Record<string, ESLint.Plugin>;
1808
-
1809
- /**
1810
- * An object containing the configured rules. When files or ignores are specified,
1811
- * these rule configurations are only available to the matching files.
1812
- */
1813
- rules?: Partial<Rules>;
1814
-
1815
- /**
1816
- * An object containing name-value pairs of information that should be
1817
- * available to all rules.
1818
- */
1819
- settings?: Record<string, unknown>;
1820
- }
1051
+ type Config<Rules extends RulesConfig = RulesConfig> = ConfigObject<Rules>;
1821
1052
 
1822
1053
  /** @deprecated Use `Config` instead of `FlatConfig` */
1823
- type FlatConfig<Rules extends RulesRecord = RulesRecord> = Config<Rules>;
1824
-
1825
- type GlobalConf =
1826
- | boolean
1827
- | "off"
1828
- | "readable"
1829
- | "readonly"
1830
- | "writable"
1831
- | "writeable";
1832
-
1833
- interface Globals {
1834
- [name: string]: GlobalConf;
1835
- }
1054
+ type FlatConfig<Rules extends RulesConfig = RulesConfig> = Config<Rules>;
1055
+
1056
+ type GlobalConf = GlobalAccess;
1057
+ type Globals = GlobalsConfig;
1836
1058
 
1837
1059
  interface LanguageOptions extends GenericLanguageOptions {
1838
1060
  /**
@@ -1869,24 +1091,7 @@ export namespace Linter {
1869
1091
  parserOptions?: Linter.ParserOptions | undefined;
1870
1092
  }
1871
1093
 
1872
- interface LinterOptions {
1873
- /**
1874
- * A boolean value indicating if inline configuration is allowed.
1875
- */
1876
- noInlineConfig?: boolean;
1877
-
1878
- /**
1879
- * A severity value indicating if and how unused disable directives should be
1880
- * tracked and reported.
1881
- */
1882
- reportUnusedDisableDirectives?: Severity | StringSeverity | boolean;
1883
-
1884
- /**
1885
- * A severity value indicating if and how unused inline configs should be
1886
- * tracked and reported.
1887
- */
1888
- reportUnusedInlineConfigs?: Severity | StringSeverity;
1889
- }
1094
+ type LinterOptions = LinterOptionsConfig;
1890
1095
 
1891
1096
  /**
1892
1097
  * Performance statistics.
@@ -1977,45 +1182,14 @@ export class ESLint {
1977
1182
  }
1978
1183
 
1979
1184
  export namespace ESLint {
1980
- type ConfigData<Rules extends Linter.RulesRecord = Linter.RulesRecord> =
1981
- Omit<Linter.LegacyConfig<Rules>, "$schema">;
1982
-
1983
- interface Environment {
1984
- /** The definition of global variables. */
1985
- globals?: Linter.Globals | undefined;
1986
-
1987
- /** The parser options that will be enabled under this environment. */
1988
- parserOptions?: Linter.ParserOptions | undefined;
1989
- }
1990
-
1991
- interface ObjectMetaProperties {
1992
- /** @deprecated Use `meta.name` instead. */
1993
- name?: string | undefined;
1994
-
1995
- /** @deprecated Use `meta.version` instead. */
1996
- version?: string | undefined;
1997
-
1998
- meta?: {
1999
- name?: string | undefined;
2000
- version?: string | undefined;
2001
- };
2002
- }
2003
-
2004
- interface Plugin extends ObjectMetaProperties {
2005
- meta?: ObjectMetaProperties["meta"] & {
2006
- namespace?: string | undefined;
2007
- };
2008
- configs?:
2009
- | Record<
2010
- string,
2011
- Linter.LegacyConfig | Linter.Config | Linter.Config[]
2012
- >
2013
- | undefined;
2014
- environments?: Record<string, Environment> | undefined;
2015
- languages?: Record<string, Language> | undefined;
2016
- processors?: Record<string, Linter.Processor> | undefined;
2017
- rules?: Record<string, RuleDefinition> | undefined;
2018
- }
1185
+ type ConfigData<Rules extends Linter.RulesRecord = RulesConfig> = Omit<
1186
+ Linter.LegacyConfig<Rules>,
1187
+ "$schema"
1188
+ >;
1189
+
1190
+ type Environment = EnvironmentConfig;
1191
+ type ObjectMetaProperties = CoreObjectMetaProperties;
1192
+ type Plugin = CorePlugin;
2019
1193
 
2020
1194
  type FixType = "directive" | "problem" | "suggestion" | "layout";
2021
1195