forked from import-js/eslint-plugin-import
/
cli.js
79 lines (75 loc) · 2.22 KB
/
cli.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* tests that require fully booting up ESLint
*/
import path from 'path'
import { expect } from 'chai'
import { CLIEngine } from 'eslint'
import eslintPkg from 'eslint/package.json'
import semver from 'semver'
describe('CLI regression tests', function () {
describe('issue #210', function () {
let cli
before(function () {
cli = new CLIEngine({
useEslintrc: false,
configFile: './tests/files/issue210.config.js',
rulePaths: ['./src/rules'],
rules: {
'named': 2,
},
})
})
it("doesn't throw an error on gratuitous, erroneous self-reference", function () {
expect(() => cli.executeOnFiles(['./tests/files/issue210.js'])).not.to.throw(Error)
})
})
describe('issue #1645', function () {
let cli
beforeEach(function () {
if (semver.satisfies(eslintPkg.version, '< 6')) {
this.skip()
} else {
cli = new CLIEngine({
useEslintrc: false,
configFile: './tests/files/just-json-files/.eslintrc.json',
rulePaths: ['./src/rules'],
ignore: false,
})
}
})
it('throws an error on invalid JSON', function () {
const invalidJSON = './tests/files/just-json-files/invalid.json'
const results = cli.executeOnFiles([invalidJSON])
expect(results).to.eql({
results: [
{
filePath: path.resolve(invalidJSON),
messages: [
{
column: 2,
endColumn: 3,
endLine: 1,
line: 1,
message: 'Expected a JSON object, array or literal.',
nodeType: results.results[0].messages[0].nodeType, // we don't care about this one
ruleId: 'json/*',
severity: 2,
source: '\n',
},
],
errorCount: 1,
warningCount: 0,
fixableErrorCount: 0,
fixableWarningCount: 0,
source: ',\n',
},
],
errorCount: 1,
warningCount: 0,
fixableErrorCount: 0,
fixableWarningCount: 0,
usedDeprecatedRules: results.usedDeprecatedRules, // we don't care about this one
})
})
})
})