Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Publish expect tslint rule independently #126

Open
OliverJAsh opened this issue Jul 14, 2018 · 7 comments
Open

Publish expect tslint rule independently #126

OliverJAsh opened this issue Jul 14, 2018 · 7 comments

Comments

@OliverJAsh
Copy link
Contributor

It would be useful to have the expect tslint rule published independently, so it can be used in tslint projects. palantir/tslint#2114

Would this be difficult to do, or is it just a case of moving the rule into a separate project and publishing?

@eps1lon
Copy link
Contributor

eps1lon commented Aug 2, 2018

As a temporary workaround you should be able to install dtslint and add

    "rules": {
        "expect": true
    },
    "rulesDirectory": [
        "./node_modules/dtslint/bin/rules"
    ]

to your tslint.json. You just have to be careful with mixing typescript versions since dtslint currently list typescript as a direct dependency.

@OliverJAsh
Copy link
Contributor Author

Thanks @eps1lon. When running tslint, it seesm to use the version of TS installed by dtslint. Is there any way to make it use the local version at the top level of node_modules?

@eps1lon
Copy link
Contributor

eps1lon commented Sep 9, 2019

Thanks @eps1lon. When running tslint, it seesm to use the version of TS installed by dtslint. Is there any way to make it use the local version at the top level of node_modules?

@OliverJAsh You could use the resolutions field if you're using yarn. I don't use other package managers at the moment so I wouldn't know how to achieve something similar with npm or pnpm.

@OliverJAsh
Copy link
Contributor Author

OliverJAsh commented Oct 16, 2019

@eps1lon Thanks, I'm doing that but for some reason dtslint still reports the version as next, even though it's not installed anywhere in my node_modules:

TypeScript@next expected type to be:

@OliverJAsh
Copy link
Contributor Author

Ah, it's because the string is hardcoded here.

walk(ctx, lintProgram, TsType, "next", /*nextHigherVersion*/ undefined));

It is using the local version, however, so all is good.

@OliverJAsh
Copy link
Contributor Author

I created a small example project to demonstrate how you can use the TSLint expect rule, independently of dtslint: https:/unsplash/ts-type-tests-example

@OliverJAsh
Copy link
Contributor Author

We've had a lot of success with https://www.npmjs.com/package/eslint-plugin-expect-type.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants