GithubHelp home page GithubHelp logo

layershifter / babel-plugin-transform-react-handled-props Goto Github PK

View Code? Open in Web Editor NEW
19.0 3.0 4.0 972 KB

Generates handledProps from defaultProps and propTypes during the build :sparkles:

License: MIT License

JavaScript 100.00%
babel-plugin proptypes

babel-plugin-transform-react-handled-props's People

Contributors

greenkeeper[bot] avatar layershifter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

babel-plugin-transform-react-handled-props's Issues

RFC: Enhancements and ideas for future

Preamble

I this issue I wan't collect and structure all ideas and enhancements for major release of plugin, make plan for them and implement them step-by-step.

Options

properties

I'm thinked about properties option to plugin that will allow to define properties for collecting props.

{
  "plugins": [
    ["transform-react-handled-props", {"properties": ["hiddenProps"]}]
  ]
}

In:

const Example = () => <div />

Example.hiddenProps = ['children']
Example.propTypes = {
  className: propTypes.string
}

Out:

const Example = () => <div />

Example.handledProps = ['children', 'className']
Example.hiddenProps = ['children']
Example.propTypes = {
  className: propTypes.string
}

It may be usefull for cases like SUIR's AutoControlledComponent.

resolve

#TODO


Jobs

The plugin performs the following steps to make changes:

  • scans for React's import;
  • scans for possible React components;
  • collects properties;
  • adds collected array of handledProps.

Scan for React's import

It's pretty simple step and I think, that we don't need modify it at all. I think we should stick to the theorem that if there is no import, the file doesn't contain anything related to React components.

To be continued...

Broken in higher-order components

I tried using this plugin in my project but got the following error when compiling higher-order components:

We don't know what to do with this node type. We were previously a Statement but we can't fit in here?
    at NodePath.insertAfter (~/babel-traverse/lib/path/modification.js:175:13)
    at insertAfterPath (~/node_modules/babel-plugin-transform-react-handled-props/lib/util/appendProps.js:50:27)
    at ~/node_modules/babel-plugin-transform-react-handled-props/lib/util/appendProps.js:59:5

Here is a snippet reproducing the problem:

import React from 'react';

export default function WithSauce(options = {}) {
  return function createContainer(Component) {
    return class Sauce extends React.Component {
      render() {
        return (
          <Component className="sauced" />
        );
      }
    };
  };
}

I tried changing my syntax a bit and got a different problem (possibly unrelated)

export default (options) => (Component) => class WithSauce extends React.Component { [...] }

Transpiled to:

module.exports = function (options) {
  return function (Component) {
    return function WithSauce() { [...] }
  }
}

WithSauce.handledProps = []; // Error: WithSauce is not defined.

Let me know if there is anything else I can help with to identify the root cause.

An in-range update of eslint is breaking the build ๐Ÿšจ

Version 4.14.0 of eslint was just published.

