Skip to content

Commit 7183fac

Browse files
author
elevatebart
committed
convert error into reports
1 parent 0a4ce3b commit 7183fac

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/eslint-plugin/lib/rules/deprecate-imports.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,27 @@ module.exports = {
5454
const [deprecatedImports] = context.options
5555

5656
if (!deprecatedImports) {
57-
throw new Error('No deprecated imports provided')
57+
throw context.report({
58+
message: 'No deprecated imports provided',
59+
})
5860
}
5961

6062
if (!Array.isArray(deprecatedImports)) {
61-
throw new Error('Deprecated imports accepts an array of options ')
63+
throw context.report({
64+
message: 'Rule accepts an array of import definitions',
65+
})
6266
}
6367

6468
const emptyImport = deprecatedImports.find(
6569
(importToCheck) => !importToCheck.source
6670
)
6771

6872
if (emptyImport) {
69-
throw new Error(
70-
`No source provided for deprecated import ${JSON.stringify(
73+
throw context.report({
74+
message: `No source provided for deprecated import ${JSON.stringify(
7175
emptyImport
72-
)}`
73-
)
76+
)}`,
77+
})
7478
}
7579

7680
const deprecatedImportsWithArraySource = deprecatedImports.map(

0 commit comments

Comments
 (0)