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

Project standards and conventions #1383

Closed
8 of 12 tasks
larrybotha opened this issue Jul 1, 2019 · 20 comments
Closed
8 of 12 tasks

Project standards and conventions #1383

larrybotha opened this issue Jul 1, 2019 · 20 comments

Comments

@larrybotha
Copy link
Contributor

larrybotha commented Jul 1, 2019

Hey @tannerlinsley, loving react-table and would love to contribute and make things easier for you and contributors, so I'd like to open a discussion and see if you're happy to work with a checklist of standards and conventions to introduce.

Todo

Tasks are ordered by ease of implementation / impact on maintenance and reliability.

  1. Code formatting
    1. 1. add prettierrc.js to normalise prettier configs across all contributors setup
    2. 2. use husky to automate formatting of code for contributors not using prettier without having to install prettier
  2. Testing
    1. 1. add custom jest.config.js for more flexibility over test configs (remove react-scripts dep?)
    2. 2. add @testing-library/react for awesome testing
    3. 3. add separate jest projects for unit testing and linting, as well as jest-watch-select-projects for switching between watched tests quickly
    4. 4. add jest-watch-typeahead for faster selection of test files to run
    5. 5. add is-ci-cli so that a single npm test script can be run for local watched testing while CI runs through tests once
  3. Commit message formatting
    1. add commitizen to introduce a standard for commit messages to allow for automated semantic releases and generated changelogs
  4. Changelog
    1. 1. generate changelog using conventional-changelog to save time, automate linking to issues from commitizen-formatted commits
  5. Semantic releases
    1. 1. add semantic-release and configure Travis to automate semantic versioning based on commit messages. Ensure latest commit is tagged before installing.
  6. Code coverage
    1. 1. update Travis to send code coverage results to codecov.io or similar on successful builds
  7. TypeScript
    1. rewrite code in TypeScript, or (at least)
    1. add TypeScript module declarations

Let me know what you think about each point; will be happy to get working on the list as soon as you're happy!

@tannerlinsley
Copy link
Collaborator

I agree full-heartedly with every single point, with the exception of rewriting in typescript. Long story short, I'm not ready to full full typescript on open source code yet, but fully support having definitions.

@larrybotha
Copy link
Contributor Author

@tannerlinsley understood - I'll keep the 2nd TS point in there as it's useful for consumers of react-table.

Will update the list, and get cracking on a couple :)

@larrybotha larrybotha changed the title Chat about project standards / conventions Project standards and conventions Jul 1, 2019
larrybotha added a commit to larrybotha/react-table that referenced this issue Jul 1, 2019
larrybotha added a commit to larrybotha/react-table that referenced this issue Jul 1, 2019
larrybotha added a commit to larrybotha/react-table that referenced this issue Jul 1, 2019
…eact-table into feature/add-prettier-config

* 'feature/add-prettier-config' of github.com:larrybotha/react-table:
  install and configure lint-staged and husky - ref 1.2 in TanStack#1383
  write files with prettier
  add prettier config
tannerlinsley pushed a commit that referenced this issue Jul 2, 2019
* add prettier config

* write files with prettier

* install and configure lint-staged and husky - ref 1.2 in #1383

* feat(style): add prettier configs, ref 1.1 & 1.2 in #1383
larrybotha added a commit to larrybotha/react-table that referenced this issue Jul 2, 2019
# Via Tanner Linsley
* master:
  Feature/add prettier config, ref TanStack#1383 (TanStack#1384)

# Conflicts:
#	package.json
#	yarn.lock
tannerlinsley pushed a commit that referenced this issue Jul 15, 2019
* add deps for testing

* feat(tests): add jest configs

* uncomment module directories path
@nmccready
Copy link

One thing that makes the barrier of entry into typescript a whole lot easier and friendly is using Babel to compile it instead. It's much more forgiving.
https://babeljs.io/docs/en/babel-preset-typescript

@tannerlinsley
Copy link
Collaborator

@nmccready, Yes. When we bring in TS, we'll probably compile it using babel.

larrybotha added a commit to larrybotha/react-table that referenced this issue Jul 26, 2019
use `npm run commit` to use commitizen for better commit messages

re TanStack#1383
tannerlinsley pushed a commit that referenced this issue Jul 26, 2019
use `npm run commit` to use commitizen for better commit messages

re #1383
@tannerlinsley
Copy link
Collaborator

@larrybotha, I've set up some failing tests in master. Not sure why they aren't running correctly. Any ideas?

@larrybotha
Copy link
Contributor Author

@tannerlinsley will have a look and get back to you :)

@larrybotha
Copy link
Contributor Author

PR here: #1417

