Code Monkey home page Code Monkey logo

Comments (8)

mikeerickson avatar mikeerickson commented on September 28, 2024

@santiph At what capacity are you thinking Bard should contain ESLint support? Seeing as you can lint just about anything you want (and also exclude) not sure what you are looking for?

from bardjs.

rglepper avatar rglepper commented on September 28, 2024

@mikeerickson For example, If no-undef: "error" and you inject an application component using Bard, when you use it on your tests, ESLint throws a linting error. This can be avoided by declaring the vars on a global comment at the top of the file, so is no big deal, but it would be great if ESLint recognised the components injected by Bard.

from bardjs.

mikeerickson avatar mikeerickson commented on September 28, 2024

Ah, this is because it is a global variable. You can also fix as

/*global error*/

Or, in your package.json

  "eslintConfig": {
...
    "globals": {
      "error": true
    }
  },

from bardjs.

rglepper avatar rglepper commented on September 28, 2024

@mikeerickson I have tried what you suggest, and it doesn't seem to change anything. Maybe I did't get my message across, let me show you an example:

/* eslint-env mocha */
/* eslint no-undef:2 */
/* global error */

describe('example', function() {
    beforeEach(function() {
        bard.appModule('app.module');
        bard.inject('exampleService');
    });


    it('should do something', function() {
        exampleService.someMethod();
    });

});

'exampleService' is not defined (no-undef)

That's what I mean, does it make sense?

I think it would be very nice if there was a Bard plugin for ESLint so that injected components are recognised as defined. As I said before, the way around it is to declare the injected component as a global /* global exampleService */ but it sort of misses the whole point for using Bard.

from bardjs.

mikeerickson avatar mikeerickson commented on September 28, 2024

@rglepper So in your case, if you apply

/* eslint no-undef: 0 */

Then it would take care of your issue (no?) I hear what you are saying, but creating a specific bard-eslint-plugin to workaround these types of eslint warnings / errors is sort of out of the scope when specific rules outside of bards control (ie your own choosing) the no-undef switch would do the trick

If I am still missing your point and you feel a bard-eslint-plugin would make additional sense, please let me know.

from bardjs.

santiph avatar santiph commented on September 28, 2024

I was expecting a better solution than copy/pasting this on every test file:
/*global bard $controller $httpBackend $q $rootScope */

from bardjs.

mikeerickson avatar mikeerickson commented on September 28, 2024

You can again apply this in your package.json as follows

  "eslintConfig": {
...
    "globals": {
      "error": true,
      "$controller": true,
      "$httpBackend": true,
      "$rootScope": true
    }
  },

This way, you don't have to apply to each of your test files.

from bardjs.

mikeerickson avatar mikeerickson commented on September 28, 2024

@santiph See previous message...

from bardjs.

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.