Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom rule options overwriting defaults between test assertions #157

Closed
bgriffith opened this issue Sep 12, 2015 · 0 comments · Fixed by #159
Closed

Custom rule options overwriting defaults between test assertions #157

bgriffith opened this issue Sep 12, 2015 · 0 comments · Fixed by #159
Labels

Comments

@bgriffith
Copy link
Member

Currently custom rule options are overwriting the defaults for any assertions that follow.

See example below.

The defaults:

...
'defaults': {
    'allow-element-with-attribute': false,
    'allow-element-with-class': false,
    'allow-element-with-id': false
  },
...

First assertion will correctly allow elements with attributes.

  it('[attribute: true, class: false, id: false]', function (done) {
    lint.test(file, {
      'no-qualifying-elements': [
        1,
        {
          'allow-element-with-attribute': true
        }
      ]
    }, function (data) {
      lint.assert.equal(2, data.warningCount);
      done();
    });
  });

Second assert takes defaults to be

...
'defaults': {
    'allow-element-with-attribute': true,
    'allow-element-with-class': false,
    'allow-element-with-id': false
  },
...

Therefore second assertion will incorrectly allow elements for both attribute and class

  it('[attribute: false, class: true, id: false]', function (done) {
    lint.test(file, {
      'no-qualifying-elements': [
        1,
        {
          'allow-element-with-class': true
        }
      ]
    }, function (data) {
      lint.assert.equal(2, data.warningCount);
      done();
    });
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant