Code Monkey home page Code Monkey logo

Comments (13)

btford avatar btford commented on May 5, 2024

@ealtenho started on that yesterday here: https://github.com/angular/angular-hint/blob/master/load.js#L12

from angular-hint.

ealtenho avatar ealtenho commented on May 5, 2024

@btford, I'm not sure the direction of this issue? What are the goals here aside from what has already been done?

from angular-hint.

btford avatar btford commented on May 5, 2024

We already started on this, but there are a few pending tasks:

  • console.warn for wrong config options, like ng-hint="bar" when there is no module called bar
  • inclusive and exclusive modes – "use all hinting modules except X, Y, Z" and "use only hinting modules X, Y, and Z."

from angular-hint.

ealtenho avatar ealtenho commented on May 5, 2024

@caguillen214 would checking

console.warn for wrong config options, like ng-hint="bar" when there is no module called bar

be similar to your work for #1 ?

from angular-hint.

ealtenho avatar ealtenho commented on May 5, 2024

@btford for the inclusive and exclusive modes, would this be triggered by a flag like inclusive or exclusive entered with the ng-hint tag? Or how were you envisioning this? Would inclusive or exclusive mode be the default?

from angular-hint.

btford avatar btford commented on May 5, 2024

There are a couple of possible ways to implement this. @caguillen214 – would be good for you and @ealtenho to brainstorm and choose something.

  • ng-hint="include x, y, z" and ng-hint="exclude x, y, z"
  • ng-hint-include="x, y, z" and ng-hint-exclude="x, y, z"

I think it's better to avoid mixing "inclusive" and "exclusive" modes. For example, none of these make sense to me:

  • ng-hint="+x, -y, +z"
  • ng-hint="{ x: true, y: false, z: true }"

Other hinting systems (like jshint, jslint, eshint) allow you to scope configuration options in a way that it can make sense to have both inclusive and exclusive rules in the same configuration. Although some of Angular corresponds directly to the DOM, in angular-hint we mostly decorate the service layer.

With this in mind, we should warn when a page has more than one ng-hint. It might be good to suggest that the ng-hint occur on <html> or on the same element that has ng-app.

from angular-hint.

caguillen214 avatar caguillen214 commented on May 5, 2024

So the implementation would be similar to what I do in hint-directive/hint-module if we decided to dynamically get the options loaded, by checking which modules have been created for the app.

It seems that it makes sense to just have like a hashmap of options we support. Since we don't have many options I feel the code would be simpler if we didn't dynamically load the ng-hint modules created and instead we just kept track of the ng-hint modules we support.

<html ng-app="app.js" ng-hint="['directive','dom']">

then something like (psuedo):

var ngHints = { 
   'all': 'all.js', 'directive' : 'hint-directive.js', 'dom': 'hint-dom.js', 'interpolation': 'hint-interpolation.js'
}
html.attr('ng-hint').value.forEach(function(hint) {
   if(ngHints[hint])
     load(ngHints[hint]);
   else
     throw new Error('No Angular-hint module found with name: '+hint);
}

from angular-hint.

caguillen214 avatar caguillen214 commented on May 5, 2024

With this in mind, we should warn when a page has more than one ng-hint. It might be good to suggest that the ng-hint occur on or on the same element that has ng-app.

I think this is a good idea.

from angular-hint.

btford avatar btford commented on May 5, 2024

ng-hint="['directive','dom']"

I think this is misleading in that it suggests that you could pass any angular expression in there. Because ng-hint runs before angular is bootstrapped, it's impossible to bind to an angular expression.

Let's do this:

  • ng-hint (includes all by default)
  • ng-hint-include="x, y, z" (comma-separated)
  • ng-hint-exclude="x, y, z"

@ealtenho can you implement (and add tests for this?)

from angular-hint.

ealtenho avatar ealtenho commented on May 5, 2024

@btford
I've added a rough implementation of how I think this should work, but I'm having trouble getting tests to run. I assume that unit tests are the appropriate tool to use here, and I tried to start my implementation using TDD, but I can't seem to get the order of the bootstrapping correct with karma. When I run my tests I get the message that resumeBootstrap is not a function.

I have (sort of) tested by hand using the sample application and appending the various ng-hint directives.

from angular-hint.

ealtenho avatar ealtenho commented on May 5, 2024

I will remove my broken unit tests and start working on E2E tests for this feature.

from angular-hint.

btford avatar btford commented on May 5, 2024

👍

from angular-hint.

ealtenho avatar ealtenho commented on May 5, 2024

This is now implemented. What remains is E2E testing as described in #7

from angular-hint.

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.