@@ -4631,6 +4631,99 @@ describe("FlatESLint", () => {
4631
4631
} ) ;
4632
4632
} ) ;
4633
4633
4634
+ describe ( "configs with 'ignores' and without 'files'" , ( ) => {
4635
+
4636
+ // https://github.com/eslint/eslint/issues/17103
4637
+ describe ( "config with ignores: ['error.js']" , ( ) => {
4638
+ const cwd = getFixturePath ( "config-with-ignores-without-files" ) ;
4639
+ const { prepare, cleanup, getPath } = createCustomTeardown ( {
4640
+ cwd,
4641
+ files : {
4642
+ "eslint.config.js" : `module.exports = [
4643
+ {
4644
+ rules: {
4645
+ "no-unused-vars": "error",
4646
+ },
4647
+ },
4648
+ {
4649
+ ignores: ["error.js"],
4650
+ rules: {
4651
+ "no-unused-vars": "warn",
4652
+ },
4653
+ },
4654
+ ];` ,
4655
+ "error.js" : "let unusedVar;" ,
4656
+ "warn.js" : "let unusedVar;"
4657
+ }
4658
+ } ) ;
4659
+
4660
+ beforeEach ( prepare ) ;
4661
+ afterEach ( cleanup ) ;
4662
+
4663
+ it ( "should apply to all files except for 'error.js'" , async ( ) => {
4664
+ const engine = new FlatESLint ( {
4665
+ cwd
4666
+ } ) ;
4667
+
4668
+ const results = await engine . lintFiles ( "{error,warn}.js" ) ;
4669
+
4670
+ assert . strictEqual ( results . length , 2 ) ;
4671
+
4672
+ const [ errorResult , warnResult ] = results ;
4673
+
4674
+ assert . strictEqual ( errorResult . filePath , path . join ( getPath ( ) , "error.js" ) ) ;
4675
+ assert . strictEqual ( errorResult . messages . length , 1 ) ;
4676
+ assert . strictEqual ( errorResult . messages [ 0 ] . ruleId , "no-unused-vars" ) ;
4677
+ assert . strictEqual ( errorResult . messages [ 0 ] . severity , 2 ) ;
4678
+
4679
+ assert . strictEqual ( warnResult . filePath , path . join ( getPath ( ) , "warn.js" ) ) ;
4680
+ assert . strictEqual ( warnResult . messages . length , 1 ) ;
4681
+ assert . strictEqual ( warnResult . messages [ 0 ] . ruleId , "no-unused-vars" ) ;
4682
+ assert . strictEqual ( warnResult . messages [ 0 ] . severity , 1 ) ;
4683
+ } ) ;
4684
+ } ) ;
4685
+
4686
+ describe ( "config with ignores: ['**/*.json']" , ( ) => {
4687
+ const cwd = getFixturePath ( "config-with-ignores-without-files" ) ;
4688
+ const { prepare, cleanup, getPath } = createCustomTeardown ( {
4689
+ cwd,
4690
+ files : {
4691
+ "eslint.config.js" : `module.exports = [
4692
+ {
4693
+ rules: {
4694
+ "no-undef": "error",
4695
+ },
4696
+ },
4697
+ {
4698
+ ignores: ["**/*.json"],
4699
+ rules: {
4700
+ "no-unused-vars": "error",
4701
+ },
4702
+ },
4703
+ ];` ,
4704
+ "foo.js" : "" ,
4705
+ "foo.json" : ""
4706
+ }
4707
+ } ) ;
4708
+
4709
+ beforeEach ( prepare ) ;
4710
+ afterEach ( cleanup ) ;
4711
+
4712
+ it ( "should not add json files as lint targets" , async ( ) => {
4713
+ const engine = new FlatESLint ( {
4714
+ cwd
4715
+ } ) ;
4716
+
4717
+ const results = await engine . lintFiles ( "foo*" ) ;
4718
+
4719
+ // should not lint `foo.json`
4720
+ assert . strictEqual ( results . length , 1 ) ;
4721
+ assert . strictEqual ( results [ 0 ] . filePath , path . join ( getPath ( ) , "foo.js" ) ) ;
4722
+ } ) ;
4723
+ } ) ;
4724
+
4725
+ } ) ;
4726
+
4634
4727
describe ( "with ignores config" , ( ) => {
4635
4728
const root = getFixturePath ( "cli-engine/ignore-patterns" ) ;
4636
4729
0 commit comments