diff --git a/tests/lib/config_tests.js b/tests/lib/config_tests.js index 956ee8f3..8bff17cd 100644 --- a/tests/lib/config_tests.js +++ b/tests/lib/config_tests.js @@ -104,6 +104,20 @@ describe('lib', () => { expect(actual.rules['test-file-exists'].level).to.equals('off') }) + it('should detect loops in extended rulesets', async () => { + const loopSelf = await Config.loadConfig( + path.join(__dirname, 'loop-self.yaml') + ) + expect(loopSelf.rules).to.have.property('test-file-exists') + expect(loopSelf.rules['test-file-exists'].level).to.equals('error') + + const loopB = await Config.loadConfig( + path.join(__dirname, 'loop-b.yaml') + ) + expect(loopB.rules).to.have.property('test-file-exists') + expect(loopB.rules['test-file-exists'].level).to.equals('off') + }) + it('should throw error on non existant file', async () => { expect(Config.loadConfig('/does-not-exist')).to.eventually.throw( 'ENOENT' diff --git a/tests/lib/loop-a.yaml b/tests/lib/loop-a.yaml new file mode 100644 index 00000000..ff3345e0 --- /dev/null +++ b/tests/lib/loop-a.yaml @@ -0,0 +1,6 @@ +$schema: "../../rulesets/schema.json" +extends: "./loop-b.yaml" +version: 2 +rules: + test-file-exists: + level: error diff --git a/tests/lib/loop-b.yaml b/tests/lib/loop-b.yaml new file mode 100644 index 00000000..5df25ac4 --- /dev/null +++ b/tests/lib/loop-b.yaml @@ -0,0 +1,6 @@ +$schema: "../../rulesets/schema.json" +extends: "./loop-a.yaml" +version: 2 +rules: + test-file-exists: + level: off diff --git a/tests/lib/loop-self.yaml b/tests/lib/loop-self.yaml new file mode 100644 index 00000000..c752eab0 --- /dev/null +++ b/tests/lib/loop-self.yaml @@ -0,0 +1,6 @@ +$schema: "../../rulesets/schema.json" +extends: "./loop-self.yaml" +version: 2 +rules: + test-file-exists: + level: error