Giter Club home page Giter Club logo

Comments (8)

attaboy avatar attaboy commented on July 17, 2024 1

@justindeguzman I ended up forking this project pretty aggressively since it seemed dormant for awhile. To solve this particular problem I added some functions to test "deep" object/array equality.

function deepEquals(thing1, thing2) {
  if (thing1 === thing2) {
    return true;
  } else if (Number.isNaN(thing1) && Number.isNaN(thing2)) {
    return true;
  } else if (Array.isArray(thing1) && Array.isArray(thing2)) {
    return arraysEqual(thing1, thing2);
  } else if (typeof(thing1) === 'object' && typeof(thing2) === 'object') {
    return objectsEqual(thing1, thing2);
  } else {
    return false;
  }
}

function arraysEqual(array1, array2) {
  if (array1.length !== array2.length) {
    return false;
  } else {
    return array1.every(function(item, index) {
      return deepEquals(array1[index], array2[index]);
    });
  }
}

function objectsEqual(obj1, obj2) {
  if (obj1.constructor !== obj2.constructor) {
    return false;
  }
  var obj1Keys = Object.keys(obj1);
  var obj2Keys = Object.keys(obj2);
  if (!arraysEqual(obj1Keys.sort(), obj2Keys.sort())) {
    return false;
  }
  return obj1Keys.every(function(key) {
    return deepEquals(obj1[key], obj2[key]);
  });
}
  setCodeMirrorOptionIfChanged: function(optionName, newValue) {
    var oldValue = this.codeMirror.getOption(optionName);
    if (!deepEquals(oldValue, newValue)) {
      this.codeMirror.setOption(optionName, newValue);
    }
  },

from react-codemirror.

attaboy avatar attaboy commented on July 17, 2024

Okay, thinking about this more; using JSON.stringify would almost certainly cause other bugs, since there are a handful of CodeMirror options that take functions as values.

from react-codemirror.

justindeguzman avatar justindeguzman commented on July 17, 2024

@attaboy Were you able to find a solution?

from react-codemirror.

cacois avatar cacois commented on July 17, 2024

Have a fork published anywhere? Really like to get linting to work...

from react-codemirror.

attaboy avatar attaboy commented on July 17, 2024

@cacois I just created a pull request that I believe fixes the problem with lint: #93

from react-codemirror.

cacois avatar cacois commented on July 17, 2024

@attaboy Thanks for the note!

Plugged your branch in to give it a test, but I don't see any change in behavior in my app. Any specific guidance on getting it working? I'm basically just importing libraries adding the lint: true, gutters: ['CodeMirror-lint-markers'] options.

from react-codemirror.

attaboy avatar attaboy commented on July 17, 2024

@cacois Which lint plugin are you trying to use? I'm using jshint successfully in my project by requiring addon/lint/lint and add-on/lint/javascript-lint and ensuring that the JSHint library is loaded already (globally, which is an assumption that the javascript-lint add-on makes).

from react-codemirror.

cacois avatar cacois commented on July 17, 2024

@attaboy Got it! Turns out I wasn't getting the JSHINT function to be globally available, as necessary. Once I figured out how to import it properly, things began working fine. Thanks!

from react-codemirror.

Related Issues (20)

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.