Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(scope-manager): finish migrating tovitest#11111

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
17 commits
Select commitHold shift + click to select a range
e68a99f
Update `vitest` to version 3.1.2
aryaemami59Apr 27, 2025
fc82196
Fix lint issues for `eslint-plugin`
aryaemami59Apr 27, 2025
00a9e07
chore(scope-manager): finish migrating to `vitest`
aryaemami59Apr 27, 2025
a67d82b
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Apr 28, 2025
9461ae4
Lint `vitest-custom-matchers.d.ts` files
aryaemami59Apr 28, 2025
d4758cb
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Apr 28, 2025
a47cdfc
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Apr 30, 2025
563c866
update `vite` to version 6.3.4
aryaemami59Apr 30, 2025
83fc610
update `chai` to version 5.2.0
aryaemami59Apr 30, 2025
88fae3b
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59May 1, 2025
c9cb546
update `@vitest/eslint-plugin` to version 1.1.44
aryaemami59May 1, 2025
7bdc0ef
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59May 3, 2025
301fa4d
fix custom matchers
aryaemami59May 3, 2025
fe1a557
fix custom matchers
aryaemami59May 3, 2025
efa960e
switch `.toEqual` usages to `.toStrictEqual`
aryaemami59May 4, 2025
93f8445
update `vite` to version 6.3.5
aryaemami59May 5, 2025
90b2ccc
Merge branch 'main'
JoshuaKGoldbergMay 5, 2025
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: 2 additions & 0 deletionsknip.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -91,6 +91,8 @@ export default {
entry: [
'tests/**/*.{bench,test,test-d}.?(c|m)ts?(x)',
'tests/test-utils/serializers/index.ts',
'tests/test-utils/custom-matchers/custom-matchers.ts',
'tests/test-utils/custom-matchers/vitest-custom-matchers.d.ts',
],
},
},
Expand Down
5 changes: 3 additions & 2 deletionspackages/scope-manager/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"clean": "rimraf dist/_ts4.3/coverage/",
"clean": "rimraf dist/ coverage/",
"clean-fixtures": "rimraf -g \"./src/**/fixtures/**/snapshots\"",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"generate-lib": "npx nx generate-lib repo",
Expand All@@ -53,9 +53,10 @@
"devDependencies": {
"@typescript-eslint/typescript-estree": "8.31.1",
"@vitest/coverage-v8": "^3.1.2",
"@vitest/pretty-format": "^3.1.2",
"glob": "*",
"prettier": "^3.2.5",
"pretty-format": "*",
"rimraf": "*",
"typescript": "*",
"vitest": "^3.1.2"
},
Expand Down
12 changes: 4 additions & 8 deletionspackages/scope-manager/tests/eslint-scope/arguments.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
import {
expectToBeFunctionScope,
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../test-utils';
import { ScopeType } from '../../src/index.js';
import { getRealVariables, parseAndAnalyze } from '../test-utils/index.js';

describe('arguments', () => {
it('arguments are correctly materialized', () => {
Expand All@@ -17,13 +13,13 @@ describe('arguments', () => {

let scope = scopeManager.scopes[0];
let variables = getRealVariables(scope.variables);
expectToBeGlobalScope(scope);
assert.isScopeOfType(scope, ScopeType.global);
expect(variables).toHaveLength(0);
expect(scope.references).toHaveLength(0);

scope = scopeManager.scopes[1];
variables = getRealVariables(scope.variables);
expectToBeFunctionScope(scope);
assert.isScopeOfType(scope, ScopeType.function);
expect(variables).toHaveLength(1);
expect(variables[0].name).toBe('arguments');
expect(scope.references).toHaveLength(1);
Expand Down
20 changes: 7 additions & 13 deletionspackages/scope-manager/tests/eslint-scope/catch-scope.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
import {
expectToBeBlockScope,
expectToBeCatchScope,
expectToBeFunctionScope,
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../test-utils';
import { ScopeType } from '../../src/index.js';
import { getRealVariables, parseAndAnalyze } from '../test-utils/index.js';

describe('catch', () => {
it('creates scope', () => {
Expand All@@ -21,33 +15,33 @@ describe('catch', () => {

let scope = scopeManager.scopes[0];
let variables = getRealVariables(scope.variables);
expectToBeGlobalScope(scope);
assert.isScopeOfType(scope, ScopeType.global);
expect(variables).toHaveLength(0);
expect(scope.references).toHaveLength(0);

scope = scopeManager.scopes[1];
variables = getRealVariables(scope.variables);
expectToBeFunctionScope(scope);
assert.isScopeOfType(scope, ScopeType.function);
expect(variables).toHaveLength(1);
expect(variables[0].name).toBe('arguments');
expect(scope.references).toHaveLength(0);

scope = scopeManager.scopes[2];
variables = getRealVariables(scope.variables);
expectToBeBlockScope(scope);
assert.isScopeOfType(scope, ScopeType.block);
expect(variables).toHaveLength(0);
expect(scope.references).toHaveLength(0);

scope = scopeManager.scopes[3];
variables = getRealVariables(scope.variables);
expectToBeCatchScope(scope);
assert.isScopeOfType(scope, ScopeType.catch);
expect(variables).toHaveLength(1);
expect(variables[0].name).toBe('e');
expect(scope.references).toHaveLength(0);

scope = scopeManager.scopes[4];
variables = getRealVariables(scope.variables);
expectToBeBlockScope(scope);
assert.isScopeOfType(scope, ScopeType.block);
expect(variables).toHaveLength(0);
expect(scope.references).toHaveLength(0);
});
Expand Down
42 changes: 24 additions & 18 deletionspackages/scope-manager/tests/eslint-scope/class-fields.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
import {
expectToBeClassFieldInitializerScope,
expectToBeClassScope,
expectToBeGlobalScope,
expectToBeIdentifier,
parseAndAnalyze,
} from '../test-utils';
import { AST_NODE_TYPES } from '@typescript-eslint/types';

import { ScopeType } from '../../src/index.js';
import { parseAndAnalyze } from '../test-utils/index.js';

describe('Class fields', () => {
it('class C { f = g }', () => {
const { scopeManager } = parseAndAnalyze('class C { f = g }');

const globalScope = scopeManager.scopes[0];
expectToBeGlobalScope(globalScope);
assert.isScopeOfType(globalScope, ScopeType.global);

const classScope = globalScope.childScopes[0];
// should create a class scope
expectToBeClassScope(classScope);
assert.isScopeOfType(classScope, ScopeType.class);
// The class scope has no references
expect(classScope.references).toHaveLength(0);
// The class scope has only the variable 'C'; it doesn't have the field name 'f'.
Expand All@@ -24,9 +21,15 @@ describe('Class fields', () => {

const classFieldInitializerScope = classScope.childScopes[0];
// The class scope has a class-field-initializer scope.
expectToBeClassFieldInitializerScope(classFieldInitializerScope);
assert.isScopeOfType(
classFieldInitializerScope,
ScopeType.classFieldInitializer,
);
// The class-field-initializer scope's block is the node of the field initializer.
expectToBeIdentifier(classFieldInitializerScope.block);
assert.isNodeOfType(
classFieldInitializerScope.block,
AST_NODE_TYPES.Identifier,
);
expect(classFieldInitializerScope.block.name).toBe('g');
// The class-field-initializer scope's variableScope is itself.
expect(classFieldInitializerScope.variableScope).toBe(
Expand All@@ -43,11 +46,11 @@ describe('Class fields', () => {
const { scopeManager } = parseAndAnalyze('class C { f }');

const globalScope = scopeManager.scopes[0];
expectToBeGlobalScope(globalScope);
assert.isScopeOfType(globalScope, ScopeType.global);

const classScope = globalScope.childScopes[0];
// should create a class scope
expectToBeClassScope(classScope);
assert.isScopeOfType(classScope, ScopeType.class);
// The class scope has no references
expect(classScope.references).toHaveLength(0);
// The class scope has no child scopes; fields that don't have initializers don't create any class-field-initializer scopes.
Expand All@@ -61,11 +64,11 @@ describe('Class fields', () => {
const { scopeManager } = parseAndAnalyze('class C { [fname] }');

const globalScope = scopeManager.scopes[0];
expectToBeGlobalScope(globalScope);
assert.isScopeOfType(globalScope, ScopeType.global);

const classScope = globalScope.childScopes[0];
// should create a class scope
expectToBeClassScope(classScope);
assert.isScopeOfType(classScope, ScopeType.class);
// The class scope has only the reference `fname`.
expect(classScope.references).toHaveLength(1);
// The class scope has no child scopes; fields that don't have initializers don't create any class-field-initializer scopes.
Expand All@@ -76,18 +79,21 @@ describe('Class fields', () => {
const { scopeManager } = parseAndAnalyze('class C { [fname] = value }');

const globalScope = scopeManager.scopes[0];
expectToBeGlobalScope(globalScope);
assert.isScopeOfType(globalScope, ScopeType.global);

const classScope = globalScope.childScopes[0];
// should create a class scope
expectToBeClassScope(classScope);
assert.isScopeOfType(classScope, ScopeType.class);
// The class scope has only the reference `fname`; it doesn't have the reference 'value'.
expect(classScope.references).toHaveLength(1);
expect(classScope.references[0].identifier.name).toBe('fname');

const classFieldInitializerScope = classScope.childScopes[0];
// The class scope has a class-field-initializer scope.
expectToBeClassFieldInitializerScope(classFieldInitializerScope);
assert.isScopeOfType(
classFieldInitializerScope,
ScopeType.classFieldInitializer,
);
// The class-field-initializer scope has the reference 'value'.
expect(classFieldInitializerScope.references).toHaveLength(1);
expect(classFieldInitializerScope.references[0].identifier.name).toBe(
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
import { AST_NODE_TYPES } from '@typescript-eslint/types';

import {
expectToBeFunctionScope,
expectToBeGlobalScope,
getRealVariables,
parseAndAnalyze,
} from '../test-utils';
import { ScopeType } from '../../src/index.js';
import { getRealVariables, parseAndAnalyze } from '../test-utils/index.js';

describe('ES6 arrow function expression', () => {
it('materialize scope for arrow function expression', () => {
Expand All@@ -21,16 +17,16 @@ describe('ES6 arrow function expression', () => {

let scope = scopeManager.scopes[0];
let variables = getRealVariables(scope.variables);
expectToBeGlobalScope(scope);
assert.isScopeOfType(scope, ScopeType.global);
expect(scope.block.type).toBe(AST_NODE_TYPES.Program);
expect(scope.isStrict).toBeFalsy();
expect(scope.isStrict).toBe(false);
expect(variables).toHaveLength(1);

scope = scopeManager.scopes[1];
variables = getRealVariables(scope.variables);
expectToBeFunctionScope(scope);
assert.isScopeOfType(scope, ScopeType.function);
expect(scope.block.type).toBe(AST_NODE_TYPES.ArrowFunctionExpression);
expect(scope.isStrict).toBeFalsy();
expect(scope.isStrict).toBe(false);
expect(variables).toHaveLength(2);

// There's no "arguments"
Expand All@@ -45,16 +41,16 @@ describe('ES6 arrow function expression', () => {

let scope = scopeManager.scopes[0];
let variables = getRealVariables(scope.variables);
expectToBeGlobalScope(scope);
assert.isScopeOfType(scope, ScopeType.global);
expect(scope.block.type).toBe(AST_NODE_TYPES.Program);
expect(scope.isStrict).toBeFalsy();
expect(scope.isStrict).toBe(false);
expect(variables).toHaveLength(1);

scope = scopeManager.scopes[1];
variables = getRealVariables(scope.variables);
expectToBeFunctionScope(scope);
assert.isScopeOfType(scope, ScopeType.function);
expect(scope.block.type).toBe(AST_NODE_TYPES.ArrowFunctionExpression);
expect(scope.isStrict).toBeFalsy();
expect(scope.isStrict).toBe(false);
expect(variables).toHaveLength(4);

// There's no "arguments"
Expand All@@ -74,16 +70,16 @@ describe('ES6 arrow function expression', () => {

let scope = scopeManager.scopes[0];
let variables = getRealVariables(scope.variables);
expectToBeGlobalScope(scope);
assert.isScopeOfType(scope, ScopeType.global);
expect(scope.block.type).toBe(AST_NODE_TYPES.Program);
expect(scope.isStrict).toBeTruthy();
expect(scope.isStrict).toBe(true);
expect(variables).toHaveLength(1);

scope = scopeManager.scopes[1];
variables = getRealVariables(scope.variables);
expectToBeFunctionScope(scope);
assert.isScopeOfType(scope, ScopeType.function);
expect(scope.block.type).toBe(AST_NODE_TYPES.ArrowFunctionExpression);
expect(scope.isStrict).toBeTruthy();
expect(scope.isStrict).toBe(true);
expect(variables).toHaveLength(0);
});

Expand All@@ -98,16 +94,16 @@ describe('ES6 arrow function expression', () => {

let scope = scopeManager.scopes[0];
let variables = getRealVariables(scope.variables);
expectToBeGlobalScope(scope);
assert.isScopeOfType(scope, ScopeType.global);
expect(scope.block.type).toBe(AST_NODE_TYPES.Program);
expect(scope.isStrict).toBeFalsy();
expect(scope.isStrict).toBe(false);
expect(variables).toHaveLength(1);

scope = scopeManager.scopes[1];
variables = getRealVariables(scope.variables);
expectToBeFunctionScope(scope);
assert.isScopeOfType(scope, ScopeType.function);
expect(scope.block.type).toBe(AST_NODE_TYPES.ArrowFunctionExpression);
expect(scope.isStrict).toBeTruthy();
expect(scope.isStrict).toBe(true);
expect(variables).toHaveLength(0);
});

Expand All@@ -119,9 +115,9 @@ describe('ES6 arrow function expression', () => {
const scope = scopeManager.scopes[1];
const variables = getRealVariables(scope.variables);

expectToBeFunctionScope(scope);
assert.isScopeOfType(scope, ScopeType.function);
expect(scope.block.type).toBe(AST_NODE_TYPES.ArrowFunctionExpression);
expect(scope.isStrict).toBeFalsy();
expect(scope.isStrict).toBe(false);
expect(variables).toHaveLength(1);
});
});
Loading

[8]ページ先頭

©2009-2025 Movatter.jp