@@ -35,6 +35,7 @@ import {
35
35
Scope ,
36
36
SourceCode ,
37
37
} from "eslint" ;
38
+ import { defineConfig , globalIgnores } from "eslint/config" ;
38
39
import { ESLintRules } from "eslint/rules" ;
39
40
import { Linter as ESLinter } from "eslint/universal" ;
40
41
import {
@@ -530,6 +531,68 @@ rule = {
530
531
} ,
531
532
meta : { deprecated : true , replacedBy : [ "other-rule-name" ] } ,
532
533
} ;
534
+ rule = {
535
+ create ( context ) {
536
+ return { } ;
537
+ } ,
538
+ meta : { deprecated : { message : "message" , url : "https://example.com" } } ,
539
+ } ;
540
+ rule = {
541
+ create ( context ) {
542
+ return { } ;
543
+ } ,
544
+ meta : { deprecated : { availableUntil : "10.0.0" } } ,
545
+ } ;
546
+ rule = {
547
+ create ( context ) {
548
+ return { } ;
549
+ } ,
550
+ meta : { deprecated : { availableUntil : null } } ,
551
+ } ;
552
+ rule = {
553
+ create ( context ) {
554
+ return { } ;
555
+ } ,
556
+ meta : { deprecated : { deprecatedSince : "9.0.0" } } ,
557
+ } ;
558
+ rule = {
559
+ create ( context ) {
560
+ return { } ;
561
+ } ,
562
+ meta : { deprecated : { replacedBy : [ ] } } ,
563
+ } ;
564
+ rule = {
565
+ create ( context ) {
566
+ return { } ;
567
+ } ,
568
+ meta : {
569
+ deprecated : {
570
+ replacedBy : [ { message : "message" , url : "https://example.com" } ] ,
571
+ } ,
572
+ } ,
573
+ } ;
574
+ rule = {
575
+ create ( context ) {
576
+ return { } ;
577
+ } ,
578
+ meta : {
579
+ deprecated : {
580
+ replacedBy : [ { plugin : { name : "eslint-plugin-example" } } ] ,
581
+ } ,
582
+ } ,
583
+ } ;
584
+ rule = {
585
+ create ( context ) {
586
+ return { } ;
587
+ } ,
588
+ meta : {
589
+ deprecated : {
590
+ replacedBy : [
591
+ { rule : { name : "rule-id" , url : "https://example.com" } } ,
592
+ ] ,
593
+ } ,
594
+ } ,
595
+ } ;
533
596
rule = {
534
597
create ( context ) {
535
598
return { } ;
@@ -552,7 +615,7 @@ rule = {
552
615
} ;
553
616
554
617
rule = {
555
- create ( context ) {
618
+ create ( context : Rule . RuleContext ) {
556
619
context . getAncestors ( ) ;
557
620
558
621
context . getDeclaredVariables ( AST ) ;
@@ -569,9 +632,15 @@ rule = {
569
632
570
633
context . getCwd ( ) ;
571
634
635
+ context . languageOptions ;
636
+ context . languageOptions
637
+ . ecmaVersion satisfies Linter . LanguageOptions [ "ecmaVersion" ] ;
638
+
572
639
context . sourceCode ;
640
+ context . sourceCode . getLocFromIndex ( 42 ) ;
573
641
574
642
context . getSourceCode ( ) ;
643
+ context . getSourceCode ( ) . getLocFromIndex ( 42 ) ;
575
644
576
645
context . getScope ( ) ;
577
646
@@ -583,8 +652,14 @@ rule = {
583
652
584
653
context . markVariableAsUsed ( "foo" ) ;
585
654
655
+ // @ts -expect-error wrong `node` type
656
+ context . report ( { message : "foo" , node : { } } ) ;
657
+
586
658
context . report ( { message : "foo" , node : AST } ) ;
587
- context . report ( { message : "foo" , loc : { line : 0 , column : 0 } } ) ;
659
+ context . report ( {
660
+ message : "foo" ,
661
+ loc : { start : { line : 0 , column : 0 } , end : { line : 1 , column : 1 } } ,
662
+ } ) ;
588
663
context . report ( { message : "foo" , node : AST , data : { foo : "bar" } } ) ;
589
664
context . report ( { message : "foo" , node : AST , fix : ( ) => null } ) ;
590
665
context . report ( {
@@ -661,6 +736,8 @@ rule = {
661
736
] ,
662
737
} ) ;
663
738
739
+ ( violation : Rule . ReportDescriptor ) => context . report ( violation ) ;
740
+
664
741
return {
665
742
onCodePathStart ( codePath , node ) {
666
743
const origin : Rule . CodePathOrigin = codePath . origin ;
@@ -1935,3 +2012,32 @@ FlatESLint; // $ExpectType typeof ESLint
1935
2012
shouldUseFlatConfig ( ) ; // $ExpectType Promise<boolean>
1936
2013
1937
2014
// #endregion
2015
+
2016
+ // #region defineConfig
2017
+
2018
+ defineConfig ( [
2019
+ {
2020
+ files : [ "*.js" ] ,
2021
+ rules : {
2022
+ "no-console" : "error" ,
2023
+ } ,
2024
+ } ,
2025
+ ] ) ;
2026
+
2027
+ defineConfig ( [
2028
+ globalIgnores ( [ "*.js" ] ) ,
2029
+ {
2030
+ files : [ "*.js" ] ,
2031
+ rules : {
2032
+ "no-console" : "error" ,
2033
+ } ,
2034
+ } ,
2035
+ {
2036
+ files : [ "*.ts" ] ,
2037
+ rules : {
2038
+ "@typescript-eslint/no-unused-vars" : "error" ,
2039
+ } ,
2040
+ } ,
2041
+ ] ) ;
2042
+
2043
+ // #endregion
0 commit comments