Required a few small tweaks to babel configs and versions. You'll see useTable passes now on all but one test.

I noticed you've got commit: "git commit" in packages.json. No biggie, but git-cz makes writing conventional commits super easy, but that's up to you :)

I'm using $ $(npm bin)/git-cz directly for the commitizen prompts.

@tannerlinsley
Copy link
Collaborator

Awesome!

I absolutely want to use git-cz. Still just trying to figure out the workflow we were talking about in #1410, how to enforce it, etc.

@larrybotha
Copy link
Contributor Author

Want me to tackle enforcing the commit convention?

@tannerlinsley
Copy link
Collaborator

I would love that :)

@larrybotha
Copy link
Contributor Author

Great, will get on it this evening :)

@tannerlinsley
Copy link
Collaborator

How can we generate the changelog and do the rest of these awesome things you have on this issue?

@larrybotha
Copy link
Contributor Author

@tannerlinsley will get on this this evening. I need to do some evaluation on how alpha releases work with commitizen-changelog and semantic-release. I imagine the complexity has been accounted for, but I'll let you know

@tannerlinsley
Copy link
Collaborator

Awesome. Thanks for your help man. If I can do anything to help, let me know.

@larrybotha
Copy link
Contributor Author

Only a pleasure; I'll let you know.

Wow, you're tearing through those issues and PRs like a monster - 2 issues (this included), and 0 PRs outstanding!

@paolostyle
Copy link
Contributor

paolostyle commented Aug 21, 2019

I could help with TypeScript typings - I already have some, because my whole project is written in TypeScript, though they're rather low effort for now (way too many anys); however I think it would be best to wait until at least beta, currently a lot of stuff is changing rather dynamically. I'm also wondering whether they should be in this repo or rather in DefinitelyTyped, generally it's recommended to only have type definitions in library's repo if it's written in TypeScript or if the types are generated automatically (probably based on JSDocs or something like this? not sure). So it would probably make sense to have it on DefinitelyTyped.

@larrybotha
Copy link
Contributor Author

@paolostyle I agree; waiting for beta is a good idea. I'm not sure about where is best to host the definitions. I suppose there are a few things to consider, depending on the route taken.

Managed here

  • pros
    • types and source are managed in a single repo
      • easier to maintain
    • users install a single module for both the library and definitions
    • may be able to benefit from generating a declaration file
      • perhaps start with dts-gen
      • generate declaration file from JsDoc comments using tsd-jsdoc
  • cons
    • generating a declaration file may result in incorrect declaration files

Managed on DefinitelyTyped

  • pros
    • follows the recommended approach (which benefits make it the recommended approach? is it pragmatic to follow the recommendation, or is it idealistic?)
  • cons
    • declaration file is in a separate repo
      • someone needs to remember that there is another repo that needs updating
      • additional work required to work in multiple repos

Issues common to both strategies

  • ensuring types do not become stale (I've resorted to monkey-patching libraries that are written in JS that have stale declaration files; not a great experience for users)

I haven't looked into it deeply to determine what other strategies there may be to make this as painless to maintain as possible, while providing the best UX for users, so there may well be better or more reliable tools than what I've listed here.

Alternatively, a smaller benefit with lower overhead may be to use JsDoc and suggest TypeScript users enable checkJs, as per this article. I'm not sure if this works for editors other than VSCode (I don't use VSCode), or if it'll introduce issues with other js libs that have incorrect JsDoc declarations, however.

@tannerlinsley
Copy link
Collaborator

Just had a discussion about this here: https://spectrum.chat/react-table/general/the-types-for-typescript-are-outdated~79730c66-b5f8-48f0-b8d9-a187c3d2f435

TLDR, I would like the types to be kept over at DefinitelyTyped and distributed via @types/react-table. Then all we need to do is add that as a dependency in React Table and we're good to go.

My reasoning: https://blog.johnnyreilly.com/2019/08/symbiotic-definitely-typed.html, someday RT will be TS, but tomorrow is likely not that day.

@m-rutter
Copy link

m-rutter commented Aug 28, 2019

On the topic of typescript declarations, there are a handful of github gists out in the wild attempting to provide type declarations for v7, such as this: https://gist.github.com/Grsmto/1ac3a7ddb8ad8288660784a37bff1798 The usefulness of these attempts is limited because of the use of the any type.

I might try writing my own declaration file in my current project that attempts to do better about inferring the types with generics, but it might help if the WIP v7 documentation for the public API were a little more fine grained in terms of the function types.

EDIT:
I'm guessing this will come with the first beta once the public API stabilizes.

@tannerlinsley
Copy link
Collaborator

I think this can be closed now as long as we track the rest of the items in their own issues like #1467

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

No branches or pull requests

5 participants