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

feat: add babel plugin for optional chaining #356

Merged
merged 2 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions example/project/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PageHeader from '@availity/page-header';
import { Container, Card } from 'reactstrap';
import * as yup from 'yup';
import Form from '@/components/Form';
import chain from '@/chain';

const App: React.SFC<{}> = () => (
<Container className="container-sm">
Expand All @@ -12,9 +13,11 @@ const App: React.SFC<{}> = () => (
tag={Formik}
initialValues={{
formField: '',
chainedField: chain,
}}
validationSchema={yup.object().shape({
formField: yup.string().required('This field is required.'),
chainedField: yup.string().required('This field is required.'),
})}
render={Form}
/>
Expand Down
14 changes: 14 additions & 0 deletions example/project/app/chain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Simple .js file to test compiling and linting for @babel/plugin-proposal-optional-chaining

const chainObject = {
org: {
types: [
{
name: 'Availity',
},
],
},
};

const chain = chainObject.org?.types?.[0]?.name;
export default chain;
1 change: 1 addition & 0 deletions example/project/app/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const Form: React.SFC<FormikProps<FormValues>> = ({ handleSubmit, handleReset })
</CardHeader>
<CardBody>
<Field name="formField" label="Some Field Label" />
<Field name="chainedField" label="Another Field Label" />
</CardBody>
<CardFooter className="d-flex justify-content-end">
<Button color="secondary" onClick={handleReset}>
Expand Down
3 changes: 2 additions & 1 deletion packages/workflow/babel-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module.exports = (_api, opts) => {
rootPathSuffix: 'project/app',
rootPathPrefix: '@/'
}
]
],
[require.resolve('@babel/plugin-proposal-optional-chaining')]
].filter(Boolean)
};
};
1 change: 1 addition & 0 deletions packages/workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@availity/workflow-logger": "^5.5.0",
"@availity/workflow-upgrade": "^5.4.2",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@babel/runtime": "^7.0.0",
"@testing-library/jest-dom": "^4.0.0",
"babel-core": "^7.0.0-bridge.0",
Expand Down
15 changes: 15 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,14 @@
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-syntax-optional-catch-binding" "^7.2.0"

"@babel/plugin-proposal-optional-chaining@^7.6.0":
version "7.6.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.6.0.tgz#e9bf1f9b9ba10c77c033082da75f068389041af8"
integrity sha512-kj4gkZ6qUggkprRq3Uh5KP8XnE1MdIO0J7MhdDX8+rAbB6dJ2UrensGIS+0NPZAaaJ1Vr0PN6oLUgXMU1uMcSg==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-syntax-optional-chaining" "^7.2.0"

"@babel/plugin-proposal-unicode-property-regex@^7.4.4", "@babel/plugin-proposal-unicode-property-regex@^7.6.2":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.6.2.tgz#05413762894f41bfe42b9a5e80919bd575dcc802"
Expand Down Expand Up @@ -682,6 +690,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-syntax-optional-chaining@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.2.0.tgz#a59d6ae8c167e7608eaa443fda9fa8fa6bf21dff"
integrity sha512-HtGCtvp5Uq/jH/WNUPkK6b7rufnCPLLlDAFN7cmACoIjaOOiXxUt3SswU5loHqrhtqTsa/WoLQ1OQ1AGuZqaWA==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-syntax-typescript@^7.2.0":
version "7.3.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.3.3.tgz#a7cc3f66119a9f7ebe2de5383cce193473d65991"
Expand Down