Skip to content

Commit

Permalink
fix: fall back to deprecated getSourceCode(); fixes #1159
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Sep 20, 2023
1 parent e8b1475 commit 8374349
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
16 changes: 11 additions & 5 deletions src/iterateJsdoc.js
Expand Up @@ -694,8 +694,10 @@ const getUtils = (
indent,
) => {
const ancestors = /** @type {import('eslint').Rule.Node[]} */ (context.getAncestors());

// istanbul ignore next -- Fallback to deprecated method
const {
sourceCode,
sourceCode = context.getSourceCode(),
} = context;

const utils = /** @type {Utils} */ (getBasicUtils(context, settings));
Expand Down Expand Up @@ -2149,8 +2151,9 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
* @returns {void}
*/
const callIterator = (context, node, jsdocNodes, state, lastCall) => {
// istanbul ignore next -- Fallback to deprecated method
const {
sourceCode,
sourceCode = context.getSourceCode(),
} = context;
const {
lines,
Expand Down Expand Up @@ -2262,8 +2265,9 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
return {
// @ts-expect-error ESLint accepts
create (context) {
// istanbul ignore next -- Fallback to deprecated method
const {
sourceCode,
sourceCode = context.getSourceCode(),
} = context;
settings = getSettings(context);
if (!settings) {
Expand Down Expand Up @@ -2340,8 +2344,9 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
const checkFile = (iterator, ruleConfig) => {
return {
create (context) {
// istanbul ignore next -- Fallback to deprecated method
const {
sourceCode,
sourceCode = context.getSourceCode(),
} = context;
const settings = getSettings(context);
if (!settings) {
Expand Down Expand Up @@ -2459,8 +2464,9 @@ export default function iterateJsdoc (iterator, ruleConfig) {
}
}

// istanbul ignore next -- Fallback to deprecated method
const {
sourceCode,
sourceCode = context.getSourceCode(),
} = context;
const {
lines,
Expand Down
3 changes: 2 additions & 1 deletion src/rules/requireJsdoc.js
Expand Up @@ -288,8 +288,9 @@ const getOptions = (context, settings) => {
/** @type {import('eslint').Rule.RuleModule} */
export default {
create (context) {
// istanbul ignore next -- Fallback to deprecated method
const {
sourceCode,
sourceCode = context.getSourceCode(),
} = context;
const settings = getSettings(context);
if (!settings) {
Expand Down
3 changes: 2 additions & 1 deletion src/rules/requireReturns.js
Expand Up @@ -104,8 +104,9 @@ export default iterateJsdoc(({
initModuleExports: Boolean(publicOnly?.cjs ?? true),
initWindow: Boolean(publicOnly?.window ?? false),
};
// istanbul ignore next -- Fallback to deprecated method
const {
sourceCode,
sourceCode = context.getSourceCode(),
} = context;
const exported = exportParser.isUncommentedExport(
/** @type {import('eslint').Rule.Node} */ (node), sourceCode, opt, settings,
Expand Down

0 comments on commit 8374349

Please sign in to comment.