Skip to content
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

chore: migrate to eslint #7368

Merged
merged 2 commits into from
Nov 20, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*]
end_of_line = lf
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
122 changes: 0 additions & 122 deletions packages/rxjs/.eslintrc

This file was deleted.

24 changes: 24 additions & 0 deletions packages/rxjs/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off",
"no-prototype-builtins": "off"
},
"env": {
"browser": true,
"node": true
},
"overrides": [
{
"files": "spec/**/*.js",
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
}
20 changes: 6 additions & 14 deletions packages/rxjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,15 @@
"lint-staged": {
"*.js": "eslint --cache --fix",
"(src|spec)/**/*.ts": [
"tslint --fix",
"eslint --fix",
"prettier --write"
],
"*.{js,css,md}": "prettier --write"
},
"scripts": {
"changelog": "npx conventional-changelog-cli -p angular -i CHANGELOG.md -s",
"lint_spec": "tslint -c spec/tslint.json -p spec/tsconfig.json \"spec/**/*.ts\"",
"lint_src": "tslint -c tslint.json -p src/tsconfig.base.json \"src/**/*.ts\"",
"lint": "npm-run-all --parallel lint_*",
"dtslint": "tsc -b ./src/tsconfig.types.json && tslint -c spec-dtslint/tslint.json -p spec-dtslint/tsconfig.json \"spec-dtslint/**/*.ts\"",
"lint": "eslint --ext=ts,js src spec spec-dtslint",
"dtslint": "npm run lint && tsc -b ./src/tsconfig.types.json",
"prepublishOnly": "yarn build && yarn lint && yarn test && yarn test:circular && yarn dtslint && yarn copy_common_package_files",
"test": "yarn build && cross-env TS_NODE_PROJECT=tsconfig.mocha.json mocha --config spec/support/.mocharc.js \"spec/**/*-spec.ts\"",
"test:esm": "node spec/module-test-spec.mjs",
Expand Down Expand Up @@ -145,16 +143,15 @@
"@types/shelljs": "^0.8.8",
"@types/sinon": "^10.0.13",
"@types/sinon-chai": "^3.2.9",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"chai": "^4.3.7",
"color": "3.0.0",
"colors": "1.1.2",
"cross-env": "5.1.3",
"cz-conventional-changelog": "1.2.0",
"dependency-cruiser": "^9.12.0",
"eslint": "^7.8.1",
"eslint-plugin-jasmine": "^2.10.1",
"eslint": "^8.52.0",
"form-data": "^3.0.0",
"fs-extra": "^8.1.0",
"husky": "^4.2.5",
Expand All @@ -170,11 +167,6 @@
"sinon-chai": "^3.7.0",
"source-map-support": "0.5.3",
"ts-node": "^10.9.1",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-etc": "1.13.10",
"tslint-no-toplevel-property-access": "0.0.2",
"tslint-no-unused-expression-chai": "0.0.3",
"typescript": "~4.9.4",
"validate-commit-msg": "2.14.0",
"web-streams-polyfill": "^3.0.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ it('should handle observable inputs okay', () => {
const o1 = onErrorResumeNext([1, 2, 3, 'test'], Promise.resolve(true)); // $ExpectType Observable<string | number | boolean>
const o2 = onErrorResumeNext( // $ExpecType Observable<string>
(function* () {
yield 'foo';
return 'test';
})()
);
Expand Down
2 changes: 1 addition & 1 deletion packages/rxjs/spec-dtslint/operators/delay-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ it('should infer correctly', () => {
});

it('should support date parameter', () => {
const o = of(1, 2, 3).pipe(delay(new Date(2018, 09, 18))); // $ExpectType Observable<number>
const o = of(1, 2, 3).pipe(delay(new Date(2018, 9, 18))); // $ExpectType Observable<number>
});

it('should support a scheduler', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/rxjs/spec-dtslint/operators/groupBy-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ it('should support a duration selector', () => {
});

it('should infer type of duration selector based on element selector', () => {
/* tslint:disable-next-line:max-line-length */
const o = of(1, 2, 3).pipe(groupBy(value => value.toString(), value => Boolean(value), (value: GroupedObservable<string, boolean>) => value)); // $ExpectType Observable<GroupedObservable<string, boolean>>
});

Expand Down
8 changes: 0 additions & 8 deletions packages/rxjs/spec-dtslint/tslint.json

This file was deleted.

28 changes: 14 additions & 14 deletions packages/rxjs/spec-dtslint/types-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,76 +12,76 @@ import { A, B, C } from './helpers';
describe('ObservedValueOf', () => {
it('should infer from an observable', () => {
let explicit: ObservedValueOf<Observable<A>>;
let inferred = explicit!; // $ExpectType A
const inferred = explicit!; // $ExpectType A
});

it('should infer from an array', () => {
let explicit: ObservedValueOf<A[]>;
let inferred = explicit!; // $ExpectType A
const inferred = explicit!; // $ExpectType A
});

it('should infer from a promise', () => {
let explicit: ObservedValueOf<Promise<A>>;
let inferred = explicit!; // $ExpectType A
const inferred = explicit!; // $ExpectType A
});
});

describe('ObservedUnionFromArray', () => {
it('should infer from an array of observables', () => {
let explicit: ObservedValueUnionFromArray<[Observable<A>, Observable<B>]>;
let inferred = explicit!; // $ExpectType A | B
const inferred = explicit!; // $ExpectType A | B
});

it('should infer from an array of arrays', () => {
let explicit: ObservedValueUnionFromArray<[A[], B[]]>;
let inferred = explicit!; // $ExpectType A | B
const inferred = explicit!; // $ExpectType A | B
});

it('should infer from an array of promises', () => {
let explicit: ObservedValueUnionFromArray<[Promise<A>, Promise<B>]>;
let inferred = explicit!; // $ExpectType A | B
const inferred = explicit!; // $ExpectType A | B
});
});

describe('ObservedTupleFromArray', () => {
it('should infer from an array of observables', () => {
let explicit: ObservedValueTupleFromArray<[Observable<A>, Observable<B>]>;
let inferred = explicit!; // $ExpectType [A, B]
const inferred = explicit!; // $ExpectType [A, B]
});

it('should infer from an array of arrays', () => {
let explicit: ObservedValueTupleFromArray<[A[], B[]]>;
let inferred = explicit!; // $ExpectType [A, B]
const inferred = explicit!; // $ExpectType [A, B]
});

it('should infer from an array of promises', () => {
let explicit: ObservedValueTupleFromArray<[Promise<A>, Promise<B>]>;
let inferred = explicit!; // $ExpectType [A, B]
const inferred = explicit!; // $ExpectType [A, B]
});
});

describe('Cons', () => {
it('should construct a tuple with the specified type at the head', () => {
let explicit: Cons<A, [B, C]>;
let inferred = explicit!; // $ExpectType [A, B, C]
const inferred = explicit!; // $ExpectType [A, B, C]
});

it('should support rest tuples', () => {
let explicit: Cons<A, B[]>;
let inferred = explicit!; // $ExpectType [arg: A, ...rest: B[]]
const inferred = explicit!; // $ExpectType [arg: A, ...rest: B[]]
});
});

describe('Head', () => {
it('should return the head of a tuple', () => {
let explicit: Head<[A, B, C]>;
let inferred = explicit!; // $ExpectType A
const inferred = explicit!; // $ExpectType A
});
});

describe('Tail', () => {
it('should return the tail of a tuple', () => {
let explicit: Tail<[A, B, C]>;
let inferred = explicit!; // $ExpectType [B, C]
const inferred = explicit!; // $ExpectType [B, C]
});
});
});
2 changes: 1 addition & 1 deletion packages/rxjs/spec/Observable-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('Observable', () => {
};
});

