forked from mysticatea/eslint-plugin-node
-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6aee9f2
commit 86a5242
Showing
18 changed files
with
90 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @fileoverview Utilities for eslint compatibility. | ||
* @see https://eslint.org/docs/latest/use/migrate-to-9.0.0#removed-context-methods | ||
* @author aladdin-add<[email protected]> | ||
*/ | ||
"use strict" | ||
|
||
/** @import { Rule } from 'eslint' */ | ||
/** @typedef {import('estree').Node} Node */ | ||
|
||
exports.getSourceCode = function (/** @type Rule.RuleContext */ context) { | ||
return context.sourceCode || context.getSourceCode() | ||
} | ||
|
||
exports.getScope = function ( | ||
/** @type {Rule.RuleContext} */ context, | ||
/** @type {Node} */ node | ||
) { | ||
const sourceCode = exports.getSourceCode(context) | ||
return sourceCode.getScope?.(node || sourceCode.ast) || context.getScope() | ||
} | ||
|
||
exports.getAncestors = function ( | ||
/** @type {Rule.RuleContext} */ context, | ||
/** @type {Node} */ node | ||
) { | ||
const sourceCode = exports.getSourceCode(context) | ||
return sourceCode.getAncestors?.(node) || context.getAncestors() | ||
} | ||
|
||
exports.getCwd = function (/** @type {Rule.RuleContext} */ context) { | ||
return context.cwd || context.getCwd() | ||
} | ||
|
||
exports.getPhysicalFilename = function ( | ||
/** @type {Rule.RuleContext} */ context | ||
) { | ||
return context.physicalFilename || context.getPhysicalFilename?.() | ||
} | ||
|
||
exports.getFilename = function (/** @type {Rule.RuleContext} */ context) { | ||
return context.filename || context.getFilename?.() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.