-
-
Notifications
You must be signed in to change notification settings - Fork 49
feat(no-sync)!: move ts-declaration-location
to peerDependencies
#451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,6 @@ let typeMatchesSpecifier = | |
/** @type {import('ts-declaration-location').default | undefined} */ | ||
(undefined) | ||
|
||
try { | ||
typeMatchesSpecifier = | ||
/** @type {import('ts-declaration-location').default} */ ( | ||
/** @type {unknown} */ (require("ts-declaration-location")) | ||
) | ||
|
||
// eslint-disable-next-line no-empty -- Deliberately left empty. | ||
} catch {} | ||
const getTypeOfNode = require("../util/get-type-of-node") | ||
const getParserServices = require("../util/get-parser-services") | ||
const getFullTypeName = require("../util/get-full-type-name") | ||
|
@@ -124,6 +116,25 @@ module.exports = { | |
const selector = options.allowAtRootLevel | ||
? selectors.map(selector => `:function ${selector}`) | ||
: selectors | ||
|
||
const hasAdvancedIgnores = ignores.some( | ||
ignore => typeof ignore !== "string" | ||
) | ||
|
||
// Only require `ts-declaration-location` if needed and not already required. | ||
if (hasAdvancedIgnores && typeMatchesSpecifier === undefined) { | ||
try { | ||
typeMatchesSpecifier = | ||
/** @type {import('ts-declaration-location').default} */ ( | ||
/** @type {unknown} */ ( | ||
require("ts-declaration-location") | ||
) | ||
) | ||
} catch { | ||
// Will throw below if needed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Actually, let's just move the throw below up to here: // Only require `ts-declaration-location` if needed and not already required.
if (hasAdvancedIgnores) {
if (typeMatchesSpecifier === undefined) {
try {
typeMatchesSpecifier =
/** @type {import('ts-declaration-location').default} */ (
/** @type {unknown} */ (
require("ts-declaration-location")
)
)
} catch {
typeMatchesSpecifier === null
}
} else {
throw new Error(
'ts-declaration-location not available. Rule "n/no-sync" is configured to use "ignores" option with a non-string value. This requires ts-declaration-location to be available.'
)
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... Or we could move this load down to where the throw below was ... |
||
} | ||
} | ||
|
||
return { | ||
/** | ||
* @param {import('estree').Identifier & {parent: import('estree').Node}} node | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type should now be:
/** @type {import('ts-declaration-location').default | undefined | null} */