-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eslint] fix indentation and whitespace
- Loading branch information
Showing
14 changed files
with
262 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,40 @@ | ||
{ | ||
"root": true, | ||
"root": true, | ||
|
||
"extends": "@ljharb", | ||
"extends": "@ljharb", | ||
|
||
"rules": { | ||
"brace-style": 1, | ||
"comma-spacing": 1, | ||
"consistent-return": 1, | ||
"curly": 1, | ||
"function-paren-newline": 1, | ||
"indent": [1, 4], | ||
"key-spacing": 1, | ||
"keyword-spacing": 1, | ||
"max-lines-per-function": 0, | ||
"max-params": 1, | ||
"max-statements-per-line": 1, | ||
"no-continue": 1, | ||
"no-else-return": 1, | ||
"no-extra-parens": 1, | ||
"no-extra-semi": 1, | ||
"no-mixed-spaces-and-tabs": 1, | ||
"no-negated-condition": 1, | ||
"no-param-reassign": 1, | ||
"no-redeclare": 1, | ||
"no-restricted-syntax": 1, | ||
"no-unused-vars": 1, | ||
"no-use-before-define": 1, | ||
"object-curly-newline": 1, | ||
"object-curly-spacing": 1, | ||
"operator-linebreak": 1, | ||
"semi": 1, | ||
"sort-keys": 1, | ||
"space-before-function-paren": 1, | ||
"space-in-parens": 1, | ||
"space-infix-ops": 1, | ||
"strict": 1, | ||
"wrap-iife": 1, | ||
}, | ||
"rules": { | ||
"brace-style": 1, | ||
"consistent-return": 1, | ||
"curly": 1, | ||
"function-paren-newline": 1, | ||
"max-lines-per-function": 0, | ||
"max-params": 1, | ||
"max-statements-per-line": 1, | ||
"no-continue": 1, | ||
"no-else-return": 1, | ||
"no-extra-parens": 1, | ||
"no-extra-semi": 1, | ||
"no-negated-condition": 1, | ||
"no-param-reassign": 1, | ||
"no-redeclare": 1, | ||
"no-restricted-syntax": 1, | ||
"no-unused-vars": 1, | ||
"no-use-before-define": 1, | ||
"object-curly-newline": 1, | ||
"operator-linebreak": 1, | ||
"semi": 1, | ||
"sort-keys": 1, | ||
"strict": 1, | ||
"wrap-iife": 1, | ||
}, | ||
|
||
"overrides": [ | ||
{ | ||
"files": "example/**", | ||
"rules": { | ||
"no-console": 0, | ||
}, | ||
}, | ||
], | ||
"overrides": [ | ||
{ | ||
"files": "example/**", | ||
"rules": { | ||
"no-console": 0, | ||
}, | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
var stringify = require('../'); | ||
|
||
var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 }; | ||
var obj = { c: 8, b: [{ z: 6, y: 5, x: 4 }, 7], a: 3 }; | ||
var s = stringify(obj, function (a, b) { | ||
return a.key < b.key ? 1 : -1; | ||
return a.key < b.key ? 1 : -1; | ||
}); | ||
console.log(s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
var stringify = require('../'); | ||
var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 }; | ||
|
||
var obj = { c: 8, b: [{ z: 6, y: 5, x: 4 }, 7], a: 3 }; | ||
|
||
console.log(stringify(obj)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
var stringify = require('../'); | ||
var obj = { c: 6, b: [4,5], a: 3 }; | ||
|
||
var obj = { c: 6, b: [4, 5], a: 3 }; | ||
|
||
console.log(stringify(obj)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
var stringify = require('../'); | ||
|
||
var obj = { d: 6, c: 5, b: [{z:3,y:2,x:1},9], a: 10 }; | ||
var obj = { d: 6, c: 5, b: [{ z: 3, y: 2, x: 1 }, 9], a: 10 }; | ||
|
||
var s = stringify(obj, function (a, b) { | ||
return a.value < b.value ? 1 : -1; | ||
return a.value < b.value ? 1 : -1; | ||
}); | ||
|
||
console.log(s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,84 @@ | ||
var json = typeof JSON !== 'undefined' ? JSON : require('jsonify'); | ||
|
||
module.exports = function (obj, opts) { | ||
if (!opts) opts = {}; | ||
if (typeof opts === 'function') opts = { cmp: opts }; | ||
var space = opts.space || ''; | ||
if (typeof space === 'number') space = Array(space+1).join(' '); | ||
var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false; | ||
var replacer = opts.replacer || function(key, value) { return value; }; | ||
if (!opts) opts = {}; | ||
if (typeof opts === 'function') opts = { cmp: opts }; | ||
var space = opts.space || ''; | ||
if (typeof space === 'number') space = Array(space + 1).join(' '); | ||
var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false; | ||
var replacer = opts.replacer || function (key, value) { return value; }; | ||
|
||
var cmp = opts.cmp && (function (f) { | ||
return function (node) { | ||
return function (a, b) { | ||
var aobj = { key: a, value: node[a] }; | ||
var bobj = { key: b, value: node[b] }; | ||
return f(aobj, bobj); | ||
}; | ||
}; | ||
})(opts.cmp); | ||
var cmp = opts.cmp && (function (f) { | ||
return function (node) { | ||
return function (a, b) { | ||
var aobj = { key: a, value: node[a] }; | ||
var bobj = { key: b, value: node[b] }; | ||
return f(aobj, bobj); | ||
}; | ||
}; | ||
})(opts.cmp); | ||
|
||
var seen = []; | ||
return (function stringify (parent, key, node, level) { | ||
var indent = space ? ('\n' + new Array(level + 1).join(space)) : ''; | ||
var colonSeparator = space ? ': ' : ':'; | ||
var seen = []; | ||
return (function stringify(parent, key, node, level) { | ||
var indent = space ? ('\n' + new Array(level + 1).join(space)) : ''; | ||
var colonSeparator = space ? ': ' : ':'; | ||
|
||
if (node && node.toJSON && typeof node.toJSON === 'function') { | ||
node = node.toJSON(); | ||
} | ||
if (node && node.toJSON && typeof node.toJSON === 'function') { | ||
node = node.toJSON(); | ||
} | ||
|
||
node = replacer.call(parent, key, node); | ||
node = replacer.call(parent, key, node); | ||
|
||
if (node === undefined) { | ||
return; | ||
} | ||
if (typeof node !== 'object' || node === null) { | ||
return json.stringify(node); | ||
} | ||
if (isArray(node)) { | ||
var out = []; | ||
for (var i = 0; i < node.length; i++) { | ||
var item = stringify(node, i, node[i], level+1) || json.stringify(null); | ||
out.push(indent + space + item); | ||
} | ||
return '[' + out.join(',') + indent + ']'; | ||
} | ||
else { | ||
if (seen.indexOf(node) !== -1) { | ||
if (cycles) return json.stringify('__cycle__'); | ||
throw new TypeError('Converting circular structure to JSON'); | ||
} | ||
else seen.push(node); | ||
if (node === undefined) { | ||
return; | ||
} | ||
if (typeof node !== 'object' || node === null) { | ||
return json.stringify(node); | ||
} | ||
if (isArray(node)) { | ||
var out = []; | ||
for (var i = 0; i < node.length; i++) { | ||
var item = stringify(node, i, node[i], level + 1) || json.stringify(null); | ||
out.push(indent + space + item); | ||
} | ||
return '[' + out.join(',') + indent + ']'; | ||
} | ||
else { | ||
if (seen.indexOf(node) !== -1) { | ||
if (cycles) return json.stringify('__cycle__'); | ||
throw new TypeError('Converting circular structure to JSON'); | ||
} | ||
else seen.push(node); | ||
|
||
var keys = objectKeys(node).sort(cmp && cmp(node)); | ||
var out = []; | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i]; | ||
var value = stringify(node, key, node[key], level+1); | ||
var keys = objectKeys(node).sort(cmp && cmp(node)); | ||
var out = []; | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i]; | ||
var value = stringify(node, key, node[key], level + 1); | ||
|
||
if(!value) continue; | ||
if (!value) continue; | ||
|
||
var keyValue = json.stringify(key) | ||
+ colonSeparator | ||
+ value; | ||
; | ||
out.push(indent + space + keyValue); | ||
} | ||
seen.splice(seen.indexOf(node), 1); | ||
return '{' + out.join(',') + indent + '}'; | ||
} | ||
})({ '': obj }, '', obj, 0); | ||
var keyValue = json.stringify(key) | ||
+ colonSeparator | ||
+ value; | ||
; | ||
out.push(indent + space + keyValue); | ||
} | ||
seen.splice(seen.indexOf(node), 1); | ||
return '{' + out.join(',') + indent + '}'; | ||
} | ||
})({ '': obj }, '', obj, 0); | ||
}; | ||
|
||
var isArray = Array.isArray || function (x) { | ||
return {}.toString.call(x) === '[object Array]'; | ||
return {}.toString.call(x) === '[object Array]'; | ||
}; | ||
|
||
var objectKeys = Object.keys || function (obj) { | ||
var has = Object.prototype.hasOwnProperty || function () { return true }; | ||
var keys = []; | ||
for (var key in obj) { | ||
if (has.call(obj, key)) keys.push(key); | ||
} | ||
return keys; | ||
var has = Object.prototype.hasOwnProperty || function () { return true }; | ||
var keys = []; | ||
for (var key in obj) { | ||
if (has.call(obj, key)) keys.push(key); | ||
} | ||
return keys; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,52 @@ | ||
{ | ||
"name": "json-stable-stringify", | ||
"version": "1.0.1", | ||
"description": "deterministic JSON.stringify() with custom sorting to get deterministic hashes from stringified results", | ||
"main": "index.js", | ||
"dependencies": { | ||
"jsonify": "~0.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^21.0.0", | ||
"eslint": "=8.8.0", | ||
"tape": "^5.6.1" | ||
}, | ||
"scripts": { | ||
"lint": "eslint --ext=js,mjs .", | ||
"pretest": "npm run lint", | ||
"tests-only": "tape 'test/**/*.js'", | ||
"test": "npm run tests-only" | ||
}, | ||
"testling": { | ||
"files": "test/*.js", | ||
"browsers": [ | ||
"ie/8..latest", | ||
"ff/5", | ||
"ff/latest", | ||
"chrome/15", | ||
"chrome/latest", | ||
"safari/latest", | ||
"opera/latest" | ||
] | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/substack/json-stable-stringify.git" | ||
}, | ||
"homepage": "https://github.com/substack/json-stable-stringify", | ||
"keywords": [ | ||
"json", | ||
"stringify", | ||
"deterministic", | ||
"hash", | ||
"sort", | ||
"stable" | ||
], | ||
"author": { | ||
"name": "James Halliday", | ||
"email": "mail@substack.net", | ||
"url": "http://substack.net" | ||
}, | ||
"license": "MIT" | ||
"name": "json-stable-stringify", | ||
"version": "1.0.1", | ||
"description": "deterministic JSON.stringify() with custom sorting to get deterministic hashes from stringified results", | ||
"main": "index.js", | ||
"dependencies": { | ||
"jsonify": "~0.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^21.0.0", | ||
"eslint": "=8.8.0", | ||
"tape": "^5.6.1" | ||
}, | ||
"scripts": { | ||
"lint": "eslint --ext=js,mjs .", | ||
"pretest": "npm run lint", | ||
"tests-only": "tape 'test/**/*.js'", | ||
"test": "npm run tests-only" | ||
}, | ||
"testling": { | ||
"files": "test/*.js", | ||
"browsers": [ | ||
"ie/8..latest", | ||
"ff/5", | ||
"ff/latest", | ||
"chrome/15", | ||
"chrome/latest", | ||
"safari/latest", | ||
"opera/latest" | ||
] | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/substack/json-stable-stringify.git" | ||
}, | ||
"homepage": "https://github.com/substack/json-stable-stringify", | ||
"keywords": [ | ||
"json", | ||
"stringify", | ||
"deterministic", | ||
"hash", | ||
"sort", | ||
"stable" | ||
], | ||
"author": { | ||
"name": "James Halliday", | ||
"email": "mail@substack.net", | ||
"url": "http://substack.net" | ||
}, | ||
"license": "MIT" | ||
>>>>>>> 47b2b3c ([eslint] fix indentation and whitespace) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.