Skip to content

replace tslint by typescript-eslint #1979

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 7 commits into from
Jan 29, 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/pages/generated/**
/dist/**
node_modules
/type-definitions/flow-tests
56 changes: 50 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"extends": ["airbnb", "prettier"],
"plugins": ["react", "prettier"],
"extends": [
"airbnb",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"prettier"
],
"plugins": ["react", "prettier", "@typescript-eslint"],
"rules": {
"array-callback-return": "off",
"block-scoped-var": "off",
Expand Down Expand Up @@ -35,7 +41,7 @@
"no-this-before-super": "off",
"no-underscore-dangle": "off",
"no-unused-expressions": "off",
"no-unused-vars": "error",
"no-unused-vars": "off",
"no-use-before-define": "off",
"no-useless-concat": "error",
"no-var": "error",
Expand All @@ -61,10 +67,15 @@
"react/self-closing-comp": "error",
"react/sort-comp": "off",
"react/jsx-props-no-spreading": "off",
"react/require-default-props": [
"error",
{
"functions": "ignore"
}
],
"jsx-a11y/no-static-element-interactions": "off",
"import/extensions": [
"error",
"always",
{ "js": "never", "ts": "never", "tsx": "never" }
],
"import/newline-after-import": "error",
Expand All @@ -74,6 +85,39 @@
"import/no-unresolved": "error",
"import/no-useless-path-segments": "off",
"import/prefer-default-export": "off",
"prettier/prettier": "error"
}
"prettier/prettier": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
]
},
"overrides": [
{
"files": ["__tests__/*"],
"rules": {
"import/no-unresolved": [
"error",
{
"ignore": ["immutable"]
}
]
}
},

{
"files": ["type-definitions/ts-tests/*"],
"rules": {
"no-lone-blocks": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"prefer-const": "off",
"import/no-unresolved": [
"error",
{
"ignore": ["immutable"]
}
]
}
}
]
}
6 changes: 4 additions & 2 deletions __tests__/Comparator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ const expectedSortedNumbers: readonly number[] = [
7, 95, 90, 92, 3, 5, 9, 4, 6, 10, 12,
];

/* eslint-disable no-else-return */
const testComparator: Comparator<number> = (left, right) => {
//The number 7 always goes first...
if (left == 7) {
if (left === 7) {
return PairSorting.LeftThenRight;
} else if (right == 7) {
} else if (right === 7) {
return PairSorting.RightThenLeft;
}

Expand All @@ -31,6 +32,7 @@ const testComparator: Comparator<number> = (left, right) => {
//...and, finally, sort the numbers of each subgroup in ascending order.
return left - right;
};
/* eslint-enable no-else-return */

describe.each([
['List', List],
Expand Down
17 changes: 10 additions & 7 deletions __tests__/Conversion.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { fromJS, is, List, Map, OrderedMap, Record } from 'immutable';

import * as jasmineCheck from 'jasmine-check';
jasmineCheck.install();

// Symbols
declare function Symbol(name: string): any;
jasmineCheck.install();

describe('Conversion', () => {
// Note: order of keys based on Map's hashing order
Expand Down Expand Up @@ -107,7 +104,9 @@ describe('Conversion', () => {
});

it('Throws when provided circular reference', () => {
const o = { a: { b: { c: null as any } } };
type OType = { a: { b: { c: OType | null } } };

const o: OType = { a: { b: { c: null } } };
o.a.b.c = o;
expect(() => fromJS(o)).toThrow(
'Cannot convert circular structure to Immutable'
Expand All @@ -117,7 +116,8 @@ describe('Conversion', () => {
it('Converts deep JSON with custom conversion', () => {
const seq = fromJS(js, function (key, sequence) {
if (key === 'point') {
return new Point(sequence as any);
// @ts-expect-error -- to convert to real typing
return new Point(sequence);
}
return Array.isArray(this[key])
? sequence.toList()
Expand All @@ -128,7 +128,8 @@ describe('Conversion', () => {
});

it('Converts deep JSON with custom conversion including keypath if requested', () => {
const paths: Array<any> = [];
const paths: Array<Array<string | number> | undefined> = [];
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const seq1 = fromJS(js, function (key, sequence, keypath) {
expect(arguments.length).toBe(3);
paths.push(keypath);
Expand All @@ -147,6 +148,8 @@ describe('Conversion', () => {
['point'],
['list'],
]);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const seq2 = fromJS(js, function (key, sequence) {
expect(arguments[2]).toBe(undefined);
});
Expand Down
10 changes: 6 additions & 4 deletions __tests__/Equality.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { is, List, Map, Seq, Set } from 'immutable';

import * as jasmineCheck from 'jasmine-check';

jasmineCheck.install();

describe('Equality', () => {
Expand Down Expand Up @@ -53,8 +53,8 @@ describe('Equality', () => {
});

it('dereferences things', () => {
const ptrA = { foo: 1 },
ptrB = { foo: 2 };
const ptrA = { foo: 1 };
const ptrB = { foo: 2 };
expectIsNot(ptrA, ptrB);
ptrA.valueOf = ptrB.valueOf = function () {
return 5;
Expand All @@ -66,11 +66,13 @@ describe('Equality', () => {
};
expectIs(ptrA, ptrB);
ptrA.valueOf = ptrB.valueOf = function () {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return null as any;
};
expectIs(ptrA, ptrB);
ptrA.valueOf = ptrB.valueOf = function () {
return void 0 as any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return undefined as any;
};
expectIs(ptrA, ptrB);
ptrA.valueOf = function () {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/IndexedSeq.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Seq } from 'immutable';

import * as jasmineCheck from 'jasmine-check';

jasmineCheck.install();

describe('IndexedSequence', () => {
Expand Down
5 changes: 3 additions & 2 deletions __tests__/KeyedSeq.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Range, Seq } from 'immutable';

import * as jasmineCheck from 'jasmine-check';

jasmineCheck.install();

describe('KeyedSeq', () => {
Expand All @@ -11,7 +11,8 @@ describe('KeyedSeq', () => {
const seqEntries = seq.entries();
const keyedEntries = keyed.entries();

let seqStep, keyedStep;
let seqStep;
let keyedStep;
do {
seqStep = seqEntries.next();
keyedStep = keyedEntries.next();
Expand Down
Loading