Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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,
},
};