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 25, 2024
1 parent fd0f085 commit 23ee43a
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
object: "context",
property: "getScope",
message:
"If you are using it in a test case, use test/test-lib/get-scope.mjs instead. Other than that, the API should also be compatible with ESLint v9.",
"If you are using it in a test case, use test/test-lib/eslint-compat.mjs#getScope instead. Other than that, the API should also be compatible with ESLint v9.",
},
],
},
Expand Down
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.6.1",
"@types/eslint": "^8.56.12",
"c8": "^8.0.1",
"dot-prop": "^7.2.0",
"eslint": "^8.57.1",
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 23ee43a

Please sign in to comment.