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

feat: Move shared types into their own package #425

Merged
merged 17 commits into from May 10, 2019
Merged

feat: Move shared types into their own package #425

merged 17 commits into from May 10, 2019

Conversation

bradzacher
Copy link
Member

@bradzacher bradzacher commented Apr 11, 2019

Fixes #330, #335, #413

Happy to change the name of the package, wasn't sure what to call it.

This PR moves the ESLint override types (and the createRule function) out of the eslint-plugin package and into a new package.

This should make it easier for people to consume our libraries when writing rules they don't want to submit here (because they're internal rules, etc), or when they're writing an eslint plugin in typescript.

@bradzacher bradzacher added the enhancement New feature or request label Apr 11, 2019
@bradzacher bradzacher requested a review from a team April 11, 2019 22:39
@codecov
Copy link

codecov bot commented Apr 12, 2019

Codecov Report

Merging #425 into master will decrease coverage by 0.73%.
The diff coverage is 68.88%.

@@            Coverage Diff            @@
##           master    #425      +/-   ##
=========================================
- Coverage   96.23%   95.5%   -0.74%     
=========================================
  Files          83      88       +5     
  Lines        4067    4093      +26     
  Branches     1149    1150       +1     
=========================================
- Hits         3914    3909       -5     
- Misses         52      82      +30     
- Partials      101     102       +1
Impacted Files Coverage Δ
...ackages/eslint-plugin/src/rules/prefer-includes.ts 100% <ø> (ø) ⬆️
...slint-plugin/src/rules/no-unnecessary-qualifier.ts 96.07% <ø> (ø) ⬆️
packages/eslint-plugin/src/rules/array-type.ts 91.35% <ø> (ø) ⬆️
packages/eslint-plugin/src/rules/member-naming.ts 100% <ø> (ø) ⬆️
...plugin/src/rules/prefer-string-starts-ends-with.ts 100% <ø> (ø) ⬆️
...s/experimental-utils/src/eslint-utils/deepMerge.ts 88.23% <ø> (ø)
packages/typescript-estree/src/ast-converter.ts 100% <ø> (ø) ⬆️
packages/parser/src/scope/scopes.ts 100% <ø> (ø) ⬆️
...xperimental-utils/src/eslint-utils/applyDefault.ts 83.33% <ø> (ø)
...slint-plugin/src/rules/prefer-namespace-keyword.ts 100% <ø> (ø) ⬆️
... and 68 more

@bradzacher bradzacher marked this pull request as ready for review April 27, 2019 03:13
@bradzacher bradzacher requested review from JamesHenry and removed request for a team May 7, 2019 01:00
Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good! I will start using it right away on the stuff I mentioned on slack.

However, please could we call it:

@typescript-eslint/experimental-utils

I think it would be really useful for it to initially not fall under proper semver to give us chance to "move fast and break things" for a bit. As we use it outside the monorepo we might well find things we need to tweak.

So we could have experimental in the name and then a corresponding disclaimer in the README of the package that that is what our plan is. "Feel free to use it, but no guarantees between minor version s"

We can then promote it to be just:

@typescript-eslint/utils

In v2.0.0.

WDYT?

@bradzacher
Copy link
Member Author

@typescript-eslint/experimental-utils

Sounds like a good idea!
I'll make the change now :)

@bradzacher bradzacher mentioned this pull request May 9, 2019
14 tasks
# Conflicts:
#	packages/eslint-plugin/src/rules/no-extra-parens.ts
#	packages/eslint-plugin/tests/RuleTester.ts
#	packages/eslint-plugin/typings/ts-eslint.d.ts
# Conflicts:
#	packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts
# Conflicts:
#	packages/eslint-plugin/tests/RuleTester.ts
#	packages/eslint-plugin/tests/rules/indent/indent.test.ts
#	packages/eslint-plugin/typings/ts-eslint.d.ts
@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed awaiting response Issues waiting for a reply from the OP or another party labels May 9, 2019
@bradzacher bradzacher merged commit a7a03ce into master May 10, 2019
@bradzacher bradzacher deleted the utils-pkg branch May 10, 2019 16:10
@SimenB
Copy link
Contributor

SimenB commented Jun 3, 2019

Hello! 👋

This should make it easier for people to consume our libraries when writing rules they don't want to submit here (because they're internal rules, etc), or when they're writing an eslint plugin in typescript.

I tried to do this, and it broke horribly since the utils depend on typescript. Is that on purpose? I'd like to author the plugin in TS, but that shouldn't be visible to consumers of the plugin.

Sorta related, I got a type error in the test unless I specified the TS parser - are the plugins compatible with the standard parser, or will the type safety be wrong if another parser is used?

Ref jest-community/eslint-plugin-jest#269

@bradzacher
Copy link
Member Author

@SimenB - there's no direct dependency on typescript, but there is a peer dependency:
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/experimental-utils/package.json#L42-L45

The package re-exports some things from typescript-estree via the default entry point
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/experimental-utils/src/index.ts#L9-L14

Which causes the package to init, and it has a dependency of typescript (it's marked as a peer dep to help out the create-react-app folks that do some dual install stuff (#443).

I'll put up a fix so that this doesn't happen.

@SimenB
Copy link
Contributor

SimenB commented Jun 3, 2019

Ah, that's awesome! Thanks.

Thoughts on not specifying parser in RuleTester?

I'd like to run tests with the default eslint parser

@bradzacher
Copy link
Member Author

feel free to open a PR if you want!
I thought about that but was deferring on it till someone complained :)
Happy to have it as a generic so that it is easy to enforce a specific parser string at compile time.

@SimenB
Copy link
Contributor

SimenB commented Jun 3, 2019

Hehe, fair enough! I'll see what I can do

Happy to have it as a generic so that it is easy to enforce a specific parser string at compile time.

How so? I thought to just make it parser?: string

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Publish typescript-eslint utilities for 3rd party plugin authors
5 participants