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

Match pact js lint #425

Merged
merged 10 commits into from
Dec 22, 2022
Merged

Conversation

TimothyJones
Copy link
Contributor

This PR is like pact-foundation/pact-js#1027 , except for pact-js-core.

Unfortunately, it's not as well-separated as the previous one. Some key points:

  • The windows build wasn't failing if the build failed. I fixed this.
  • Most of the classes modified the options object they were given (which is probably unexpected behaviour for the caller). I fixed this, but it was actually relied on by the service classes so I had to un-fix it. The tests for those classes weren't testing anything, because if you modify the input config object, then expect(instance.options.foo).to.equal(options.foo) is comparing the object with itself.
    • It's possible that pact-js relies on this behaviour too
  • I've revamped the typescript settings to be much improved
  • I fixed a problem where vscode wouldn't understand the build, because it can't read tsconfig.spec.ts. Unfortunately, this means that the mocha types need to be available to typescript during the main build - although the spec and test files aren't outputted.
  • In src/ffi/types.ts, the recommended lint settings complain about my pattern of merging types and constants (the pattern exists to get around some enum unpleasantness). There's no nice way to whitelist this type of redeclaring, and the docs for the no-redeclare rule say this is intentional. Probably the right fix is to use an enum instead :(
  • Many files had their internal methods used before they were defined
  • I split some files where the linter was complaining about too many classes
  • I split out types.ts to prevent circular dependencies. The pattern is -
    • exported types are in types.ts and not in any other files
    • types can only be imported internally from the relevant types.ts
    • the main index.ts exports all types.ts files. No internal code (except tests) imports from the root (otherwise you get circular dependencies).

Copy link
Member

@mefellows mefellows left a comment

Choose a reason for hiding this comment

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

🎉

"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/dot-notation": [
"error",
{ "allowPattern": "RouteGuide" }
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean? I don't seem to be able to google this or find it on the eslint website?

@@ -1,4 +1,6 @@
#!/bin/bash -e
set -e # Windows bash does not read the #! line above
Copy link
Member

Choose a reason for hiding this comment

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

Of course it doesn't, why would it?

@mefellows mefellows merged commit 49b8181 into pact-foundation:master Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants