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

Handle prop types definitions #66

Closed
15 of 20 tasks
ezhlobo opened this issue Jun 15, 2019 · 3 comments
Closed
15 of 20 tasks

Handle prop types definitions #66

ezhlobo opened this issue Jun 15, 2019 · 3 comments

Comments

@ezhlobo
Copy link
Owner

ezhlobo commented Jun 15, 2019

I'm starting the development of integration with prop-types in react. Here I'm going to provide updates about the progress.

Idea

When we find pug template in the code we will look up to find out where it's located. For now we are interested in functions and classes.

function Component(props) {
  return pug`= props.name`
}

const Component = props => pug`= props.name`

class Component extends React.Component {
  render() {
    return pug`= props.name`
  }
}

We will check out propTypes definitions for those functions and classes and match them with what we use inside them.

Progress

Working branch: prop-types

Items in the checklists will be updated through the time.

  • Functions
    • Grab first-level prop-types definitions
    • Find out first-level props used inside functions
    • Find out first-level props used inside pug
    • Report, when there are definitions for unused props
      • Write comprehensive testing to make sure that we returned all used prop
      • Make it work when we use props in pug templates
    • Report, when there are used props without definition
    • Grab nested prop-types definitions
    • Find out all props used inside functions
  • Anonymous Functions assigned to variable
    • Grab prop-types definitions
    • Find out all props used inside functions
    • Report, when there are used props without definition
    • Report, when there are definitions for unused props
  • Classes
    • Grab prop-types definitions
    • Find out all props used inside functions
    • Report, when there are used props without definition
    • Report, when there are definitions for unused props
@ezhlobo
Copy link
Owner Author

ezhlobo commented Jun 24, 2019

I managed to make it work. At least there is a PoC. I'm going to test it for a while on own projects and then publish.

The first version won't support classes, but it's already useful so it makes sense to publish what we currently have.

@ezhlobo
Copy link
Owner Author

ezhlobo commented Aug 21, 2019

I recently added a fix to support iterations. On real project got an issue that in cases like this:

each item in props.list
  div(item.key)

...we didn't get list.*.key as a used prop. Now it will work as expected.

@ezhlobo
Copy link
Owner Author

ezhlobo commented Aug 23, 2019

Added in v0.8.0

@ezhlobo ezhlobo closed this as completed Aug 23, 2019
@ezhlobo ezhlobo unpinned this issue Aug 23, 2019
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

1 participant