Skip to content

Commit

Permalink
Upgrade eslint and ignore no-constructor-return rule for actual const…
Browse files Browse the repository at this point in the history
…ructors (#1974)

* Upgrade eslint and ignore no-constructor-return rule for actual constructors

* ignore eslint-next for now
  • Loading branch information
jdeniau committed Jan 26, 2024
1 parent 8c6ea52 commit 7f9ba58
Show file tree
Hide file tree
Showing 14 changed files with 3,555 additions and 1,729 deletions.
5,237 changes: 3,517 additions & 1,720 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Expand Up @@ -92,15 +92,15 @@
"colors": "1.4.0",
"cpy-cli": "3.1.1",
"dtslint": "^4.2.1",
"eslint": "7.29.0",
"eslint-config-airbnb": "18.2.1",
"eslint-config-next": "11.0.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react-hooks": "4.2.0",
"eslint": "^8.56.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-next": "^14.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"flow-bin": "0.160.0",
"jasmine-check": "1.0.0-rc.0",
"jest": "27.2.0",
Expand Down
4 changes: 4 additions & 0 deletions src/Collection.js
Expand Up @@ -6,24 +6,28 @@ import { isAssociative } from './predicates/isAssociative';

export class Collection {
constructor(value) {
// eslint-disable-next-line no-constructor-return
return isCollection(value) ? value : Seq(value);
}
}

export class KeyedCollection extends Collection {
constructor(value) {
// eslint-disable-next-line no-constructor-return
return isKeyed(value) ? value : KeyedSeq(value);
}
}

export class IndexedCollection extends Collection {
constructor(value) {
// eslint-disable-next-line no-constructor-return
return isIndexed(value) ? value : IndexedSeq(value);
}
}

export class SetCollection extends Collection {
constructor(value) {
// eslint-disable-next-line no-constructor-return
return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/List.js
Expand Up @@ -32,20 +32,25 @@ export class List extends IndexedCollection {
constructor(value) {
const empty = emptyList();
if (value === undefined || value === null) {
// eslint-disable-next-line no-constructor-return
return empty;
}
if (isList(value)) {
// eslint-disable-next-line no-constructor-return
return value;
}
const iter = IndexedCollection(value);
const size = iter.size;
if (size === 0) {
// eslint-disable-next-line no-constructor-return
return empty;
}
assertNotInfinite(size);
if (size > 0 && size < SIZE) {
// eslint-disable-next-line no-constructor-return
return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
}
// eslint-disable-next-line no-constructor-return
return empty.withMutations(list => {
list.setSize(size);
iter.forEach((v, i) => list.set(i, v));
Expand Down
1 change: 1 addition & 0 deletions src/Map.js
Expand Up @@ -36,6 +36,7 @@ export class Map extends KeyedCollection {
// @pragma Construction

constructor(value) {
// eslint-disable-next-line no-constructor-return
return value === undefined || value === null
? emptyMap()
: isMap(value) && !isOrdered(value)
Expand Down
1 change: 1 addition & 0 deletions src/OrderedMap.js
Expand Up @@ -10,6 +10,7 @@ export class OrderedMap extends Map {
// @pragma Construction

constructor(value) {
// eslint-disable-next-line no-constructor-return
return value === undefined || value === null
? emptyOrderedMap()
: isOrderedMap(value)
Expand Down
1 change: 1 addition & 0 deletions src/OrderedSet.js
Expand Up @@ -10,6 +10,7 @@ export class OrderedSet extends Set {
// @pragma Construction

constructor(value) {
// eslint-disable-next-line no-constructor-return
return value === undefined || value === null
? emptyOrderedSet()
: isOrderedSet(value)
Expand Down
2 changes: 2 additions & 0 deletions src/Range.js
Expand Up @@ -13,6 +13,7 @@ import deepEqual from './utils/deepEqual';
export class Range extends IndexedSeq {
constructor(start, end, step) {
if (!(this instanceof Range)) {
// eslint-disable-next-line no-constructor-return
return new Range(start, end, step);
}
invariant(step !== 0, 'Cannot step a Range by 0');
Expand All @@ -30,6 +31,7 @@ export class Range extends IndexedSeq {
this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
if (this.size === 0) {
if (EMPTY_RANGE) {
// eslint-disable-next-line no-constructor-return
return EMPTY_RANGE;
}
EMPTY_RANGE = this;
Expand Down
1 change: 1 addition & 0 deletions src/Record.js
Expand Up @@ -104,6 +104,7 @@ export class Record {
RecordType.displayName = name;
}

// eslint-disable-next-line no-constructor-return
return RecordType;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Repeat.js
Expand Up @@ -12,12 +12,14 @@ import deepEqual from './utils/deepEqual';
export class Repeat extends IndexedSeq {
constructor(value, times) {
if (!(this instanceof Repeat)) {
// eslint-disable-next-line no-constructor-return
return new Repeat(value, times);
}
this._value = value;
this.size = times === undefined ? Infinity : Math.max(0, times);
if (this.size === 0) {
if (EMPTY_REPEAT) {
// eslint-disable-next-line no-constructor-return
return EMPTY_REPEAT;
}
EMPTY_REPEAT = this;
Expand Down
4 changes: 4 additions & 0 deletions src/Seq.js
Expand Up @@ -23,6 +23,7 @@ import isArrayLike from './utils/isArrayLike';

export class Seq extends Collection {
constructor(value) {
// eslint-disable-next-line no-constructor-return
return value === undefined || value === null
? emptySequence()
: isImmutable(value)
Expand Down Expand Up @@ -85,6 +86,7 @@ export class Seq extends Collection {

export class KeyedSeq extends Seq {
constructor(value) {
// eslint-disable-next-line no-constructor-return
return value === undefined || value === null
? emptySequence().toKeyedSeq()
: isCollection(value)
Expand All @@ -103,6 +105,7 @@ export class KeyedSeq extends Seq {

export class IndexedSeq extends Seq {
constructor(value) {
// eslint-disable-next-line no-constructor-return
return value === undefined || value === null
? emptySequence()
: isCollection(value)
Expand All @@ -129,6 +132,7 @@ export class IndexedSeq extends Seq {

export class SetSeq extends Seq {
constructor(value) {
// eslint-disable-next-line no-constructor-return
return (
isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value)
).toSetSeq();
Expand Down
1 change: 1 addition & 0 deletions src/Set.js
Expand Up @@ -15,6 +15,7 @@ export class Set extends SetCollection {
// @pragma Construction

constructor(value) {
// eslint-disable-next-line no-constructor-return
return value === undefined || value === null
? emptySet()
: isSet(value) && !isOrdered(value)
Expand Down
1 change: 1 addition & 0 deletions src/Stack.js
Expand Up @@ -13,6 +13,7 @@ export class Stack extends IndexedCollection {
// @pragma Construction

constructor(value) {
// eslint-disable-next-line no-constructor-return
return value === undefined || value === null
? emptyStack()
: isStack(value)
Expand Down
6 changes: 6 additions & 0 deletions website/next.config.js
@@ -1,4 +1,10 @@
module.exports = {
reactStrictMode: true,
trailingSlash: true,

// as next eslint config does not work with eslint 8.
// TODO Waiting for nextjs upgrade to reactive this
eslint: {
ignoreDuringBuilds: true,
},
};

0 comments on commit 7f9ba58

Please sign in to comment.