eslint-plugin-eslint-plugin icon indicating copy to clipboard operation
eslint-plugin-eslint-plugin copied to clipboard

New: rule tests-ordering

Open aladdin-add opened this issue 8 years ago • 3 comments
trafficstars

if a rule has a very large number of test cases, it would be fine to reorder them based on options.

this rule can enforce code like this to improve readability:

      new RuleTester().run('foo', bar, {
        valid: [

          // valid tests for options: ['foo']
          { code: 'codeA', options: ['foo'] },
          { code: 'codeB', options: ['foo'] },
          // and more...

          // valid tests for options: ['bar']
          { code: 'codeA', options: ['bar'] },
          { code: 'codeB', options: ['bar'] },
          // and more...
        ],
      });

aladdin-add avatar Nov 06 '17 11:11 aladdin-add

How would ordering be determined? For example, does options: ['foo'] come before options: ['foo', 'bar']?

not-an-aardvark avatar Nov 08 '17 09:11 not-an-aardvark

it aims to put the tests having same options together, but it's fine to add an option to enforce options ordering alphabetically:

// tests for options: []
...

// tests for options: ['bar']
...

// tests for options: ['bar', 'foo']
...

// tests for options: ['foo']
...

aladdin-add avatar Nov 08 '17 09:11 aladdin-add

Sounds good to me. I don't think it's necessary to make the options alphabetical -- that seems like it could be confusing.

not-an-aardvark avatar Nov 10 '17 08:11 not-an-aardvark