Skip to content

Commit 9d9e60e

Browse files
feat: throw an error when using a TS feature when it isn't avaliable
1 parent ea2d872 commit 9d9e60e

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

lib/rules/no-sync.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,23 @@ module.exports = {
124124
continue
125125
}
126126

127-
if (parserServices !== null) {
128-
const type = getTypeOfNode(node, parserServices)
129-
if (
130-
typeMatchesSpecifier(
131-
parserServices.program,
132-
ignore,
133-
type
134-
) &&
135-
(ignore.name === undefined ||
136-
ignore.name.includes(node.name))
137-
) {
138-
return
139-
}
127+
if (parserServices === null) {
128+
throw new Error(
129+
'TypeScript parser services not available. Rule "n/no-sync" is configured to use "ignores" option with a non-string value. This requires TypeScript parser services to be available.'
130+
)
131+
}
132+
133+
const type = getTypeOfNode(node, parserServices)
134+
if (
135+
typeMatchesSpecifier(
136+
parserServices.program,
137+
ignore,
138+
type
139+
) &&
140+
(ignore.name === undefined ||
141+
ignore.name.includes(node.name))
142+
) {
143+
return
140144
}
141145
}
142146

0 commit comments

Comments
 (0)