Skip to content

Commit

Permalink
Silence no new side effect eslint linting
Browse files Browse the repository at this point in the history
This indicates an issue with our module pattern wherein we
don't need to be using a class pattern for some of our code
since there's no returned instance that is being used.

If this is the case that there are public methods exposed on an instance
we should test those...
  • Loading branch information
NickColley committed Sep 29, 2016
1 parent bae33ea commit 69f9d14
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion javascripts/govuk/primary-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
GOVUK.primaryLinks = {
init: function (selector) {
$(selector).parent().each(function (i, el) {
new GOVUK.PrimaryList(el, selector)
new GOVUK.PrimaryList(el, selector) // eslint-disable-line no-new
})
}
}
Expand Down
18 changes: 9 additions & 9 deletions spec/unit/multivariate-test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('MultivariateTest', function () {
GOVUK.cookie.and.returnValue(null)
var fooSpy = jasmine.createSpy('fooSpy')
var barSpy = jasmine.createSpy('barSpy')
new GOVUK.MultivariateTest({
new GOVUK.MultivariateTest({ // eslint-disable-line no-new
name: 'stuff',
cohorts: {
foo: {callback: fooSpy},
Expand All @@ -43,7 +43,7 @@ describe('MultivariateTest', function () {
GOVUK.cookie.and.returnValue('foo')
var fooSpy = jasmine.createSpy('fooSpy')
var barSpy = jasmine.createSpy('barSpy')
new GOVUK.MultivariateTest({
new GOVUK.MultivariateTest({ // eslint-disable-line no-new
name: 'stuff',
cohorts: {
foo: {callback: fooSpy},
Expand All @@ -55,7 +55,7 @@ describe('MultivariateTest', function () {

it('should set a custom var with the name and cohort if one is defined', function () {
GOVUK.cookie.and.returnValue('foo')
new GOVUK.MultivariateTest({
new GOVUK.MultivariateTest({ // eslint-disable-line no-new
name: 'stuff',
cohorts: {
foo: {},
Expand All @@ -71,7 +71,7 @@ describe('MultivariateTest', function () {

it('should be able to set multiple custom vars with the name and cohort if one is defined as an array', function () {
GOVUK.cookie.and.returnValue('foo')
new GOVUK.MultivariateTest({
new GOVUK.MultivariateTest({ // eslint-disable-line no-new
name: 'stuff',
cohorts: {
foo: {},
Expand All @@ -91,7 +91,7 @@ describe('MultivariateTest', function () {

it('should trigger an event to track that the test has been run', function () {
GOVUK.cookie.and.returnValue('foo')
new GOVUK.MultivariateTest({
new GOVUK.MultivariateTest({ // eslint-disable-line no-new
name: 'stuff',
cohorts: {
foo: {},
Expand All @@ -108,7 +108,7 @@ describe('MultivariateTest', function () {
it('should set html for a cohort', function () {
GOVUK.cookie.and.returnValue('foo')
var $el = $('<div>')
new GOVUK.MultivariateTest({
new GOVUK.MultivariateTest({ // eslint-disable-line no-new
name: 'stuff',
el: $el,
cohorts: {
Expand All @@ -124,7 +124,7 @@ describe('MultivariateTest', function () {
var barSpy = jasmine.createSpy('barSpy')
GOVUK.cookie.and.returnValue('bar')
var $el = $('<div>')
new GOVUK.MultivariateTest({
new GOVUK.MultivariateTest({ // eslint-disable-line no-new
name: 'stuff',
el: $el,
cohorts: {
Expand Down Expand Up @@ -177,7 +177,7 @@ describe('MultivariateTest', function () {
var fooSpy = jasmine.createSpy('fooSpy')
var barSpy = jasmine.createSpy('barSpy')
GOVUK.cookie.and.returnValue('baz')
new GOVUK.MultivariateTest({
new GOVUK.MultivariateTest({ // eslint-disable-line no-new
name: 'stuff',
cohorts: {
foo: {callback: fooSpy},
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('MultivariateTest', function () {
})

it('should report the experiment data to Google', function () {
new GOVUK.MultivariateTest({
new GOVUK.MultivariateTest({ // eslint-disable-line no-new
name: 'stuff',
contentExperimentId: 'asdfsadasdfa',
cohorts: {foo: {variantId: 0, weight: 1}, bar: {variantId: 1, weight: 0}}
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/primary-links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('primary-links', function () {
})

it('visually hides extra links', function () {
new GOVUK.PrimaryList(mediumList, '.primary')
new GOVUK.PrimaryList(mediumList, '.primary') // eslint-disable-line no-new

expect(mediumList.find('.visuallyhidden').length).toBe(2)
})
Expand All @@ -29,7 +29,7 @@ describe('primary-links', function () {

it('add a toggle link', function () {
var container = $('<div>').append(mediumList)
new GOVUK.PrimaryList(mediumList, '.primary')
new GOVUK.PrimaryList(mediumList, '.primary') // eslint-disable-line no-new

expect(container.find('a').length).toBe(1)
})
Expand All @@ -46,8 +46,8 @@ describe('primary-links', function () {
})

it('only adds toggle if more than one extra link', function () {
new GOVUK.PrimaryList(shortList, '.primary')
new GOVUK.PrimaryList(mediumList, '.primary')
new GOVUK.PrimaryList(shortList, '.primary') // eslint-disable-line no-new
new GOVUK.PrimaryList(mediumList, '.primary') // eslint-disable-line no-new

expect(shortList.find('.visuallyhidden').length).toBe(0)
expect(mediumList.find('.visuallyhidden').length).toBe(2)
Expand Down

0 comments on commit 69f9d14

Please sign in to comment.