Skip to content

Commit

Permalink
Update eslint & prettier (immutable-js#1524)
Browse files Browse the repository at this point in the history
And fix newly exposed issues
  • Loading branch information
leebyron authored May 17, 2018
1 parent 0ebb778 commit 8f45d0e
Show file tree
Hide file tree
Showing 21 changed files with 239 additions and 142 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"object-shorthand": "off",
"one-var": "error",
"operator-assignment": "error",
"prefer-destructuring": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"prefer-template": "off",
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@
"colors": "1.1.2",
"del": "3.0.0",
"dtslint": "0.1.2",
"eslint": "4.8.0",
"eslint-config-airbnb": "15.1.0",
"eslint-config-prettier": "2.6.0",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-prettier": "2.3.1",
"eslint-plugin-react": "7.4.0",
"eslint": "4.19.1",
"eslint-config-airbnb": "16.1.0",
"eslint-config-prettier": "2.9.0",
"eslint-plugin-import": "2.12.0",
"eslint-plugin-jsx-a11y": "6.0.3",
"eslint-plugin-prettier": "2.6.0",
"eslint-plugin-react": "7.8.2",
"flow-bin": "0.56.0",
"gulp": "3.9.1",
"gulp-concat": "2.6.1",
Expand All @@ -87,7 +87,7 @@
"microtime": "2.1.6",
"mkdirp": "0.5.1",
"npm-run-all": "4.1.1",
"prettier": "1.7.4",
"prettier": "1.12.1",
"react": "^0.12.0",
"react-router": "^0.11.2",
"react-tools": "0.13.3",
Expand Down
4 changes: 3 additions & 1 deletion pages/lib/genTypeDefData.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ function DocVisitor(source) {
if (!shouldIgnore(comment)) {
var name = node.name
? node.name.text
: node.stringLiteral ? node.stringLiteral.text : '';
: node.stringLiteral
? node.stringLiteral.text
: '';

if (comment) {
setIn(data, [name, 'doc'], comment);
Expand Down
16 changes: 8 additions & 8 deletions pages/lib/prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ var Prism = (function() {
},

/**
* Insert a token before another token in a language literal
* As this needs to recreate the object (we cannot actually insert before keys in object literals),
* we cannot just provide an object, we need anobject and a key.
* @param inside The key (or language id) of the parent
* @param before The key to insert before. If not provided, the function appends instead.
* @param insert Object with the key/value pairs to insert
* @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
*/
* Insert a token before another token in a language literal
* As this needs to recreate the object (we cannot actually insert before keys in object literals),
* we cannot just provide an object, we need anobject and a key.
* @param inside The key (or language id) of the parent
* @param before The key to insert before. If not provided, the function appends instead.
* @param insert Object with the key/value pairs to insert
* @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
*/
insertBefore: function(inside, before, insert, root) {
root = root || _.languages;
var grammar = root[inside];
Expand Down
8 changes: 6 additions & 2 deletions pages/lib/runkit-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ function makeAssert(I) {
function message(lhs, rhs, same, identical) {
var result = compare(lhs, rhs, same, identical);
var comparison = result
? identical ? 'strict equal to' : 'does equal'
: identical ? 'not strict equal to' : 'does not equal';
? identical
? 'strict equal to'
: 'does equal'
: identical
? 'not strict equal to'
: 'does not equal';
var className = result === same ? 'success' : 'failure';
var lhsString = isIterable(lhs) ? lhs + '' : JSON.stringify(lhs);
var rhsString = isIterable(rhs) ? rhs + '' : JSON.stringify(rhs);
Expand Down
8 changes: 5 additions & 3 deletions pages/src/docs/src/Defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var InterfaceDef = React.createClass({
var def = this.props.def;
return (
<span className="t interfaceDef">
<span className="t keyword">{'class '}</span>
<span className="t keyword">class </span>
<span className="t typeName">{name}</span>
{def.typeParams && [
'<',
Expand All @@ -33,14 +33,14 @@ var InterfaceDef = React.createClass({
'>',
]}
{def.extends && [
<span className="t keyword">{' extends '}</span>,
<span className="t keyword"> extends </span>,
Seq(def.extends)
.map((e, i) => <TypeDef key={i} type={e} />)
.interpose(', ')
.toArray(),
]}
{def.implements && [
<span className="t keyword">{' implements '}</span>,
<span className="t keyword"> implements </span>,
Seq(def.implements)
.map((e, i) => <TypeDef key={i} type={e} />)
.interpose(', ')
Expand Down Expand Up @@ -236,7 +236,9 @@ var TypeDef = React.createClass({
<span
className={'t ' + className}
onMouseOver={this.mouseOver}
onFocus={this.mouseOver}
onMouseOut={this.mouseOut}
onBlur={this.mouseOut}
>
{child}
</span>
Expand Down
10 changes: 8 additions & 2 deletions pages/src/docs/src/SideBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ var SideBar = React.createClass({
return (
<div className="sideBar">
<div className="toolBar">
<div onClick={this.props.toggleShowInGroups}>
<div
onClick={this.props.toggleShowInGroups}
onKeyPress={this.props.toggleShowInGroups}
>
<span className={this.props.showInGroups && 'selected'}>
Grouped
</span>
Expand All @@ -26,7 +29,10 @@ var SideBar = React.createClass({
Alphabetized
</span>
</div>
<div onClick={this.props.toggleShowInherited}>
<div
onClick={this.props.toggleShowInherited}
onKeyPress={this.props.toggleShowInherited}
>
<span className={this.props.showInherited && 'selected'}>
Inherited
</span>
Expand Down
8 changes: 3 additions & 5 deletions pages/src/docs/src/TypeDocumentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@ var TypeDocumentation = React.createClass({
},
});

var NotFound = React.createClass({
render() {
return <div>{'Not found'}</div>;
},
});
function NotFound() {
return <div>Not found</div>;
}

var FunctionDoc = React.createClass({
render() {
Expand Down
54 changes: 36 additions & 18 deletions pages/src/src/Logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,65 @@ var Logo = React.createClass({
<path d="M0,0l13.9,0v41.1H0L0,0z" />
<path d="M18.2,0L29,0l10.7,15.8L50.4,0l10.9,0v41.1H48.1V26.3l-8.4,12.3l-8.4-12.3v14.8H18.2V0z" />
<path d="M65.5,0l10.9,0L87,15.8L97.7,0l10.9,0v41.1H95.4V26.3L87,38.7l-8.4-12.3v14.8H65.5V0z" />
<path d="M128.6,42.2c-2.6,0-4.9-0.3-7-1c-2.1-0.7-3.9-1.6-5.4-3c-1.5-1.3-2.6-3-3.4-5c-0.8-2-1.2-4.4-1.2-7.1V0
<path
d="M128.6,42.2c-2.6,0-4.9-0.3-7-1c-2.1-0.7-3.9-1.6-5.4-3c-1.5-1.3-2.6-3-3.4-5c-0.8-2-1.2-4.4-1.2-7.1V0
l13.1,0v25.6c0,1.4,0.3,2.5,0.9,3.3c0.6,0.8,1.6,1.1,3,1.1c1.4,0,2.4-0.4,3-1.1c0.6-0.8,0.9-1.9,0.9-3.3V0l13.2,0v26.1
c0,2.7-0.4,5.1-1.2,7.1c-0.8,2-2,3.7-3.5,5c-1.5,1.3-3.3,2.3-5.4,3C133.5,41.8,131.2,42.2,128.6,42.2z" />
c0,2.7-0.4,5.1-1.2,7.1c-0.8,2-2,3.7-3.5,5c-1.5,1.3-3.3,2.3-5.4,3C133.5,41.8,131.2,42.2,128.6,42.2z"
/>
<path d="M155.4,10.8h-7.6V0l28.7,0v10.8h-7.6v30.3h-13.6V10.8z" />
<path d="M186.4,0l9.9,0l15.6,41.1h-12.9l-1.4-3.7h-12.5l-1.4,3.7h-12.9L186.4,0z M194.1,28.4l-2.8-7.2l-2.8,7.2
H194.1z" />
<path d="M212.9,0L229,0c2.1,0,3.9,0.2,5.6,0.7c1.7,0.5,3.2,1.2,4.4,2.1s2.2,2.1,2.8,3.5c0.7,1.4,1,3,1,4.8
<path
d="M186.4,0l9.9,0l15.6,41.1h-12.9l-1.4-3.7h-12.5l-1.4,3.7h-12.9L186.4,0z M194.1,28.4l-2.8-7.2l-2.8,7.2
H194.1z"
/>
<path
d="M212.9,0L229,0c2.1,0,3.9,0.2,5.6,0.7c1.7,0.5,3.2,1.2,4.4,2.1s2.2,2.1,2.8,3.5c0.7,1.4,1,3,1,4.8
c0,1.3-0.2,2.4-0.5,3.4c-0.3,0.9-0.7,1.7-1,2.3c-0.5,0.7-1,1.4-1.5,1.8c0.9,0.6,1.7,1.3,2.5,2.2c0.6,0.8,1.2,1.8,1.7,3
c0.5,1.2,0.8,2.7,0.8,4.4c0,2-0.3,3.8-1,5.4c-0.7,1.6-1.7,3-3,4.1c-1.3,1.1-2.9,2-4.7,2.6c-1.9,0.6-4,0.9-6.3,0.9h-16.8V0z
M230.2,12.5c0-1.9-1-2.8-3.1-2.8h-1.5v5.7h1.5C229.2,15.4,230.2,14.4,230.2,12.5z M227.1,31.4c3.1,0,4.7-1.2,4.7-3.6
c0-2.4-1.6-3.6-4.7-3.6h-1.5v7.2H227.1z" />
c0-2.4-1.6-3.6-4.7-3.6h-1.5v7.2H227.1z"
/>
<path d="M248.3,0L262,0v30.3h11.3v10.8h-25V0z" />
<path d="M275.3,0l24.2,0v10.8h-11.1v4.6h10.9v10.2h-10.9v4.7H300v10.8h-24.7V0z" />
</g>
) : (
<g fill={this.props.color} style={{ opacity: this.props.opacity }}>
<path d="M0,0l13.9,0v41.1H0L0,0z M7.8,36.2V4.9H6.2v31.3H7.8z" />
<path d="M18.2,0L29,0l10.7,15.8L50.4,0l10.9,0v41.1H48.1V26.3l-8.4,12.3l-8.4-12.3v14.8H18.2V0z M25.9,36.2V7.9
L39.7,28L53.5,7.9v28.3h1.6V4.9h-1.6L39.7,25.2L25.9,4.9h-1.6v31.3H25.9z" />
<path d="M65.5,0l10.9,0L87,15.8L97.7,0l10.9,0v41.1H95.4V26.3L87,38.7l-8.4-12.3v14.8H65.5V0z M73.2,36.2V7.9
L87,28l13.7-20.1v28.3h1.6V4.9h-1.6L87,25.2L73.2,4.9h-1.6v31.3H73.2z" />
<path d="M128.6,42.2c-2.6,0-4.9-0.3-7-1c-2.1-0.7-3.9-1.6-5.4-3c-1.5-1.3-2.6-3-3.4-5c-0.8-2-1.2-4.4-1.2-7.1V0
<path
d="M18.2,0L29,0l10.7,15.8L50.4,0l10.9,0v41.1H48.1V26.3l-8.4,12.3l-8.4-12.3v14.8H18.2V0z M25.9,36.2V7.9
L39.7,28L53.5,7.9v28.3h1.6V4.9h-1.6L39.7,25.2L25.9,4.9h-1.6v31.3H25.9z"
/>
<path
d="M65.5,0l10.9,0L87,15.8L97.7,0l10.9,0v41.1H95.4V26.3L87,38.7l-8.4-12.3v14.8H65.5V0z M73.2,36.2V7.9
L87,28l13.7-20.1v28.3h1.6V4.9h-1.6L87,25.2L73.2,4.9h-1.6v31.3H73.2z"
/>
<path
d="M128.6,42.2c-2.6,0-4.9-0.3-7-1c-2.1-0.7-3.9-1.6-5.4-3c-1.5-1.3-2.6-3-3.4-5c-0.8-2-1.2-4.4-1.2-7.1V0
l13.1,0v25.6c0,1.4,0.3,2.5,0.9,3.3c0.6,0.8,1.6,1.1,3,1.1c1.4,0,2.4-0.4,3-1.1c0.6-0.8,0.9-1.9,0.9-3.3V0l13.2,0v26.1
c0,2.7-0.4,5.1-1.2,7.1c-0.8,2-2,3.7-3.5,5c-1.5,1.3-3.3,2.3-5.4,3C133.5,41.8,131.2,42.2,128.6,42.2z M128.6,34.8
c-6.2,0-9.2-3-9.2-9.1V4.9h-1.6v20.8c0,3.5,0.9,6.1,2.8,7.9c1.9,1.8,4.6,2.7,8,2.7c3.5,0,6.2-0.9,8.1-2.7c1.9-1.8,2.8-4.5,2.8-7.9
V4.9h-1.7v20.8C137.8,31.7,134.8,34.8,128.6,34.8z" />
V4.9h-1.7v20.8C137.8,31.7,134.8,34.8,128.6,34.8z"
/>
<path d="M155.4,10.8h-7.6V0l28.7,0v10.8h-7.6v30.3h-13.6V10.8z M163,36.2V6.4h8.8V4.9h-19.2v1.5h8.8v29.8H163z" />
<path d="M186.4,0l9.9,0l15.6,41.1h-12.9l-1.4-3.7h-12.5l-1.4,3.7h-12.9L186.4,0z M180,36.2l1.2-3.1h20.3l1.2,3.1
h1.7L192.5,4.9h-2.3l-11.9,31.3H180z M191.3,6.4l9.6,25.2h-19.2L191.3,6.4z M194.1,28.4l-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1.1,0.3,2,0.7,2.9,1.2c0.8,0.6,1.5,1.3,1.9,2.2c0.5,0.9,0.7,2,0.7,3.2
c0,2.5-0.8,4.3-2.5,5.4c-1.7,1.1-3.9,1.7-6.6,1.7H220.7z M230.2,12.5c0-1.9-1-2.8-3.1-2.8h-1.5v5.7h1.5
C229.2,15.4,230.2,14.4,230.2,12.5z M227.1,31.4c3.1,0,4.7-1.2,4.7-3.6c0-2.4-1.6-3.6-4.7-3.6h-1.5v7.2H227.1z" />
C229.2,15.4,230.2,14.4,230.2,12.5z M227.1,31.4c3.1,0,4.7-1.2,4.7-3.6c0-2.4-1.6-3.6-4.7-3.6h-1.5v7.2H227.1z"
/>
<path d="M248.3,0L262,0v30.3h11.3v10.8h-25V0z M269.9,36.2v-1.5h-13.8V4.9h-1.6v31.3H269.9z" />
<path d="M275.3,0l24.2,0v10.8h-11.1v4.6h10.9v10.2h-10.9v4.7H300v10.8h-24.7V0z M295.4,36.2v-1.5h-12.3V21.2h11.7
v-1.5h-11.7V6.4h12.3V4.9h-13.9v31.3H295.4z" />
<path
d="M275.3,0l24.2,0v10.8h-11.1v4.6h10.9v10.2h-10.9v4.7H300v10.8h-24.7V0z M295.4,36.2v-1.5h-12.3V21.2h11.7
v-1.5h-11.7V6.4h12.3V4.9h-13.9v31.3H295.4z"
/>
</g>
);
},
Expand Down
3 changes: 2 additions & 1 deletion resources/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ Promise.all([

function it(name, test) {
var fullName = description.join(' > ') + ' ' + name;
(tests[fullName] ||
(
tests[fullName] ||
(tests[fullName] = {
description: fullName,
tests: [],
Expand Down
4 changes: 3 additions & 1 deletion src/CollectionImpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ mixin(Collection, {
toSeq() {
return isIndexed(this)
? this.toIndexedSeq()
: isKeyed(this) ? this.toKeyedSeq() : this.toSetSeq();
: isKeyed(this)
? this.toKeyedSeq()
: this.toSetSeq();
},

toStack() {
Expand Down
12 changes: 9 additions & 3 deletions src/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export class List extends IndexedCollection {
? this
: index === 0
? this.shift()
: index === this.size - 1 ? this.pop() : this.splice(index, 1);
: index === this.size - 1
? this.pop()
: this.splice(index, 1);
}

insert(index, value) {
Expand Down Expand Up @@ -539,7 +541,9 @@ function setListBounds(list, begin, end) {
let newCapacity =
end === undefined
? oldCapacity
: end < 0 ? oldCapacity + end : oldOrigin + end;
: end < 0
? oldCapacity + end
: oldOrigin + end;
if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
return list;
}
Expand Down Expand Up @@ -586,7 +590,9 @@ function setListBounds(list, begin, end) {
let newTail =
newTailOffset < oldTailOffset
? listNodeFor(list, newCapacity - 1)
: newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
: newTailOffset > oldTailOffset
? new VNode([], owner)
: oldTail;

// Merge Tail into tree.
if (
Expand Down
12 changes: 9 additions & 3 deletions src/Operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,9 @@ export function sortFactory(collection, comparator, mapper) {
);
return isKeyedCollection
? KeyedSeq(entries)
: isIndexed(collection) ? IndexedSeq(entries) : SetSeq(entries);
: isIndexed(collection)
? IndexedSeq(entries)
: SetSeq(entries);
}

export function maxFactory(collection, comparator, mapper) {
Expand Down Expand Up @@ -844,14 +846,18 @@ function validateEntry(entry) {
function collectionClass(collection) {
return isKeyed(collection)
? KeyedCollection
: isIndexed(collection) ? IndexedCollection : SetCollection;
: isIndexed(collection)
? IndexedCollection
: SetCollection;
}

function makeSequence(collection) {
return Object.create(
(isKeyed(collection)
? KeyedSeq
: isIndexed(collection) ? IndexedSeq : SetSeq
: isIndexed(collection)
? IndexedSeq
: SetSeq
).prototype
);
}
Expand Down
24 changes: 18 additions & 6 deletions src/Seq.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export class Seq extends Collection {
constructor(value) {
return value === null || value === undefined
? emptySequence()
: isImmutable(value) ? value.toSeq() : seqFromValue(value);
: isImmutable(value)
? value.toSeq()
: seqFromValue(value);
}

toSeq() {
Expand Down Expand Up @@ -92,8 +94,12 @@ export class KeyedSeq extends Seq {
return value === null || value === undefined
? emptySequence().toKeyedSeq()
: isCollection(value)
? isKeyed(value) ? value.toSeq() : value.fromEntrySeq()
: isRecord(value) ? value.toSeq() : keyedSeqFromValue(value);
? isKeyed(value)
? value.toSeq()
: value.fromEntrySeq()
: isRecord(value)
? value.toSeq()
: keyedSeqFromValue(value);
}

toKeyedSeq() {
Expand All @@ -106,7 +112,9 @@ export class IndexedSeq extends Seq {
return value === null || value === undefined
? emptySequence()
: isCollection(value)
? isKeyed(value) ? value.entrySeq() : value.toIndexedSeq()
? isKeyed(value)
? value.entrySeq()
: value.toIndexedSeq()
: isRecord(value)
? value.toSeq().entrySeq()
: indexedSeqFromValue(value);
Expand Down Expand Up @@ -346,7 +354,9 @@ export function keyedSeqFromValue(value) {
? new ArraySeq(value)
: isIterator(value)
? new IteratorSeq(value)
: hasIterator(value) ? new CollectionSeq(value) : undefined;
: hasIterator(value)
? new CollectionSeq(value)
: undefined;
if (seq) {
return seq.fromEntrySeq();
}
Expand Down Expand Up @@ -387,5 +397,7 @@ function maybeIndexedSeqFromValue(value) {
? new ArraySeq(value)
: isIterator(value)
? new IteratorSeq(value)
: hasIterator(value) ? new CollectionSeq(value) : undefined;
: hasIterator(value)
? new CollectionSeq(value)
: undefined;
}
4 changes: 3 additions & 1 deletion src/Set.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ function updateSet(set, newMap) {
}
return newMap === set._map
? set
: newMap.size === 0 ? set.__empty() : set.__make(newMap);
: newMap.size === 0
? set.__empty()
: set.__make(newMap);
}

function makeSet(map, ownerID) {
Expand Down
Loading

0 comments on commit 8f45d0e

Please sign in to comment.