Skip to content

Commit

Permalink
chore: migrate to expecttype eslint rules
Browse files Browse the repository at this point in the history
This migrates to using an eslint plugin for `$ExpectType` and friends so
we can do it as part of the lint script.

For now, `typescript` had to be added to the root project since the rxjs
site is still on an older typescript which confuses eslint (since it
ends up being hoisted by yarn).
  • Loading branch information
43081j committed Jan 23, 2024
1 parent c666574 commit 5af28f7
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 79 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ jobs:
run: yarn workspace rxjs build
- name: rxjs test
run: yarn workspace rxjs test
- name: rxjs dtslint
run: yarn workspace rxjs dtslint
- name: rxjs test:import
run: yarn workspace rxjs test:import
- name: rxjs test:esm
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dependencies": {},
"devDependencies": {
"@nx/js": "17.3.0-beta.4",
"nx": "17.3.0-beta.4"
"nx": "17.3.0-beta.4",
"typescript": "~4.9.4"
}
}
7 changes: 3 additions & 4 deletions packages/rxjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"scripts": {
"changelog": "npx conventional-changelog-cli -p angular -i CHANGELOG.md -s",
"lint": "eslint --ext=ts,js src spec spec-dtslint",
"dtslint": "npm run lint && tsc -b ./src/tsconfig.types.json",
"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",
"test:circular": "dependency-cruiser --validate .dependency-cruiser.json -x \"^node_modules\" dist/esm",
Expand All @@ -83,7 +82,6 @@
"build:clean": "shx rm -rf ./dist",
"build": "yarn build:clean && yarn compile && node ./tools/generate-alias.js",
"watch": "nodemon -w \"src/\" -w \"spec/\" -e ts -x npm test",
"watch:dtslint": "nodemon -w \"src/\" -w \"spec-dtslint/\" -e ts -x yarn dtslint",
"copy_common_package_files": "node ../../scripts/copy-common-package-files.js"
},
"repository": {
Expand Down Expand Up @@ -143,15 +141,16 @@
"@types/shelljs": "^0.8.8",
"@types/sinon": "^10.0.13",
"@types/sinon-chai": "^3.2.9",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.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": "^8.52.0",
"eslint-plugin-expect-type": "^0.3.0",
"form-data": "^3.0.0",
"fs-extra": "^8.1.0",
"husky": "^4.2.5",
Expand Down
8 changes: 8 additions & 0 deletions packages/rxjs/spec-dtslint/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"plugin:expect-type/recommended"
],
"plugins": [
"expect-type"
]
}
2 changes: 1 addition & 1 deletion packages/rxjs/spec-dtslint/firstValueFrom-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { firstValueFrom } from 'rxjs';
import { a$ } from 'helpers';
import { a$ } from './helpers';

describe('firstValueFrom', () => {
it('should infer the element type', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/rxjs/spec-dtslint/lastValueFrom-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { lastValueFrom } from 'rxjs';
import { a$ } from 'helpers';
import { a$ } from './helpers';

describe('lastValueFrom', () => {
it('should infer the element type', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/rxjs/spec-dtslint/observables/forkJoin-spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { a$, b$, c$ } from 'helpers';
import { a$, b$, c$ } from '../helpers';
import { of, forkJoin } from 'rxjs';

describe('deprecated rest args', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/rxjs/spec-dtslint/observables/iif-spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { a$, b$ } from 'helpers';
import { a$, b$ } from '../helpers';
import { iif, EMPTY } from 'rxjs';

const randomBoolean = () => Math.random() > 0.5;
Expand Down Expand Up @@ -31,4 +31,4 @@ it('should support inference from a predicate that returns any', () => {
}

const o$ = iif(alwaysTrueButReturnsAny, a$, b$) // $ExpectType Observable<A | B>
});
});
2 changes: 1 addition & 1 deletion packages/rxjs/spec-dtslint/operators/concatWith-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { of } from 'rxjs';
import { concatWith } from 'rxjs/operators';
import { a$, b$, c$, d$, e$ } from 'helpers';
import { a$, b$, c$, d$, e$ } from '../helpers';

it('should support rest params', () => {
const arr = [b$, c$];
Expand Down
Loading

0 comments on commit 5af28f7

Please sign in to comment.