test-base.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import fs from 'fs';
  2. import path from 'path';
  3. import test from 'tape';
  4. const base = require('../base');
  5. const files = { base };
  6. fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => {
  7. if (name === 'react.js' || name === 'react-a11y.js') {
  8. return;
  9. }
  10. // eslint-disable-next-line import/no-dynamic-require
  11. files[name] = require(`../rules/${name}`); // eslint-disable-line global-require
  12. });
  13. Object.keys(files).forEach((name) => {
  14. const config = files[name];
  15. test(`${name}: does not reference react`, (t) => {
  16. t.plan(2);
  17. // scan plugins for react and fail if it is found
  18. const hasReactPlugin = Object.prototype.hasOwnProperty.call(config, 'plugins')
  19. && config.plugins.indexOf('react') !== -1;
  20. t.notOk(hasReactPlugin, 'there is no react plugin');
  21. // scan rules for react/ and fail if any exist
  22. const reactRuleIds = Object.keys(config.rules)
  23. .filter((ruleId) => ruleId.indexOf('react/') === 0);
  24. t.deepEquals(reactRuleIds, [], 'there are no react/ rules');
  25. });
  26. });