Skip to content

Commit ad3b35b

Browse files
ESLint auto-fixes (replaced single quotes with double quotes)
1 parent f51d5a9 commit ad3b35b

100 files changed

Lines changed: 2922 additions & 2922 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/bundle.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
'use strict';
1+
"use strict";
22

3-
var $Ref = require('./ref'),
4-
Pointer = require('./pointer'),
5-
url = require('./util/url');
3+
var $Ref = require("./ref"),
4+
Pointer = require("./pointer"),
5+
url = require("./util/url");
66

77
module.exports = bundle;
88

@@ -19,7 +19,7 @@ function bundle (parser, options) {
1919

2020
// Build an inventory of all $ref pointers in the JSON Schema
2121
var inventory = [];
22-
crawl(parser, 'schema', parser.$refs._root$Ref.path + '#', '#', 0, inventory, parser.$refs, options);
22+
crawl(parser, "schema", parser.$refs._root$Ref.path + "#", "#", 0, inventory, parser.$refs, options);
2323

2424
// Remap all $ref pointers
2525
remap(inventory);
@@ -39,7 +39,7 @@ function bundle (parser, options) {
3939
function crawl (parent, key, path, pathFromRoot, indirections, inventory, $refs, options) {
4040
var obj = key === null ? parent : parent[key];
4141

42-
if (obj && typeof obj === 'object') {
42+
if (obj && typeof obj === "object") {
4343
if ($Ref.isAllowed$Ref(obj)) {
4444
inventory$Ref(parent, key, path, pathFromRoot, indirections, inventory, $refs, options);
4545
}
@@ -51,10 +51,10 @@ function crawl (parent, key, path, pathFromRoot, indirections, inventory, $refs,
5151
.sort(function (a, b) {
5252
// Most people will expect references to be bundled into the the "definitions" property,
5353
// so we always crawl that property first, if it exists.
54-
if (a === 'definitions') {
54+
if (a === "definitions") {
5555
return -1;
5656
}
57-
else if (b === 'definitions') {
57+
else if (b === "definitions") {
5858
return 1;
5959
}
6060
else {
@@ -186,8 +186,8 @@ function remap (inventory) {
186186
else {
187187
// Determine how far each $ref is from the "definitions" property.
188188
// Most people will expect references to be bundled into the the "definitions" property if possible.
189-
var aDefinitionsIndex = a.pathFromRoot.lastIndexOf('/definitions');
190-
var bDefinitionsIndex = b.pathFromRoot.lastIndexOf('/definitions');
189+
var aDefinitionsIndex = a.pathFromRoot.lastIndexOf("/definitions");
190+
var bDefinitionsIndex = b.pathFromRoot.lastIndexOf("/definitions");
191191

192192
if (aDefinitionsIndex !== bDefinitionsIndex) {
193193
// Give higher priority to the $ref that's closer to the "definitions" property
@@ -212,9 +212,9 @@ function remap (inventory) {
212212
// This $ref points to the same value as the prevous $ref, so remap it to the same path
213213
entry.$ref.$ref = pathFromRoot;
214214
}
215-
else if (entry.file === file && entry.hash.indexOf(hash + '/') === 0) {
215+
else if (entry.file === file && entry.hash.indexOf(hash + "/") === 0) {
216216
// This $ref points to a sub-value of the prevous $ref, so remap it beneath that path
217-
entry.$ref.$ref = Pointer.join(pathFromRoot, Pointer.parse(entry.hash.replace(hash, '#')));
217+
entry.$ref.$ref = Pointer.join(pathFromRoot, Pointer.parse(entry.hash.replace(hash, "#")));
218218
}
219219
else {
220220
// We've moved to a new file or new hash

lib/dereference.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
'use strict';
1+
"use strict";
22

3-
var $Ref = require('./ref'),
4-
Pointer = require('./pointer'),
5-
ono = require('ono'),
6-
url = require('./util/url');
3+
var $Ref = require("./ref"),
4+
Pointer = require("./pointer"),
5+
ono = require("ono"),
6+
url = require("./util/url");
77

88
module.exports = dereference;
99

@@ -16,7 +16,7 @@ module.exports = dereference;
1616
*/
1717
function dereference (parser, options) {
1818
// console.log('Dereferencing $ref pointers in %s', parser.$refs._root$Ref.path);
19-
var dereferenced = crawl(parser.schema, parser.$refs._root$Ref.path, '#', [], parser.$refs, options);
19+
var dereferenced = crawl(parser.schema, parser.$refs._root$Ref.path, "#", [], parser.$refs, options);
2020
parser.$refs.circular = dereferenced.circular;
2121
parser.schema = dereferenced.value;
2222
}
@@ -39,7 +39,7 @@ function crawl (obj, path, pathFromRoot, parents, $refs, options) {
3939
circular: false
4040
};
4141

42-
if (obj && typeof obj === 'object') {
42+
if (obj && typeof obj === "object") {
4343
parents.push(obj);
4444

4545
if ($Ref.isAllowed$Ref(obj, options)) {
@@ -114,7 +114,7 @@ function dereference$Ref ($ref, path, pathFromRoot, parents, $refs, options) {
114114
dereferencedValue = dereferenced.value;
115115
}
116116

117-
if (circular && !directCircular && options.dereference.circular === 'ignore') {
117+
if (circular && !directCircular && options.dereference.circular === "ignore") {
118118
// The user has chosen to "ignore" circular references, so don't change the value
119119
dereferencedValue = $ref;
120120
}
@@ -143,7 +143,7 @@ function dereference$Ref ($ref, path, pathFromRoot, parents, $refs, options) {
143143
function foundCircularReference (keyPath, $refs, options) {
144144
$refs.circular = true;
145145
if (!options.dereference.circular) {
146-
throw ono.reference('Circular $ref pointer found at %s', keyPath);
146+
throw ono.reference("Circular $ref pointer found at %s", keyPath);
147147
}
148148
return true;
149149
}

lib/index.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
'use strict';
2-
3-
var Options = require('./options'),
4-
$Refs = require('./refs'),
5-
parse = require('./parse'),
6-
normalizeArgs = require('./normalize-args'),
7-
resolveExternal = require('./resolve-external'),
8-
bundle = require('./bundle'),
9-
dereference = require('./dereference'),
10-
url = require('./util/url'),
11-
maybe = require('call-me-maybe'),
12-
ono = require('ono');
1+
"use strict";
2+
3+
var Options = require("./options"),
4+
$Refs = require("./refs"),
5+
parse = require("./parse"),
6+
normalizeArgs = require("./normalize-args"),
7+
resolveExternal = require("./resolve-external"),
8+
bundle = require("./bundle"),
9+
dereference = require("./dereference"),
10+
url = require("./util/url"),
11+
maybe = require("call-me-maybe"),
12+
ono = require("ono");
1313

1414
module.exports = $RefParser;
15-
module.exports.YAML = require('./util/yaml');
15+
module.exports.YAML = require("./util/yaml");
1616

1717
/**
1818
* This class parses a JSON schema, builds a map of its JSON references and their resolved values,
@@ -71,7 +71,7 @@ $RefParser.prototype.parse = function (path, schema, options, callback) {
7171
var promise;
7272

7373
if (!args.path && !args.schema) {
74-
var err = ono('Expected a file path, URL, or object. Got %s', args.path || args.schema);
74+
var err = ono("Expected a file path, URL, or object. Got %s", args.path || args.schema);
7575
return maybe(args.callback, Promise.reject(err));
7676
}
7777

@@ -85,16 +85,16 @@ $RefParser.prototype.parse = function (path, schema, options, callback) {
8585
// So we're being generous here and doing the conversion automatically.
8686
// This is not intended to be a 100% bulletproof solution.
8787
// If it doesn't work for your use-case, then use a URL instead.
88-
var pathType = 'http';
88+
var pathType = "http";
8989
if (url.isFileSystemPath(args.path)) {
9090
args.path = url.fromFileSystemPath(args.path);
91-
pathType = 'file';
91+
pathType = "file";
9292
}
9393

9494
// Resolve the absolute path of the schema
9595
args.path = url.resolve(url.cwd(), args.path);
9696

97-
if (args.schema && typeof args.schema === 'object') {
97+
if (args.schema && typeof args.schema === "object") {
9898
// A schema object was passed-in.
9999
// So immediately add a new $Ref with the schema object as its value
100100
var $ref = this.$refs._add(args.path);
@@ -110,7 +110,7 @@ $RefParser.prototype.parse = function (path, schema, options, callback) {
110110
var me = this;
111111
return promise
112112
.then(function (result) {
113-
if (!result || typeof result !== 'object' || Buffer.isBuffer(result)) {
113+
if (!result || typeof result !== "object" || Buffer.isBuffer(result)) {
114114
throw ono.syntax('"%s" is not a valid JSON Schema', me.$refs._root$Ref.path || result);
115115
}
116116
else {

lib/normalize-args.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
'use strict';
1+
"use strict";
22

3-
var Options = require('./options');
3+
var Options = require("./options");
44

55
module.exports = normalizeArgs;
66

@@ -14,15 +14,15 @@ function normalizeArgs (args) {
1414
var path, schema, options, callback;
1515
args = Array.prototype.slice.call(args);
1616

17-
if (typeof args[args.length - 1] === 'function') {
17+
if (typeof args[args.length - 1] === "function") {
1818
// The last parameter is a callback function
1919
callback = args.pop();
2020
}
2121

22-
if (typeof args[0] === 'string') {
22+
if (typeof args[0] === "string") {
2323
// The first parameter is the path
2424
path = args[0];
25-
if (typeof args[2] === 'object') {
25+
if (typeof args[2] === "object") {
2626
// The second parameter is the schema, and the third parameter is the options
2727
schema = args[1];
2828
options = args[2];
@@ -35,7 +35,7 @@ function normalizeArgs (args) {
3535
}
3636
else {
3737
// The first parameter is the schema
38-
path = '';
38+
path = "";
3939
schema = args[0];
4040
options = args[1];
4141
}

lib/options.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* eslint lines-around-comment: [2, {beforeBlockComment: false}] */
2-
'use strict';
2+
"use strict";
33

4-
var jsonParser = require('./parsers/json'),
5-
yamlParser = require('./parsers/yaml'),
6-
textParser = require('./parsers/text'),
7-
binaryParser = require('./parsers/binary'),
8-
fileResolver = require('./resolvers/file'),
9-
httpResolver = require('./resolvers/http');
4+
var jsonParser = require("./parsers/json"),
5+
yamlParser = require("./parsers/yaml"),
6+
textParser = require("./parsers/text"),
7+
binaryParser = require("./parsers/binary"),
8+
fileResolver = require("./resolvers/file"),
9+
httpResolver = require("./resolvers/http");
1010

1111
module.exports = $RefParserOptions;
1212

@@ -107,7 +107,7 @@ function merge (target, source) {
107107
*/
108108
function isMergeable (val) {
109109
return val &&
110-
(typeof val === 'object') &&
110+
(typeof val === "object") &&
111111
!Array.isArray(val) &&
112112
!(val instanceof RegExp) &&
113113
!(val instanceof Date);

lib/parse.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
'use strict';
1+
"use strict";
22

3-
var ono = require('ono'),
4-
url = require('./util/url'),
5-
plugins = require('./util/plugins');
3+
var ono = require("ono"),
4+
url = require("./util/url"),
5+
plugins = require("./util/plugins");
66

77
module.exports = parse;
88

@@ -65,11 +65,11 @@ function readFile (file, options) {
6565

6666
// Find the resolvers that can read this file
6767
var resolvers = plugins.all(options.resolve);
68-
resolvers = plugins.filter(resolvers, 'canRead', file);
68+
resolvers = plugins.filter(resolvers, "canRead", file);
6969

7070
// Run the resolvers, in order, until one of them succeeds
7171
plugins.sort(resolvers);
72-
plugins.run(resolvers, 'read', file)
72+
plugins.run(resolvers, "read", file)
7373
.then(resolve, onError);
7474

7575
function onError (err) {
@@ -105,12 +105,12 @@ function parseFile (file, options) {
105105
// If none of the parsers are an exact match for this file, then we'll try ALL of them.
106106
// This handles situations where the file IS a supported type, just with an unknown extension.
107107
var allParsers = plugins.all(options.parse);
108-
var filteredParsers = plugins.filter(allParsers, 'canParse', file);
108+
var filteredParsers = plugins.filter(allParsers, "canParse", file);
109109
var parsers = filteredParsers.length > 0 ? filteredParsers : allParsers;
110110

111111
// Run the parsers, in order, until one of them succeeds
112112
plugins.sort(parsers);
113-
plugins.run(parsers, 'parse', file)
113+
plugins.run(parsers, "parse", file)
114114
.then(onParsed, onError);
115115

116116
function onParsed (parser) {
@@ -125,10 +125,10 @@ function parseFile (file, options) {
125125
function onError (err) {
126126
if (err) {
127127
err = err instanceof Error ? err : new Error(err);
128-
reject(ono.syntax(err, 'Error parsing %s', file.url));
128+
reject(ono.syntax(err, "Error parsing %s", file.url));
129129
}
130130
else {
131-
reject(ono.syntax('Unable to parse %s', file.url));
131+
reject(ono.syntax("Unable to parse %s", file.url));
132132
}
133133
}
134134
});
@@ -142,7 +142,7 @@ function parseFile (file, options) {
142142
*/
143143
function isEmpty (value) {
144144
return value === undefined ||
145-
(typeof value === 'object' && Object.keys(value).length === 0) ||
146-
(typeof value === 'string' && value.trim().length === 0) ||
145+
(typeof value === "object" && Object.keys(value).length === 0) ||
146+
(typeof value === "string" && value.trim().length === 0) ||
147147
(Buffer.isBuffer(value) && value.length === 0);
148148
}

lib/parsers/binary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
"use strict";
22

33
var BINARY_REGEXP = /\.(jpeg|jpg|gif|png|bmp|ico)$/i;
44

lib/parsers/json.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
"use strict";
22

33
module.exports = {
44
/**
@@ -23,7 +23,7 @@ module.exports = {
2323
*
2424
* @type {RegExp|string[]|function}
2525
*/
26-
canParse: '.json',
26+
canParse: ".json",
2727

2828
/**
2929
* Parses the given file as JSON
@@ -41,7 +41,7 @@ module.exports = {
4141
data = data.toString();
4242
}
4343

44-
if (typeof data === 'string') {
44+
if (typeof data === "string") {
4545
if (data.trim().length === 0) {
4646
resolve(undefined); // This mirrors the YAML behavior
4747
}

lib/parsers/text.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
"use strict";
22

33
var TEXT_REGEXP = /\.(txt|htm|html|md|xml|js|min|map|css|scss|less|svg)$/i;
44

@@ -22,7 +22,7 @@ module.exports = {
2222
*
2323
* @type {string}
2424
*/
25-
encoding: 'utf8',
25+
encoding: "utf8",
2626

2727
/**
2828
* Determines whether this parser can parse a given file reference.
@@ -38,7 +38,7 @@ module.exports = {
3838
*/
3939
canParse: function isText (file) {
4040
// Use this parser if the file is a string or Buffer, and has a known text-based extension
41-
return (typeof file.data === 'string' || Buffer.isBuffer(file.data)) && TEXT_REGEXP.test(file.url);
41+
return (typeof file.data === "string" || Buffer.isBuffer(file.data)) && TEXT_REGEXP.test(file.url);
4242
},
4343

4444
/**
@@ -51,14 +51,14 @@ module.exports = {
5151
* @returns {Promise<string>}
5252
*/
5353
parse: function parseText (file) {
54-
if (typeof file.data === 'string') {
54+
if (typeof file.data === "string") {
5555
return file.data;
5656
}
5757
else if (Buffer.isBuffer(file.data)) {
5858
return file.data.toString(this.encoding);
5959
}
6060
else {
61-
throw new Error('data is not text');
61+
throw new Error("data is not text");
6262
}
6363
}
6464
};

0 commit comments

Comments
 (0)