Coder Social home page Coder Social logo

diffparser's Issues

Parsing this diff fails

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.

Line number does not consider context

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:

  1. The ln property is only present for changed lines (type === add/del), but not in lines of type normal.
  2. When the 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.

Update ESLint

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:

  • ESLint isn't currently enforced for PRs (on Travis). Cool to add an npm script to run this on PRs? (npm run lint)
  • The airbnb ESLint plugin is also out of date. Do you have a strong opinion of what ESLint restrictions you'd like to enforce? Perhaps using a community standard like standard could be an option?
  • Do you have a preference on using something like prettier to enforce a consistent code style (which can also be integrated with ESLint)?

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.