-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
46 lines (38 loc) · 1016 Bytes
/
test.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
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
const path = require('path');
const { rules } = require(path.join(__dirname, '../index.js'));
const { ESLint } = require('eslint');
const eslintOptions = {
baseConfig: {
env: {
es2021: true,
node: true
},
extends: [
'eslint:recommended',
'plugin:jest/recommended'
],
parserOptions: {
ecmaVersion: 'latest'
},
rules: rules
}
};
const filesToLint = [ '.' ];
test('Rules object defined', () => {
expect(rules).not.toBeUndefined();
});
test('Linter should be able to load rules', () => {
expect(() => new ESLint(eslintOptions)).not.toThrow();
});
test('Linter should pass against repo files', async () => {
const eslint = new ESLint(eslintOptions);
const formatter = await eslint.loadFormatter('json');
const lintResults = await eslint.lintFiles(filesToLint);
const resultText = formatter.format(lintResults);
const results = JSON.parse(resultText);
for (const file of results) {
expect(file.errorCount).toBe(0);
expect(file.warningCount).toBe(0);
}
});