Skip to content

Commit 23ee43a

Browse files
committed
test: simplify getScope
1 parent fd0f085 commit 23ee43a

9 files changed

+12
-24
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
object: "context",
1313
property: "getScope",
1414
message:
15-
"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.",
15+
"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.",
1616
},
1717
],
1818
},

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
},
5555
"devDependencies": {
5656
"@eslint-community/eslint-plugin-mysticatea": "^15.6.1",
57+
"@types/eslint": "^8.56.12",
5758
"c8": "^8.0.1",
5859
"dot-prop": "^7.2.0",
5960
"eslint": "^8.57.1",

test/find-variable.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from "assert"
22
import eslint from "eslint"
33
import { findVariable } from "../src/index.mjs"
4-
import { getScope } from "./test-lib/get-scope.mjs"
4+
import { getScope } from "./test-lib/eslint-compat.mjs"
55

66
describe("The 'findVariable' function", () => {
77
function getVariable(code, selector, withString = null) {

test/get-innermost-scope.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from "assert"
22
import eslint from "eslint"
33
import { getInnermostScope } from "../src/index.mjs"
4-
import { getScope } from "./test-lib/get-scope.mjs"
4+
import { getScope } from "./test-lib/eslint-compat.mjs"
55

66
describe("The 'getInnermostScope' function", () => {
77
let i = 0

test/get-static-value.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from "assert"
22
import eslint from "eslint"
33
import semver from "semver"
44
import { getStaticValue } from "../src/index.mjs"
5-
import { getScope } from "./test-lib/get-scope.mjs"
5+
import { getScope } from "./test-lib/eslint-compat.mjs"
66

77
describe("The 'getStaticValue' function", () => {
88
for (const { code, expected, noScope = false } of [

test/get-string-if-constant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from "assert"
22
import eslint from "eslint"
33
import { getStringIfConstant } from "../src/index.mjs"
4-
import { getScope } from "./test-lib/get-scope.mjs"
4+
import { getScope } from "./test-lib/eslint-compat.mjs"
55

66
describe("The 'getStringIfConstant' function", () => {
77
for (const { code, expected } of [

test/reference-tracker.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from "assert"
22
import eslint from "eslint"
33
import semver from "semver"
44
import { CALL, CONSTRUCT, ESM, READ, ReferenceTracker } from "../src/index.mjs"
5-
import { getScope } from "./test-lib/get-scope.mjs"
5+
import { getScope } from "./test-lib/eslint-compat.mjs"
66

77
const config = {
88
parserOptions: {

test/test-lib/eslint-compat.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const getScope = (context, node) =>
2+
getSourceCode(context).getScope?.(node) ?? context.getScope();
3+
4+
const getSourceCode = (context) =>
5+
context.sourceCode ?? context.getSourceCode();

test/test-lib/get-scope.mjs

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)