Переменные Grunt Jasmine Fixture / Helper приводят к тому, что Eslint no-undef для - PullRequest
0 голосов
/ 26 июня 2019

Попытка добавить Linting в более старый проект ES5 ... использует Grunt и Jasmine, импорт / экспорт / не требуется. Однако при связывании переменных Fixture переменная в спецификации тестирования приводит к ошибке переменной esLint no-undef. Как я могу разрешить переменную, объявленную в задаче Fixture and Grunt?

Файл фикстуры

var testOptions = {
  key: value,
  ... etc
}

Спецификация теста:

describe("Spec", function() {

  it("Test", function() {
    var result = function(testOptions);  // <== ESLint does not see `testOptions` defined here...see below

    console.log(JSON.stringify(testOptions)); // <== outputs object correctly
  });
});

Grunt Jasmine config:

project: {
    src: [
      '<%= proj.src %>/scripts/**/*.js'
    ],
    options: {
      specs: '<%= proj.src %>/test/spec/{,*/}*Spec.js',
      helpers: [
        '<%= proj.src %>/test/fixtures/{,*/}*Fixture.js', <=== Here is where the Grunt tasks make this fixture available
      ],
      vendor: [
        'node_modules/jquery/dist/jquery.js',
        'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
        'node_modules/jasmine-ajax/lib/mock-ajax.js'
      ],
      outfile: '<%= proj.src %>/test/_SpecRunner.html',
      // keepRunner: true,
    }
  }

Или есть правило, которое можно написать для этого?

...