Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: simplify getScope #239

Draft
wants to merge 1 commit into
base: alpha
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading