Skip to content

Commit

Permalink
refactor: use module.exports
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Apr 7, 2024
1 parent f0853cb commit 543e378
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/context.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
export function getFilename(context) {
function getFilename(context) {

Check warning on line 1 in src/context.js

View check run for this annotation

Codecov / codecov/patch

src/context.js#L1

Added line #L1 was not covered by tests
if ('filename' in context) {
return context.filename;

Check warning on line 3 in src/context.js

View check run for this annotation

Codecov / codecov/patch

src/context.js#L3

Added line #L3 was not covered by tests
}

return context.getFilename();
}

export function getPhysicalFilename(context) {
function getPhysicalFilename(context) {
if (context.getPhysicalFilename) {
return context.getPhysicalFilename();
}

return getFilename(context);
}

export function getSourceCode(context) {
function getSourceCode(context) {
if ('sourceCode' in context) {
return context.sourceCode;
}

return context.getSourceCode();
}

export function getScope(context, node) {
function getScope(context, node) {
const sourceCode = getSourceCode(context);

if (sourceCode && sourceCode.getScope) {
Expand All @@ -32,7 +32,7 @@ export function getScope(context, node) {
return context.getScope();
}

export function getAncestors(context, node) {
function getAncestors(context, node) {
const sourceCode = getSourceCode(context);

if (sourceCode && sourceCode.getAncestors) {
Expand All @@ -42,7 +42,7 @@ export function getAncestors(context, node) {
return context.getAncestors();
}

export function getDeclaredVariables(context, node) {
function getDeclaredVariables(context, node) {

Check warning on line 45 in src/context.js

View check run for this annotation

Codecov / codecov/patch

src/context.js#L45

Added line #L45 was not covered by tests
const sourceCode = getSourceCode(context);

if (sourceCode && sourceCode.getDeclaredVariables) {
Expand All @@ -51,3 +51,12 @@ export function getDeclaredVariables(context, node) {

return context.getDeclaredVariables(node);
}

module.exports = {

Check warning on line 55 in src/context.js

View check run for this annotation

Codecov / codecov/patch

src/context.js#L55

Added line #L55 was not covered by tests
getFilename,
getPhysicalFilename,
getSourceCode,
getScope,
getAncestors,
getDeclaredVariables,
};

0 comments on commit 543e378

Please sign in to comment.