Branch Build failing ๐Ÿšจ
Dependency eslint
Current Version 4.13.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v4.14.0
  • be2f57e Update: support separate requires in one-var. (fixes #6175) (#9441) (่–›ๅฎš่ฐ”็š„็Œซ)
  • 370d614 Docs: Fix typos (#9751) (Jed Fox)
  • 8196c45 Chore: Reorganize CLI options and associated docs (#9758) (Kevin Partington)
  • 75c7419 Update: Logical-and is counted in complexity rule (fixes #8535) (#9754) (Kevin Partington)
  • eb4b1e0 Docs: reintroduce misspelling in valid-typeof example (#9753) (Teddy Katz)
  • ae51eb2 New: Add allowImplicit option to array-callback-return (fixes #8539) (#9344) (James C. Davis)
  • e9d5dfd Docs: improve no-extra-parens formatting (#9747) (Rich Trott)
  • 37d066c Chore: Add unit tests for overrides glob matching. (#9744) (Robert Jackson)
  • 805a94e Chore: Fix typo in CLIEngine test name (#9741) (@scriptdaemon)
  • 1c2aafd Update: Improve parser integrations (fixes #8392) (#8755) (Toru Nagashima)
  • 4ddc131 Upgrade: debug@^3.1.0 (#9731) (Kevin Partington)
  • f252c19 Docs: Make the lint message source property a little more subtle (#9735) (Jed Fox)
  • 5a5c23c Docs: fix the link to contributing page (#9727) (Victor Hom)
  • f44ce11 Docs: change beginner to good first issue label text (#9726) (Victor Hom)
  • 14baa2e Chore: improve arrow-body-style error message (refs #5498) (#9718) (Teddy Katz)
  • f819920 Docs: fix typos (#9723) (Thomas Broadley)
  • 43d4ba8 Fix: false positive on rulelines-between-class-members (fixes #9665) (#9680) (sakabar)
Commits

The new version differs by 19 commits.

  • 8d166b4 4.14.0
  • 5a29612 Build: changelog update for 4.14.0
  • be2f57e Update: support separate requires in one-var. (fixes #6175) (#9441)
  • 370d614 Docs: Fix typos (#9751)
  • 8196c45 Chore: Reorganize CLI options and associated docs (#9758)
  • 75c7419 Update: Logical-and is counted in complexity rule (fixes #8535) (#9754)
  • eb4b1e0 Docs: reintroduce misspelling in valid-typeof example (#9753)
  • ae51eb2 New: Add allowImplicit option to array-callback-return (fixes #8539) (#9344)
  • e9d5dfd Docs: improve no-extra-parens formatting (#9747)
  • 37d066c Chore: Add unit tests for overrides glob matching. (#9744)
  • 805a94e Chore: Fix typo in CLIEngine test name (#9741)
  • 1c2aafd Update: Improve parser integrations (fixes #8392) (#8755)
  • 4ddc131 Upgrade: debug@^3.1.0 (#9731)
  • f252c19 Docs: Make the lint message source property a little more subtle (#9735)
  • 5a5c23c Docs: fix the link to contributing page (#9727)

There are 19 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of mocha is breaking the build ๐Ÿšจ

Version 3.4.0 of mocha just got published.

Branch Build failing ๐Ÿšจ
Dependency mocha
Current Version 3.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is โ€œonlyโ€ a devDependency of this project it might not break production or downstream projects, but โ€œonlyโ€ your build or test tools โ€“ preventing new deploys or publishes.

I recommend you give this issue a high priority. Iโ€™m sure you can resolve this ๐Ÿ’ช

Status Details
  • โŒ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.4.0

Mocha is now moving to a quicker release schedule: when non-breaking changes are merged, a release should happen that week.

This week's highlights:

  • allowUncaught added to commandline as --allow-uncaught (and bugfixed)
  • warning-related Node flags

๐ŸŽ‰ Enhancements

๐Ÿ› Fixes

๐Ÿ”ฉ Other

Commits

The new version differs by 9 commits0.

  • 7554b31 Add Changelog for v3.4.0
  • 9f7f7ed Add --trace-warnings flag
  • 92561c8 Add --no-warnings flag
  • ceee976 lint test/integration/fixtures/simple-reporter.js
  • dcfc094 Revert "use semistandard directly"
  • 93392dd no special case for macOS running Karma locally
  • 4d1d91d --allow-uncaught cli option
  • fb1e083 fix allowUncaught in browser
  • 4ed3fc5 Add license report and scan status

false

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of release-it is breaking the build ๐Ÿšจ

The devDependency release-it was updated from 8.3.1 to 8.4.0.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

release-it is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for Release 8.4.0
  • Try to coerce provided increment into valid semver version (3abbc73)
  • Fall back to "0.0.0" if no latest version is found (ab4c1e7)
Commits

The new version differs by 3 commits.

  • 56ee11f Release 8.4.0
  • 3abbc73 Try to coerce provided increment into valid semver version
  • ab4c1e7 Fall back to "0.0.0" if no latest version is found

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of eslint is breaking the build ๐Ÿšจ

Version 4.15.0 of eslint was just published.

Branch Build failing ๐Ÿšจ
Dependency eslint
Current Version 4.14.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v4.15.0
  • 6ab04b5 New: Add context.report({ messageId }) (fixes #6740) (#9165) (Jed Fox)
  • fc7f404 Docs: add url to each of the rules (refs #6582) (#9788) (Patrick McElhaney)
  • fc44da9 Docs: fix sort-imports rule block language (#9805) (ferhat elmas)
  • 65f0176 New: CLIEngine#getRules() (refs #6582) (#9782) (Patrick McElhaney)
  • c64195f Update: More detailed assert message for rule-tester (#9769) (Weijia Wang)
  • 9fcfabf Fix: no-extra-parens false positive (fixes: #9755) (#9795) (Erin)
  • 61e5fa0 Docs: Add table of contents to Node.js API docs (#9785) (Patrick McElhaney)
  • 4c87f42 Fix: incorrect error messages of no-unused-vars (fixes #9774) (#9791) (akouryy)
  • bbabf34 Update: add ignoreComments option to indent rule (fixes #9018) (#9752) (Kevin Partington)
  • db431cb Docs: HTTP -> HTTPS (fixes #9768) (#9768) (Ronald Eddy Jr)
  • cbf0fb9 Docs: describe how to feature-detect scopeManager/visitorKeys support (#9764) (Teddy Katz)
  • f7dcb70 Docs: Add note about "patch release pending" label to maintainer guide (#9763) (Teddy Katz)
Commits

The new version differs by 14 commits.

  • e14ceb0 4.15.0
  • 2dfc3bd Build: changelog update for 4.15.0
  • 6ab04b5 New: Add context.report({ messageId }) (fixes #6740) (#9165)
  • fc7f404 Docs: add url to each of the rules (refs #6582) (#9788)
  • fc44da9 Docs: fix sort-imports rule block language (#9805)
  • 65f0176 New: CLIEngine#getRules() (refs #6582) (#9782)
  • c64195f Update: More detailed assert message for rule-tester (#9769)
  • 9fcfabf Fix: no-extra-parens false positive (fixes: #9755) (#9795)
  • 61e5fa0 Docs: Add table of contents to Node.js API docs (#9785)
  • 4c87f42 Fix: incorrect error messages of no-unused-vars (fixes #9774) (#9791)
  • bbabf34 Update: add ignoreComments option to indent rule (fixes #9018) (#9752)
  • db431cb Docs: HTTP -> HTTPS (fixes #9768) (#9768)
  • cbf0fb9 Docs: describe how to feature-detect scopeManager/visitorKeys support (#9764)
  • f7dcb70 Docs: Add note about "patch release pending" label to maintainer guide (#9763)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Doesn't work with React wrapper methods

Wrapping a function component with React.forwardRef or React.memo causes it to get ignored.

Example:

const Button = React.forwardRef((props, ref) => {
    const rest = // get rest of props not handled
    return (<button ref={ref} {...rest}>{props.label}</button>);
});

Button.propTypes = {
    label: PropTypes.string,
};

export default Button;

Can also be chained, e.g React.memo(React.forwardRef(() => ...))

An in-range update of release-it is breaking the build ๐Ÿšจ

The devDependency release-it was updated from 10.0.8 to 10.0.9.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

release-it is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

library concepts not fully defined

problem statement

  • handledProps aren't defined formally in the README, and their usage + context are not fully articulated

discussion

i filed 1601 in hopes to better understand how RSUI wires all of this up. my understanding has progressed only as far to know that this transform adds a static-ish exports to a component which can be used somehow at runtime to aide in the propagation of props down the component tree.

anyway, this isn't critical or anything, I just thought that I'd share as an interested user that the README didn't get me fully there!

An in-range update of prettier is breaking the build ๐Ÿšจ

โ˜๏ธ Greenkeeperโ€™s updated Terms of Service will come into effect on April 6th, 2018.

Version 1.12.0 of prettier was just published.

Branch Build failing ๐Ÿšจ
Dependency prettier
Current Version 1.11.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes Prettier 1.12: Fixes, Features, and Formatting, Oh My!

๐Ÿ”— Release Notes

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of babel7 is breaking the build ๐Ÿšจ

There have been updates to the babel7 monorepo:

    • The devDependency @babel/cli was updated from 7.2.0 to 7.2.3.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the babel7 group definition.

babel7 is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of release-it is breaking the build ๐Ÿšจ

The devDependency release-it was updated from 12.4.3 to 12.5.0.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

release-it is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for Release 12.5.0
  • Always use npm.tag if provided when resolving tag (fixes #586) (39dcc22)
  • Fix prerelease continuation type in interactive mode (fixes #588) (0e62393)
  • Add docs about npm.publishPath (90531ab)
  • Update dependencies (4949a8a)
  • Update/migrate to latest semver (a11f992)
  • Update/migrate to latest @octokit/rest (5ad3e18)
  • Fix links to documentation (#599) (cec2829)
  • Move both auto-changelog recipes to the /conf directory (#587) (b90831a)
Commits

The new version differs by 34 commits.

  • 12c73b4 Release 12.5.0
  • 39dcc22 Always use npm.tag if provided when resolving tag (fixes #586)
  • 0e62393 Fix prerelease continuation type in interactive mode (fixes #588)
  • 90531ab Add docs about npm.publishPath
  • 4949a8a Update dependencies
  • a11f992 Update/migrate to latest semver
  • 5ad3e18 Update/migrate to latest @octokit/rest
  • cec2829 Fix links to documentation (#599)
  • b90831a Move both auto-changelog recipes to the /conf directory (#587)
  • da075e6 Release 12.5.0-next.3
  • 8cc81f1 Simplify/fix debug logic in metrics (related to #574)
  • f818699 Fix toml example
  • fd67e6c Add auto-changelog template file to be used directly from the repository (#583)
  • 47548b5 Release 12.5.0-next.2
  • 923a56c Authenticate and verify as collaborator with GitLab on init

There are 34 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Unexpected token

ModuleParseError: Module parse failed: Unexpected token (102:4)
You may need an appropriate loader to handle this file type.
|   };
| }
> 2657:3258.handledProps = [];

Has anyone encountered this issue?
Setup: React 16.4, Webpack 4, Babel 7 (more details coming)

An in-range update of mocha is breaking the build ๐Ÿšจ

โ˜๏ธ Greenkeeperโ€™s updated Terms of Service will come into effect on April 6th, 2018.

Version 5.1.0 of mocha was just published.

Branch Build failing ๐Ÿšจ
Dependency mocha
Current Version 5.0.5
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

mocha is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v5.1.0

5.1.0 / 2018-04-12

๐ŸŽ‰ Enhancements

๐Ÿ› Fixes

๐Ÿ“– Documentation

๐Ÿ”ฉ Other

Commits

The new version differs by 23 commits ahead by 23, behind by 2.

  • 40d9ea3 Release v5.1.0
  • bf34e42 update CHANGELOG for v5.1.0 [ci skip]
  • 63462dd Implement API documentation using npm:documantation.
  • 741b0bd fix circular objects in json reporter; closes #2433 (#3318)
  • 8010501 fix wrong version in package.json! [ci skip]
  • 94e7289 doc precision for exclusive tests
  • 8b6c957 optimize package-scripts.js
  • d71b80a PATH workaround for Travis CI bug
  • 7544bd3 further build improvements (#3315)
  • 88b9882 update package-lock.json for v5.0.5 [ci skip]
  • 4ae26b2 improve caching performance in CI (#3310)
  • ff9f3cf update stages and build matrices (#3308)
  • f2560e7 add update-contributors script; closes #3289 (#3290)
  • cd1c835 upgrade eslint; lint
  • 35dac3e use build stages for Travis CI (#3302)

There are 23 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of eslint-config-airbnb-base is breaking the build ๐Ÿšจ

Version 12.1.0 of eslint-config-airbnb-base was just published.

Branch Build failing ๐Ÿšจ
Dependency eslint-config-airbnb-base
Current Version 12.0.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint-config-airbnb-base is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push The Travis CI build failed Details

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Did not get `propTypes `

in

import PropTypes from 'prop-types';
import React from 'react';

const propTypes={
  children: PropTypes.node,
  className: PropTypes.string
}

function Example() {
  return <div />;
}

Example.propTypes = propTypes;

export default Example;

out

import PropTypes from 'prop-types';
import React from 'react';

const propTypes = {
  children: PropTypes.node,
  className: PropTypes.string
};

function Example() {
  return <div />;
}

Example.handledProps = [];
Example.propTypes = propTypes;

export default Example;

An in-range update of babel-eslint is breaking the build ๐Ÿšจ

โ˜๏ธ Greenkeeperโ€™s updated Terms of Service will come into effect on April 6th, 2018.

Version 8.2.3 of babel-eslint was just published.

Branch Build failing ๐Ÿšจ
Dependency babel-eslint
Current Version 8.2.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

babel-eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 3 commits.

  • aaeb46b 8.2.3
  • afc3c87 lock to beta.44
  • 92202be Save babel beta packages as exact versions (#606) [skip ci]

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.