fgnass / diffparser Goto Github PK
View Code? Open in Web Editor NEWUnified diff parser for Node and the browser
Unified diff parser for Node and the browser
Hello,
I've been trying to get this diff parsed but I believe there is something in it that makes it fail.
What I see in my console is the following:
Uncaught (in promise) Error: Objects are not valid as a React child (found: TypeError: Cannot read property 'changes' of null). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of `DiffViewerMeta`.
at invariant (invariant.js:44)
at traverseAllChildrenImpl (traverseAllChildren.js:144)
at traverseAllChildren (traverseAllChildren.js:172)
at flattenChildren (flattenChildren.js:66)
at ReactDOMComponent._reconcilerUpdateChildren (ReactMultiChild.js:202)
at ReactDOMComponent._updateChildren (ReactMultiChild.js:310)
at ReactDOMComponent.updateChildren (ReactMultiChild.js:297)
at ReactDOMComponent._updateDOMChildren (ReactDOMComponent.js:942)
at ReactDOMComponent.updateComponent (ReactDOMComponent.js:760)
at ReactDOMComponent.receiveComponent (ReactDOMComponent.js:722)
Do you have documentation on how to contribute? Thanks.
Input:
@@ -36,6 +36,7 @@ export type SomeContext = {
foo: bar,
};
+import newdep from 'newdep';
import {bla} from 'bla';
import {qwe} from 'qwe';
import {ertyu} from 'ertyu';
Output:
...
{
"content": "@@ -36,6 +36,7 @@ export type SomeContext = {",
"changes": [
{
"type": "normal",
"normal": true,
"position": 1,
"content": " foo: bar,"
},
{
"type": "normal",
"normal": true,
"position": 2,
"content": " };"
},
{
"type": "add",
"add": true,
"ln": 36,
"position": 3,
"content": "+import newdep from 'newdep';"
},
{
"type": "normal",
"normal": true,
"position": 4,
"content": " import {bla} from 'bla';"
},
{
"type": "normal",
"normal": true,
"position": 5,
"content": " import {qwe} from 'qwe';"
},
{
"type": "normal",
"normal": true,
"position": 6,
"content": " import {ertyu} from 'ertyu';"
}
],
"oldStart": 36,
"oldLines": 6,
"newStart": 36,
"newLines": 7
},
...
There are 2 issues here:
ln
property is only present for changed lines (type
=== add
/del
), but not in lines of type
normal
.ln
property is present, it does not consider the number of context lines preceding it, rendering its value inaccurate. In the above example, the line marked with ln: 36
should really be ln: 38
.Ideally, parse
would return a consistent format for each changed line, including the ln
number, the calculation for which should also consider the extent of the surrounding context.
I'd like to update ESLint to the latest version (from v2 to v5) and track that in this issue. Some questions before tackling that:
npm run lint
)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.