Skip to content

Commit

Permalink
Prettier, eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
bravo-kernel committed Aug 15, 2019
1 parent edfcbf8 commit 679d8a7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 27 deletions.
7 changes: 3 additions & 4 deletions lib/schema-manager.js
@@ -1,4 +1,3 @@
/* eslint-disable class-methods-use-this */
/* eslint-disable no-underscore-dangle */

const _ = require('lodash'); // limit later to `merge`, `capitalize`, etc.
Expand Down Expand Up @@ -148,7 +147,7 @@ class SchemaManager {
};

// some schemas support the identifier property
const identifierKeyword = _strategy.get(this).getIdentifierKeyword();
const identifierKeyword = _strategy.get(this).constructor.getIdentifierKeyword();
if (identifierKeyword) {
result[identifierKeyword] = this._getUriForModel();
}
Expand All @@ -157,9 +156,9 @@ class SchemaManager {
result.type = 'object';

// some schemas support the schema identifier
const schemaKeyword = _strategy.get(this).getSchemaKeyword();
const schemaKeyword = _strategy.get(this).constructor.getSchemaKeyword();
if (schemaKeyword) {
result[schemaKeyword] = _strategy.get(this).getSchemaUri();
result[schemaKeyword] = _strategy.get(this).constructor.getSchemaUri();
}

return result;
Expand Down
8 changes: 3 additions & 5 deletions lib/strategies/json-schema-v6.js
@@ -1,5 +1,3 @@
/* eslint-disable class-methods-use-this */

const StrategyInterface = require('../strategy-interface');

/**
Expand All @@ -15,7 +13,7 @@ class JsonSchema6Strategy extends StrategyInterface {
*
* @returns {string}
*/
getSchemaUri() {
static getSchemaUri() {
return 'https://json-schema.org/draft-06/schema#';
}

Expand All @@ -26,7 +24,7 @@ class JsonSchema6Strategy extends StrategyInterface {
*
* @returns {string}
*/
getSchemaKeyword() {
static getSchemaKeyword() {
return '$schema';
}

Expand All @@ -37,7 +35,7 @@ class JsonSchema6Strategy extends StrategyInterface {
*
* @returns {string}
*/
getIdentifierKeyword() {
static getIdentifierKeyword() {
return '$id';
}
}
Expand Down
13 changes: 5 additions & 8 deletions lib/strategies/openapi-v3.js
@@ -1,5 +1,3 @@
/* eslint-disable class-methods-use-this */

const StrategyInterface = require('../strategy-interface');

/**
Expand All @@ -15,32 +13,31 @@ class OpenApi3Strategy extends StrategyInterface {
* @returns {string}
*/
// prettier-ignore
getSchemaUri() { // eslint-disable-line no-unused-vars
static getSchemaUri() {
return 'https://json-schema.org/draft-06/schema#';
}

/**
* OpenAPI v3 does not support/allow support the "identifier" property so we
* OpenAPI v3 does not support/allow support the "schema" property so we
* omit the property from appearing in the schema by returning `null`.
*
* @example null
*
* @returns {null}
*/
getIdentifierKeyword() {
static getSchemaKeyword() {
return null;
}

/**
* OpenAPI v3 does not support/allow support the "schema" property so we
* OpenAPI v3 does not support/allow support the "identifier" property so we
* omit the property from appearing in the schema by returning `null`.
*
* @example null
*
* @returns {null}
*/
getSchemaKeyword() {
static getIdentifierKeyword() {
return null;
}
}
Expand Down
18 changes: 8 additions & 10 deletions lib/strategy-interface.js
@@ -1,7 +1,4 @@
/* eslint-disable class-methods-use-this */
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-use-before-define */
/* eslint-disable require-returns-check */

/**
* Strategy interface where we define the methods every inheriting strategy MUST implement.
Expand All @@ -13,7 +10,7 @@ class StrategyInterface {
* @returns {string}
*/
getSchemaUri() {
this._throwMissingImplementationError(this.constructor.name, 'getSchemaUri');
this.constructor._throwMissingImplementationError(this.constructor.name, 'getSchemaUri');
}

/**
Expand All @@ -24,9 +21,8 @@ class StrategyInterface {
* @param {string} path Path
* @returns {string|null}
*/
// prettier-ignore
getSchemaKeyword() {
this._throwMissingImplementationError(this.constructor.name, 'getSchemaKeyword');
this.constructor._throwMissingImplementationError(this.constructor.name, 'getSchemaKeyword');
}

/**
Expand All @@ -37,9 +33,11 @@ class StrategyInterface {
* @param {string} path Path
* @returns {string|null}
*/
// prettier-ignore
getIdentifierKeyword() {
this._throwMissingImplementationError(this.constructor.name, 'getIdentifierKeyword');
this.constructor._throwMissingImplementationError(
this.constructor.name,
'getIdentifierKeyword',
);
}

/**
Expand All @@ -50,7 +48,7 @@ class StrategyInterface {
*/
// prettier-ignore
getExampleProperty(raw) { // eslint-disable-line no-unused-vars
this._throwMissingImplementationError(this.constructor.name, 'getExampleProperty');
this.constructor._throwMissingImplementationError(this.constructor.name, 'getExampleProperty');
}

/**
Expand All @@ -61,7 +59,7 @@ class StrategyInterface {
* @param {string} methodName Name of the missing method
* @todo Make this truly private (using weakmap?)
*/
_throwMissingImplementationError(strategyName, methodName) {
static _throwMissingImplementationError(strategyName, methodName) {
throw new Error(`${strategyName} has not implemented the '${methodName}' interface method.`);
}
}
Expand Down

0 comments on commit 679d8a7

Please sign in to comment.