From 29ecc8f42557a80ce583cbb087d80b5791cfffed Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 3 Apr 2018 17:16:31 -0400 Subject: [PATCH] Disabled reference-components-regex for now --- CHANGELOG.md | 2 ++ lib/linter.js | 32 +++++++++++++++++++------------- rules/default.json | 2 +- test/linter.test.js | 2 +- test/loader.test.js | 2 +- test/profiles/default.json | 2 +- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af641ca1..1e9223e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Changed - `properties` rule will now ignore extensions, so `foo: 'a', x-bar: 'b'` is only 1 property. +### Fixed +- Disabled `reference-components-regex` rule until resolver can allow it to work ## [0.5.3] - 2018-03-29 ### Fixed diff --git a/lib/linter.js b/lib/linter.js index 885063bb..9a9218ef 100644 --- a/lib/linter.js +++ b/lib/linter.js @@ -110,19 +110,25 @@ const lint = (objectName, object, options = {}) => { const target = object[property] let components = []; - if (split) { - components = target.split(split); - } - else { - components.push(target); - } - const re = new RegExp(value); - for (let component of components) { - if (omit) component = component.split(omit).join(''); - if (component) { - ensure(rule, () => { - should(re.test(component)).be.exactly(true, rule.description); - }); + if (target) { + if (split) { + // console.log('====\ntarget', target); + // console.log('object', object); + components = target.split(split); + // console.log('just split: components', components); + + } + else { + components.push(target); + } + const re = new RegExp(value); + for (let component of components) { + if (omit) component = component.split(omit).join(''); + if (component) { + ensure(rule, () => { + should(re.test(component)).be.exactly(true, rule.description); + }); + } } } } diff --git a/rules/default.json b/rules/default.json index 8b4f0350..62bbb19b 100644 --- a/rules/default.json +++ b/rules/default.json @@ -92,7 +92,7 @@ { "name": "reference-components-regex", "object": "reference", - "enabled": true, + "enabled": false, "description": "reference components should all match regex ^[a-zA-Z0-9\\.\\-_]+", "pattern": { "property": "$ref", "omit": "#", "split": "/", "value": "^[a-zA-Z0-9\\.\\-_]+$" } }, diff --git a/test/linter.test.js b/test/linter.test.js index eb287e6f..84142117 100644 --- a/test/linter.test.js +++ b/test/linter.test.js @@ -210,7 +210,7 @@ describe('linter.js', () => { }); }); - context('when trying to figure this damn error out', () => { + xcontext('when trying to figure this damn error out', () => { const rule = { name: "reference-components-regex", object: "reference", diff --git a/test/loader.test.js b/test/loader.test.js index 0abdbcfc..76218f5e 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -17,7 +17,7 @@ describe('loader.js', () => { "openapi-tags-alphabetical", "reference-no-other-properties", "example-value-or-externalValue", - "reference-components-regex", + // "reference-components-regex", "no-script-tags-in-markdown", "info-contact", "license-apimatic-bug", diff --git a/test/profiles/default.json b/test/profiles/default.json index 12c2249e..fb577ae4 100644 --- a/test/profiles/default.json +++ b/test/profiles/default.json @@ -144,7 +144,7 @@ "input": { "$ref": "parameters.yml#/roomId" }, - "expectedRuleErrors": ["reference-components-regex"] + "expectedRuleErrors": [] }, { "input": {