-
Notifications
You must be signed in to change notification settings - Fork 26.2k
/
test-base.js
33 lines (26 loc) · 1.06 KB
/
test-base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import fs from 'fs';
import path from 'path';
import test from 'tape';
import index from '..';
const files = { ...{ index } }; // object spread is to test parsing
const rulesDir = path.join(__dirname, '../rules');
fs.readdirSync(rulesDir).forEach((name) => {
// eslint-disable-next-line import/no-dynamic-require
files[name] = require(path.join(rulesDir, name)); // eslint-disable-line global-require
});
Object.keys(files).forEach((
name, // trailing function comma is to test parsing
) => {
const config = files[name];
test(`${name}: does not reference react`, (t) => {
t.plan(2);
// scan plugins for react and fail if it is found
const hasReactPlugin = Object.prototype.hasOwnProperty.call(config, 'plugins')
&& config.plugins.indexOf('react') !== -1;
t.notOk(hasReactPlugin, 'there is no react plugin');
// scan rules for react/ and fail if any exist
const reactRuleIds = Object.keys(config.rules)
.filter((ruleId) => ruleId.indexOf('react/') === 0);
t.deepEquals(reactRuleIds, [], 'there are no react/ rules');
});
});