Skip to content

Commit

Permalink
[eslint] fix indentation and whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 13, 2022
1 parent 559372e commit 89fc65c
Show file tree
Hide file tree
Showing 27 changed files with 1,394 additions and 1,428 deletions.
122 changes: 56 additions & 66 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,71 +1,61 @@
{
"root": true,
"root": true,

"extends": "@ljharb/eslint-config/node/0.4",
"extends": "@ljharb/eslint-config/node/0.4",

"rules": {
"array-bracket-newline": 0,
"array-bracket-spacing": 1,
"array-callback-return": 1,
"array-element-newline": 0,
"brace-style": 1,
"camelcase": 1,
"comma-dangle": 1,
"comma-spacing": 1,
"complexity": 0,
"consistent-return": 1,
"curly": 1,
"dot-notation": 1,
"eqeqeq": 1,
"func-style": 1,
"function-call-argument-newline": 1,
"function-paren-newline": 1,
"global-require": 1,
"indent": [1, 4],
"key-spacing": 1,
"max-lines-per-function": 1,
"max-statements-per-line": 1,
"multiline-comment-style": 0,
"new-parens": 1,
"no-else-return": 1,
"no-extra-bind": 1,
"no-extra-parens": 1,
"no-extra-semi": 1,
"no-multi-assign": 1,
"no-new-wrappers": 1,
"no-param-reassign": 1,
"no-plusplus": 1,
"no-proto": 1,
"no-restricted-syntax": 1,
"no-shadow": 1,
"no-sparse-arrays": 1,
"no-trailing-spaces": 1,
"no-undef": 1,
"no-underscore-dangle": 1,
"no-unused-vars": 1,
"no-use-before-define": 1,
"no-useless-concat": 1,
"object-curly-newline": 1,
"one-var-declaration-per-line": 1,
"operator-linebreak": 1,
"quote-props": 1,
"quotes": 1,
"semi-style": 1,
"semi": 1,
"sort-keys": 0,
"space-before-function-paren": 1,
"space-unary-ops": 1,
"spaced-comment": 1,
"strict": 1,
"wrap-iife": 1,
},
"rules": {
"array-bracket-newline": 0,
"array-callback-return": 1,
"array-element-newline": 0,
"brace-style": 1,
"camelcase": 1,
"comma-dangle": 1,
"complexity": 0,
"consistent-return": 1,
"curly": 0,
"dot-notation": 1,
"eqeqeq": 1,
"func-style": 1,
"global-require": 1,
"max-lines-per-function": 1,
"max-statements-per-line": 1,
"multiline-comment-style": 0,
"new-parens": 1,
"no-else-return": 1,
"no-extra-bind": 1,
"no-extra-parens": 1,
"no-extra-semi": 1,
"no-multi-assign": 1,
"no-new-wrappers": 1,
"no-param-reassign": 1,
"no-plusplus": 1,
"no-proto": 1,
"no-restricted-syntax": 1,
"no-shadow": 1,
"no-sparse-arrays": 1,
"no-undef": 1,
"no-underscore-dangle": 1,
"no-unused-vars": 1,
"no-use-before-define": 1,
"no-useless-concat": 1,
"object-curly-newline": 0,
"one-var-declaration-per-line": 1,
"operator-linebreak": 1,
"quote-props": 1,
"quotes": 1,
"semi-style": 1,
"semi": 1,
"sort-keys": 0,
"strict": 1,
"wrap-iife": 1,
},

"overrides": [
{
"files": "examples/**",
"rules": {
"no-console": 0,
},
},
],
"overrides": [
{
"files": "examples/**",
"rules": {
"no-console": 0,
},
},
],
}
12 changes: 6 additions & 6 deletions examples/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ var traverse = require('traverse');

var id = 54;
var callbacks = {};
var obj = { moo : function () {}, foo : [2,3,4, function () {}] };
var obj = { moo: function () {}, foo: [2, 3, 4, function () {}] };

var scrubbed = traverse(obj).map(function (x) {
if (typeof x === 'function') {
callbacks[id] = { id : id, f : x, path : this.path };
this.update('[Function]');
id++;
}
if (typeof x === 'function') {
callbacks[id] = { id: id, f: x, path: this.path };
this.update('[Function]');
id++;
}
});

console.dir(scrubbed);
Expand Down
12 changes: 6 additions & 6 deletions examples/leaves.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var traverse = require('traverse');

var obj = {
a : [1,2,3],
b : 4,
c : [5,6],
d : { e : [7,8], f : 9 },
a: [1, 2, 3],
b: 4,
c: [5, 6],
d: { e: [7, 8], f: 9 },
};

var leaves = traverse(obj).reduce(function (acc, x) {
if (this.isLeaf) acc.push(x);
return acc;
if (this.isLeaf) acc.push(x);
return acc;
}, []);

console.dir(leaves);
4 changes: 2 additions & 2 deletions examples/negative.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var traverse = require('traverse');
var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];
var obj = [5, 6, -3, [7, 8, -2, 1], { f: 10, g: -13 }];

traverse(obj).forEach(function (x) {
if (x < 0) this.update(x + 128);
if (x < 0) this.update(x + 128);
});

console.dir(obj);
4 changes: 2 additions & 2 deletions examples/scrub.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// scrub out circular references
var traverse = require('traverse');

var obj = { a : 1, b : 2, c : [ 3, 4 ] };
var obj = { a: 1, b: 2, c: [3, 4] };
obj.c.push(obj);

var scrubbed = traverse(obj).map(function (x) {
if (this.circular) this.remove()
if (this.circular) this.remove()
});
console.dir(scrubbed);
58 changes: 29 additions & 29 deletions examples/stringify.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
#!/usr/bin/env node
var traverse = require('traverse');

var obj = [ 'five', 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];
var obj = ['five', 6, -3, [7, 8, -2, 1], { f: 10, g: -13 }];

var s = '';
traverse(obj).forEach(function to_s (node) {
if (Array.isArray(node)) {
this.before(function () { s += '[' });
this.post(function (child) {
if (!child.isLast) s += ',';
});
this.after(function () { s += ']' });
}
else if (typeof node == 'object') {
this.before(function () { s += '{' });
this.pre(function (x, key) {
to_s(key);
s += ':';
});
this.post(function (child) {
if (!child.isLast) s += ',';
});
this.after(function () { s += '}' });
}
else if (typeof node == 'string') {
s += '"' + node.toString().replace(/"/g, '\\"') + '"';
}
else if (typeof node == 'function') {
s += 'null';
}
else {
s += node.toString();
}
traverse(obj).forEach(function to_s(node) {
if (Array.isArray(node)) {
this.before(function () { s += '[' });
this.post(function (child) {
if (!child.isLast) s += ',';
});
this.after(function () { s += ']' });
}
else if (typeof node == 'object') {
this.before(function () { s += '{' });
this.pre(function (x, key) {
to_s(key);
s += ':';
});
this.post(function (child) {
if (!child.isLast) s += ',';
});
this.after(function () { s += '}' });
}
else if (typeof node == 'string') {
s += '"' + node.toString().replace(/"/g, '\\"') + '"';
}
else if (typeof node == 'function') {
s += 'null';
}
else {
s += node.toString();
}
});

console.log('JSON.stringify: ' + JSON.stringify(obj));
Expand Down
Loading

0 comments on commit 89fc65c

Please sign in to comment.