@@ -33,7 +33,6 @@ import type {
3333 LanguageOptions as GenericLanguageOptions ,
3434 RuleContext as CoreRuleContext ,
3535 RuleDefinition ,
36- RuleVisitor ,
3736 SourceRange ,
3837 TextSourceCode ,
3938 TraversalStep ,
@@ -56,8 +55,22 @@ import type {
5655 ProcessorFile as CoreProcessorFile ,
5756 JavaScriptParserOptionsConfig ,
5857 RulesMeta ,
58+ RuleConfig ,
5959 RuleTextEditor ,
6060 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 ,
6174} from "@eslint/core" ;
6275import { LegacyESLint } from "./use-at-your-own-risk.js" ;
6376
@@ -769,37 +782,21 @@ export namespace Rule {
769782 MessageIds : string ;
770783 } > { }
771784
772- type ReportFixer = (
773- fixer : RuleFixer ,
774- ) => null | Fix | IterableIterator < Fix > | Fix [ ] ;
785+ type ReportFixer = CoreRuleFixer ;
775786
776- interface ReportDescriptorOptionsBase {
777- data ?: { [ key : string ] : string } ;
787+ /** @deprecated Use `ReportDescriptorOptions` instead. */
788+ type ReportDescriptorOptionsBase = ViolationReportBase ;
778789
779- fix ?: null | ReportFixer ;
780- }
790+ type SuggestionReportOptions = SuggestedEditBase ;
791+ type SuggestionDescriptorMessage = SuggestionMessage ;
792+ type SuggestionReportDescriptor = SuggestedEdit ;
781793
782- interface SuggestionReportOptions {
783- data ?: { [ key : string ] : string } ;
794+ // redundant with ReportDescriptorOptionsBase but kept for clarity
795+ type ReportDescriptorOptions = ViolationReportBase ;
784796
785- fix : ReportFixer ;
786- }
787-
788- type SuggestionDescriptorMessage = { desc : string } | { messageId : string } ;
789- type SuggestionReportDescriptor = SuggestionDescriptorMessage &
790- SuggestionReportOptions ;
791-
792- interface ReportDescriptorOptions extends ReportDescriptorOptionsBase {
793- suggest ?: SuggestionReportDescriptor [ ] | null | undefined ;
794- }
795-
796- type ReportDescriptor = ReportDescriptorMessage &
797- ReportDescriptorLocation &
798- ReportDescriptorOptions ;
799- type ReportDescriptorMessage = { message : string } | { messageId : string } ;
800- type ReportDescriptorLocation =
801- | { node : ESTree . Node }
802- | { loc : AST . SourceLocation | { line : number ; column : number } } ;
797+ type ReportDescriptor = ViolationReport < ESTree . Node > ;
798+ type ReportDescriptorMessage = ViolationMessage ;
799+ type ReportDescriptorLocation = ViolationLocation < ESTree . Node > ;
803800
804801 type RuleFixer = RuleTextEditor < ESTree . Node | AST . Token > ;
805802 type Fix = RuleTextEdit ;
@@ -909,9 +906,7 @@ export namespace Linter {
909906 *
910907 * @see [Rules](https://eslint.org/docs/latest/use/configure/rules)
911908 */
912- type RuleEntry < Options extends any [ ] = any [ ] > =
913- | RuleSeverity
914- | RuleSeverityAndOptions < Options > ;
909+ type RuleEntry < Options extends any [ ] = any [ ] > = RuleConfig < Options > ;
915910
916911 /**
917912 * The rules config object is a key/value map of rule names and their severity and options.
@@ -921,9 +916,8 @@ export namespace Linter {
921916 /**
922917 * A configuration object that may have a `rules` block.
923918 */
924- interface HasRules < Rules extends RulesConfig = RulesConfig > {
925- rules ?: Partial < Rules > | undefined ;
926- }
919+ type HasRules < Rules extends RulesConfig = RulesConfig > =
920+ CoreHasRules < Rules > ;
927921
928922 /**
929923 * The ECMAScript version of the code being linted.
@@ -933,99 +927,17 @@ export namespace Linter {
933927 /**
934928 * The type of JavaScript source code.
935929 */
936- // TODO: Refactor to JavaScriptSourceType when exported from @eslint /core.
937- type SourceType = "script" | "module" | "commonjs" ;
930+ type SourceType = JavaScriptSourceType ;
938931
939932 /**
940933 * ESLint legacy configuration.
941934 *
942935 * @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
943936 */
944- interface BaseConfig <
937+ type BaseConfig <
945938 Rules extends RulesConfig = RulesConfig ,
946939 OverrideRules extends RulesConfig = Rules ,
947- > extends HasRules < Rules > {
948- $schema ?: string | undefined ;
949-
950- /**
951- * An environment provides predefined global variables.
952- *
953- * @see [Environments](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-environments)
954- */
955- env ?: { [ name : string ] : boolean } | undefined ;
956-
957- /**
958- * Extending configuration files.
959- *
960- * @see [Extends](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#extending-configuration-files)
961- */
962- extends ?: string | string [ ] | undefined ;
963-
964- /**
965- * Specifying globals.
966- *
967- * @see [Globals](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-globals)
968- */
969- globals ?: Linter . Globals | undefined ;
970-
971- /**
972- * Disable processing of inline comments.
973- *
974- * @see [Disabling Inline Comments](https://eslint.org/docs/latest/use/configure/rules-deprecated#disabling-inline-comments)
975- */
976- noInlineConfig ?: boolean | undefined ;
977-
978- /**
979- * Overrides can be used to use a differing configuration for matching sub-directories and files.
980- *
981- * @see [How do overrides work](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#how-do-overrides-work)
982- */
983- overrides ?: Array < ConfigOverride < OverrideRules > > | undefined ;
984-
985- /**
986- * Parser.
987- *
988- * @see [Working with Custom Parsers](https://eslint.org/docs/latest/extend/custom-parsers)
989- * @see [Specifying Parser](https://eslint.org/docs/latest/use/configure/parser-deprecated)
990- */
991- parser ?: string | undefined ;
992-
993- /**
994- * Parser options.
995- *
996- * @see [Working with Custom Parsers](https://eslint.org/docs/latest/extend/custom-parsers)
997- * @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options)
998- */
999- parserOptions ?: JavaScriptParserOptionsConfig | undefined ;
1000-
1001- /**
1002- * Which third-party plugins define additional rules, environments, configs, etc. for ESLint to use.
1003- *
1004- * @see [Configuring Plugins](https://eslint.org/docs/latest/use/configure/plugins-deprecated#configure-plugins)
1005- */
1006- plugins ?: string [ ] | undefined ;
1007-
1008- /**
1009- * Specifying processor.
1010- *
1011- * @see [processor](https://eslint.org/docs/latest/use/configure/plugins-deprecated#specify-a-processor)
1012- */
1013- processor ?: string | undefined ;
1014-
1015- /**
1016- * Report unused eslint-disable comments as warning.
1017- *
1018- * @see [Report unused eslint-disable comments](https://eslint.org/docs/latest/use/configure/rules-deprecated#report-unused-eslint-disable-comments)
1019- */
1020- reportUnusedDisableDirectives ?: boolean | undefined ;
1021-
1022- /**
1023- * Settings.
1024- *
1025- * @see [Settings](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#adding-shared-settings)
1026- */
1027- settings ?: { [ name : string ] : any } | undefined ;
1028- }
940+ > = CoreBaseConfig < Rules , OverrideRules > ;
1029941
1030942 /**
1031943 * The overwrites that apply more differing configuration to specific files or directories.
@@ -1068,18 +980,7 @@ export namespace Linter {
1068980 reportUnusedDisableDirectives ?: boolean | undefined ;
1069981 }
1070982
1071- // TODO: Once exported from @eslint /core, remove this and use that instead
1072- interface LintSuggestion {
1073- /** A short description. */
1074- desc : string ;
1075-
1076- /** Fix result info. */
1077- fix : Rule . Fix ;
1078-
1079- /** Id referencing a message for the description. */
1080- messageId ?: string | undefined ;
1081- }
1082-
983+ type LintSuggestion = CoreLintSuggestion ;
1083984 type LintMessage = CoreLintMessage ;
1084985
1085986 interface LintSuppression {
0 commit comments