Open santiph opened 8 years ago
@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?
@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.
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
}
},
@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.
@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.
I was expecting a better solution than copy/pasting this on every test file:
/*global bard $controller $httpBackend $q $rootScope */
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.
@santiph See previous message...
Is there any way to integrate bardjs to ESLint?