Skip to content

Commit

Permalink
test: simplify getScope
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Oct 15, 2024
1 parent ede67fe commit 9e23712
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 23 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
},
"devDependencies": {
"@eslint-community/eslint-plugin-mysticatea": "^15.5.1",
"@types/eslint": "^8.56.12",
"c8": "^8.0.1",
"dot-prop": "^7.2.0",
"eslint": "^8.50.0",
Expand Down
2 changes: 1 addition & 1 deletion test/find-variable.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert"
import eslint from "eslint"
import { findVariable } from "../src/index.mjs"
import { getScope } from "./test-lib/get-scope.mjs"
import { getScope } from "./test-lib/eslint-compat.mjs"

describe("The 'findVariable' function", () => {
function getVariable(code, selector, withString = null) {
Expand Down
2 changes: 1 addition & 1 deletion test/get-innermost-scope.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert"
import eslint from "eslint"
import { getInnermostScope } from "../src/index.mjs"
import { getScope } from "./test-lib/get-scope.mjs"
import { getScope } from "./test-lib/eslint-compat.mjs"

describe("The 'getInnermostScope' function", () => {
let i = 0
Expand Down
2 changes: 1 addition & 1 deletion test/get-static-value.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from "assert"
import eslint from "eslint"
import semver from "semver"
import { getStaticValue } from "../src/index.mjs"
import { getScope } from "./test-lib/get-scope.mjs"
import { getScope } from "./test-lib/eslint-compat.mjs"

describe("The 'getStaticValue' function", () => {
for (const { code, expected, noScope = false } of [
Expand Down
2 changes: 1 addition & 1 deletion test/get-string-if-constant.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert"
import eslint from "eslint"
import { getStringIfConstant } from "../src/index.mjs"
import { getScope } from "./test-lib/get-scope.mjs"
import { getScope } from "./test-lib/eslint-compat.mjs"

describe("The 'getStringIfConstant' function", () => {
for (const { code, expected } of [
Expand Down
2 changes: 1 addition & 1 deletion test/reference-tracker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from "assert"
import eslint from "eslint"
import semver from "semver"
import { CALL, CONSTRUCT, ESM, READ, ReferenceTracker } from "../src/index.mjs"
import { getScope } from "./test-lib/get-scope.mjs"
import { getScope } from "./test-lib/eslint-compat.mjs"

const config = {
parserOptions: {
Expand Down
5 changes: 5 additions & 0 deletions test/test-lib/eslint-compat.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const getScope = (context, node) =>
getSourceCode(context).getScope?.(node) ?? context.getScope();

const getSourceCode = (context) =>
context.sourceCode ?? context.getSourceCode();
18 changes: 0 additions & 18 deletions test/test-lib/get-scope.mjs

This file was deleted.

0 comments on commit 9e23712

Please sign in to comment.