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

Remove circular imports in typescript code, add linting #1292

Merged
merged 19 commits into from Feb 5, 2021

Conversation

davidjgoss
Copy link
Contributor

Details

Remove circular imports in messages TypeScript code and add eslint-plugin-import to lint against future regressions.

Motivation and Context

See #1279 which this helps with but doesn't close, because we have a similar issue in the protobufjs library.

These issues block us upgrading to webpack 5 in the HTML formatter. Node's module resolution handles them okay and apparently so does webpack 4, but the runtime module resolution seems to have changed somehow with 5.

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • The change has been ported to Java.
  • The change has been ported to Ruby.
  • The change has been ported to JavaScript.
  • The change has been ported to Go.
  • The change has been ported to .NET.
  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have updated the CHANGELOG accordingly.

@davidjgoss
Copy link
Contributor Author

@aslakhellesoy thanks for moving this forward, I hadn't caught on that it would fail unless all eslint configs were the same (this should get easier if we can make npm workspaces happen). I see there are some failures on this rule in gherkin and cucumber-expressions, shall I pick this back up and work on those? (It's not super urgent to fix this, just prevents upgrading to webpack 5.)

@aslakhellesoy
Copy link
Contributor

Hi @davidjgoss yes, that would be great if you could continue the untangling of the circular deps in gherkin and cucumber-expressions.

Thanks!!

@aslakhellesoy aslakhellesoy changed the title messages: remove circular imports in typescript code, add linting Remove circular imports in typescript code, add linting Feb 3, 2021
@aslakhellesoy
Copy link
Contributor

Allright, that's cucumber-expressions done. I'll have a quick go at gherkin too....

@aslakhellesoy
Copy link
Contributor

Gherkin circular dependency:

Screenshot 2021-02-03 at 21 57 35

@aslakhellesoy aslakhellesoy added this to In Progress in Cucumber Open Feb 4, 2021
@aslakhellesoy
Copy link
Contributor

I think Gherkin circulars are gone now - still some small things to fix in cucumber-expressions it seems...

@aslakhellesoy
Copy link
Contributor

You opened a can of worms here @davidjgoss :-)

But I'm glad you did. Keeping code nicely decoupled is something I care deeply about, and this has been an eye opener for me. It's the first time (I think) that I have worked with a system that disallows circular dependencies at the compilation level.

I've not seen it in Java or C# before, or any other language (although I'm sure it exists).

In order to untangle these circular dependencies I was forced to do what I have considered good practice for 15 years - interface-implementation separation. But I don't always practice what I preach, so having a tool that enforces this is great!

I'll be using this on all my TypeScript code from now on I think.

@mpkorstanje is there anything similar in Java that you know of?

@aslakhellesoy aslakhellesoy merged commit cf0aa29 into master Feb 5, 2021
Cucumber Open automation moved this from In Progress to Implemented Feb 5, 2021
@aslakhellesoy aslakhellesoy deleted the html-circular-dep-fix branch February 5, 2021 12:15
@davidjgoss
Copy link
Contributor Author

@aslakhellesoy awesome, thanks for getting it over the line (i.e. the last, er, 99%)

@aslakhellesoy aslakhellesoy moved this from Implemented to Released in Cucumber Open Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants