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

Readme, license, build, linting, tests #1

Merged
merged 23 commits into from
Mar 2, 2020
Merged

Conversation

thomasdashney
Copy link
Contributor

@thomasdashney thomasdashney commented Mar 1, 2020

What Changed

  • Added README
  • Added MIT LICENSE
  • Added some more tests to bring coverage to 100%
  • Add eslint and prettier config
  • Add rollup config and build script
  • Enabled typescript "strict" mode and update code accordingly

Breaking changes:

  • Change restful mixin to RestEndpoints class (which extends HttpEndpoints). This was necessary because Typescript was unable to generate definition file typings for the protected mixin methods (see Generating type definitions for mixin classes with protected members microsoft/TypeScript#17744)
  • Prefix all HttpEndpoints and RestEndpoints private & protected methods with an underscore (ie. _get, _post, _list, _create). Non-typescript users won't see that these methods are protected, so the _ prefix will help to indicate that these shouldn't be considered public.
  • Rename RestEndpoints's delete method to destroy. This avoids a naming collision with HttpEndpoints's delete method, which was preventing the ability to call HttpEndpoints's delete in a subclass of RestEndpoints

@thomasdashney thomasdashney requested a review from azmenak March 1, 2020 01:39
@thomasdashney thomasdashney changed the title Readme, license, Build, linting, tests Readme, license, build, linting, tests Mar 1, 2020
@thomasdashney thomasdashney added this to the v1.0.0 beta milestone Mar 1, 2020
.eslintrc.json Outdated
"files": ["**/*.tsx", "**/*.js"]
}
],
"ignorePatterns": ["dist/**/*.js", "dist/**/*.d.ts"],
Copy link

Choose a reason for hiding this comment

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

Nit: could just ignore the whole folder

Suggested change
"ignorePatterns": ["dist/**/*.js", "dist/**/*.d.ts"],
"ignorePatterns": ["dist/**/*"],

.eslintrc.json Outdated
"rules": {
"prettier/prettier": 1,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/interface-name-prefix": [1, {"prefixWithI": "always"}],
Copy link

Choose a reason for hiding this comment

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

I know we use this internally, but IMO its not the best practice for libs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, agreed

"dependencies": {
"eventemitter3": "4.0.0",
"hoist-non-react-statics": "^3.3.2",
"typesafe-actions": "4.4.2"
Copy link

Choose a reason for hiding this comment

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

This version could probably be a lot less strict

Comment on lines +37 to +38
fs.copyFileSync(`${srcDir}/README.md`, `${destDir}/README.md`)
fs.copyFileSync(`${srcDir}/LICENSE`, `${destDir}/LICENSE`)
Copy link

Choose a reason for hiding this comment

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

Any reason these need to be in the dist folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For README.md, yes - I believe this is what shows up on the NPM page as the README (since the dist is what gets published).

For LICENSE - not necessarily, but I figure it doesn't hurt to include it here.

@@ -0,0 +1,44 @@
import resolve from '@rollup/plugin-node-resolve'
Copy link

Choose a reason for hiding this comment

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

Might want to look at something like https://github.com/pikapkg/pack for bundling/distribution. Will eliminate a lot of the boilerplate and deals with creating all the various versions + types that consumers might want to use.

At the very least, any modern lib should expose an ES module, which is what we would be using.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually gave it a shot but was getting weird errors and found it hard to debug. It's possible that some other changes I made afterwards in this PR would have fixed it, but I found it personally easier to use rollup since I've used it before.

I agree thought that Pika looks like it would take the maintenance weight off if.. definitely feel free to submit a PR if you get it running!

Copy link
Contributor Author

@thomasdashney thomasdashney Mar 2, 2020

Choose a reason for hiding this comment

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

Also, incase it was unclear, currently we have an ES tree-shakeable build via tsc: https://bundlephobia.com/[email protected]), as well as a CJS build via rollup if this were to be used in Node (which currently wouldn't work since we use DOM methods such as Headers, but will be helpful if we add SSR support)

@thomasdashney
Copy link
Contributor Author

@azmenak Merging to get this in so we can start using in the d1g1t UI, but feel free to submit a PR or comment on this if there's anything you want to improve.

My next step is to tackle more of the README (#16), add CI and code coverage badge (#2), and submit a PR for smaller changes I want to add (#13, #14, #15). My goal is to get a 1.0.0 beta up sometime this week.

@thomasdashney thomasdashney merged commit f04db72 into master Mar 2, 2020
@thomasdashney thomasdashney deleted the build-and-test branch March 2, 2020 03:33
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