Skip to content

Commit dc6cedc

Browse files
committed
[max-dependencies]: add typescript tests for 'ignoreTypeImports'
1 parent 8195aa3 commit dc6cedc

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

tests/src/rules/max-dependencies.js

+42-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test } from '../utils'
1+
import { test, getTSParsers } from '../utils'
22

33
import { RuleTester } from 'eslint'
44

@@ -97,3 +97,44 @@ ruleTester.run('max-dependencies', rule, {
9797
}),
9898
],
9999
})
100+
101+
context('TypeScript', function() {
102+
getTSParsers().forEach((parser) => {
103+
ruleTester.run('max-dependencies', rule, {
104+
valid: [
105+
test({
106+
code: 'import type { x } from \'./foo\'; import { y } from \'./bar\';',
107+
parser: parser,
108+
options: [{
109+
max: 1,
110+
ignoreTypeImports: true,
111+
}],
112+
}),
113+
],
114+
invalid: [
115+
test({
116+
code: 'import type { x } from \'./foo\'; import type { y } from \'./bar\'',
117+
parser: parser,
118+
options: [{
119+
max: 1,
120+
}],
121+
errors: [
122+
'Maximum number of dependencies (1) exceeded.',
123+
],
124+
}),
125+
126+
test({
127+
code: 'import type { x } from \'./foo\'; import type { y } from \'./bar\'; import type { z } from \'./baz\'',
128+
parser: parser,
129+
options: [{
130+
max: 2,
131+
ignoreTypeImports: false,
132+
}],
133+
errors: [
134+
'Maximum number of dependencies (2) exceeded.',
135+
],
136+
}),
137+
],
138+
})
139+
})
140+
})

0 commit comments

Comments
 (0)