let observer = {
const observer = {
next: function () {
/*noop*/
},
Expand Down
10 changes: 5 additions & 5 deletions packages/rxjs/spec/helpers/marble-testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function hot<V>(marbles: string, values?: { [index: string]: V } | void,
if (!global.rxTestScheduler) {
throw 'tried to use hot() in async test';
}
return global.rxTestScheduler.createHotObservable.apply(global.rxTestScheduler, arguments);
return global.rxTestScheduler.createHotObservable.call(global.rxTestScheduler, marbles, values, error);
}

export function cold(marbles: string, values?: void, error?: any): ColdObservable<string>;
Expand All @@ -21,26 +21,26 @@ export function cold(marbles: string, values?: any, error?: any): ColdObservable
if (!global.rxTestScheduler) {
throw 'tried to use cold() in async test';
}
return global.rxTestScheduler.createColdObservable.apply(global.rxTestScheduler, arguments);
return global.rxTestScheduler.createColdObservable.call(global.rxTestScheduler, marbles, values, error);
}

export function expectObservable(observable: Observable<any>, unsubscriptionMarbles: string | null = null): { toBe: observableToBeFn } {
if (!global.rxTestScheduler) {
throw 'tried to use expectObservable() in async test';
}
return global.rxTestScheduler.expectObservable.apply(global.rxTestScheduler, arguments);
return global.rxTestScheduler.expectObservable.call(global.rxTestScheduler, observable, unsubscriptionMarbles);
}

export function expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): { toBe: subscriptionLogsToBeFn } {
if (!global.rxTestScheduler) {
throw 'tried to use expectSubscriptions() in async test';
}
return global.rxTestScheduler.expectSubscriptions.apply(global.rxTestScheduler, arguments);
return global.rxTestScheduler.expectSubscriptions.call(global.rxTestScheduler, actualSubscriptionLogs);
}

export function time(marbles: string): number {
if (!global.rxTestScheduler) {
throw 'tried to use time() in async test';
}
return global.rxTestScheduler.createTime.apply(global.rxTestScheduler, arguments);
return global.rxTestScheduler.createTime.call(global.rxTestScheduler, marbles);
}