condenast / xml-to-react Goto Github PK
View Code? Open in Web Editor NEWA utility to convert valid XML documents into React elements.
License: Apache License 2.0
A utility to convert valid XML documents into React elements.
License: Apache License 2.0
Creating an exploratory issue to discuss using Jest for this project.
On registry https://registry.npmjs.org/
, the "latest" version (v6.24.1) of dependency babel-preset-es2015
has the following deprecation notice:
π Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.
Please take the actions necessary to rename or substitute this deprecated package and commit to your base branch. If you wish to ignore this deprecation warning and continue using babel-preset-es2015
as-is, please add it to your ignoreDeps array in Renovate config before closing this issue, otherwise another issue will be recreated the next time Renovate runs.
Affected package file(s): package.json
per @johnkpaul 's suggestion, we should refine the behavior when faced with an invalid XML document.
today, XMLToReact#convert
will simply log a warning when supplied with an invalid XML document. it will also log the warning for all xmldom
error levels.
xmldom
error levels (warning, error, fatal)?We currently require our consumers to coerce and validate their attributes themselves within their converter callbacks.
It may be beneficial to coerce the type of each XML node attribute value for use within a converter callback.
e.g.,
<Party>
<Person name="Mary" age="20" ready="true" />
</Party>
const xmlToReact = new XMLToReact({ Person: convertPerson });
function convertPerson (attributes) {
typeof attributes.name; // 'string'
typeof attributes.age; // 'string'
typeof attributes.ready; // 'string'
return { type: 'div', props: attributes };
}
The value of each XML node attribute is a string.
If we coerce each the type of each value, we would instead the following:
function convertPerson (attributes) {
typeof attributes.name; // 'string'
typeof attributes.age; // 'number'
typeof attributes.ready; // 'boolean'
return { type: 'div', props: attributes };
}
for boolean attributes, we should consider HTML's approach
related: #16 (comment)
On registry https://registry.npmjs.org/
, the "latest" version (v6.23.0) of dependency babel
has the following deprecation notice:
In 6.x, the babel package has been deprecated in favor of babel-cli. Check https://opencollective.com/babel to support the Babel maintainers
Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.
Please take the actions necessary to rename or substitute this deprecated package and commit to your base branch. If you wish to ignore this deprecation warning and continue using babel
as-is, please add it to your ignoreDeps array in Renovate config before closing this issue, otherwise another issue will be recreated the next time Renovate runs.
Affected package file(s): package.json
What are the requirements for this project to be made public? (please edit this issue with a checklist)
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.
react
, react-dom
)These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
package.json
xmldom ^0.1.27
@babel/cli ^7.2.3
@babel/core ^7.2.2
@babel/preset-env ^7.4.5
@babel/preset-react ^7.0.0
@babel/register ^7.0.0
chai ^4.1.2
enzyme ^3.3.0
enzyme-adapter-react-16 ^1.1.1
eslint ^5.0.0
eslint-config-airbnb ^17.0.0
eslint-plugin-import ^2.9.0
eslint-plugin-jsdoc ^20.0.0
eslint-plugin-jsx-a11y ^6.0.3
eslint-plugin-react ^7.7.0
jest ^24.8.0
prop-types ^15.6.1
react ^16.2.0
react-dom ^16.2.1
rollup ^1.0.0
rollup-plugin-babel ^4.3.2
rollup-plugin-commonjs ^10.0.0
rollup-plugin-node-resolve ^5.0.0
rollup-plugin-peer-deps-external ^2.0.0
react ^0.13.0 || ^0.14.0 || ^15.0.0 || ^16
.nvmrc
node 8.16
.travis.yml
node 6
node 8
Currently, we require converters to be defined to do anything. But as of React 16.x (if not earlier?), we can render custom/arbitrary tag names. This means that we can turn an XML document into a React tree without any provided converters.
e.g.
import { createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
renderToStaticMarkup(createElement('foo'));
// => <foo></foo>
I'd like to propose that this be our default behavior.
On registry https://registry.npmjs.org/
, the "latest" version (v6.24.1) of dependency babel-preset-es2015
has the following deprecation notice:
π Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.
Please take the actions necessary to rename or substitute this deprecated package and commit to your base branch. If you wish to ignore this deprecation warning and continue using babel-preset-es2015
as-is, please add it to your ignoreDeps array in Renovate config before closing this issue, otherwise another issue will be recreated the next time Renovate runs.
Affected package file(s): package.json
Would you like to disable Renovate's deprecation warning issues? Add the following to your config:
"suppressNotifications": ["deprecationWarningIssues"]
We should extract XML parsing into our own internal helper, which would act as an interface between xmldom
and xml-to-react
.
This would make it easier to test our other helpers, and to better test XML parsing error conditions.
related:
#16 (comment)
#14
the functions within the internal helpers module require tests.
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: Preset name not found within published preset config (monorepo:babel6). Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.
On registry https://registry.npmjs.org/
, the "latest" version (v6.23.0) of dependency babel
has the following deprecation notice:
In 6.x, the babel package has been deprecated in favor of babel-cli. Check https://opencollective.com/babel to support the Babel maintainers
Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.
Please take the actions necessary to rename or substitute this deprecated package and commit to your base branch. If you wish to ignore this deprecation warning and continue using babel
as-is, please add it to your ignoreDeps array in Renovate config before closing this issue, otherwise another issue will be recreated the next time Renovate runs.
Affected package file(s): package.json
Would you like to disable Renovate's deprecation warning issues? Add the following to your config:
"suppressNotifications": ["deprecationWarningIssues"]
This is a conversation that I'd like to have, but I've realized that atjson provides all the building blocks of this project using a few parts.
The API isn't too dissimilar as well:
import HTMLSource from "@atjson/source-html";
import ReactRenderer from "@atjson/renderer-react";
ReactDOM.render('app-container', ReactRenderer.render(HTMLSource.fromRaw(html)));
This is just a thought, since we're currently actively maintaining atjson, and could leverage those tools for this β€οΈ
Our tests run against src
but not our build pipeline, which uses rollup
. This leaves uncertainty when we update dependencies in our build chain.
Travis only runs npm test
currently, and tests run against our src
(using babel)
Maintenance becomes easier if we know dependency updates can be reliably accepted.
n/a
This is a master issue to work through the CondΓ© Nast Open Source Checklist.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.