index-test.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* eslint-env jest */
  2. /* eslint global-require: 0 */
  3. import assert from 'assert';
  4. import fs from 'fs';
  5. import path from 'path';
  6. import plugin from '../src';
  7. const rules = fs.readdirSync(path.resolve(__dirname, '../src/rules/'))
  8. .map((f) => path.basename(f, '.js'));
  9. describe('all rule files should be exported by the plugin', () => {
  10. rules.forEach((ruleName) => {
  11. it(`should export ${ruleName}`, () => {
  12. assert.equal(
  13. plugin.rules[ruleName],
  14. require(path.join('../src/rules', ruleName)) // eslint-disable-line
  15. );
  16. });
  17. });
  18. });
  19. describe('configurations', () => {
  20. it('should export a \'recommended\' configuration', () => {
  21. assert(plugin.configs.recommended);
  22. });
  23. });
  24. describe('schemas', () => {
  25. rules.forEach((ruleName) => {
  26. it(`${ruleName} should export a schema with type object`, () => {
  27. const rule = require(path.join('../src/rules', ruleName)); // eslint-disable-line
  28. const schema = rule.meta && rule.meta.schema && rule.meta.schema[0];
  29. const { type } = schema;
  30. assert.deepEqual(type, 'object');
  31. });
  32. });
  33. });