Skip to content
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
10 changes: 10 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ export default tseslint.config(
},
},
rules: {
"no-restricted-syntax": [
"error",
// Forbid default import from "typescript"
{
message: 'Default import from "typescript" is not allowed.',
selector:
'ImportDeclaration[source.value="typescript"] > ImportDefaultSpecifier',
},
],

// These off-by-default rules work well for this repo and we like them on.
"logical-assignment-operators": [
"error",
Expand Down
2 changes: 1 addition & 1 deletion src/comments.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it, vitest } from "vitest";

import { forEachComment } from "./comments";
Expand Down
2 changes: 1 addition & 1 deletion src/comments.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import { forEachToken } from "./tokens";

Expand Down
2 changes: 1 addition & 1 deletion src/compilerOptions.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it } from "vitest";

import {
Expand Down
2 changes: 1 addition & 1 deletion src/compilerOptions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

/* eslint-disable jsdoc/informative-docs */
/**
Expand Down
2 changes: 1 addition & 1 deletion src/flags.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

/**
* Test if the given node has the given `ModifierFlags` set.
Expand Down
2 changes: 1 addition & 1 deletion src/modifiers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

/**
* Test if the given iterable includes a modifier of any of the given kinds.
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/access.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it } from "vitest";

import { createNode } from "../test/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/access.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import { isAssignmentKind } from "../syntax";

Expand Down
2 changes: 1 addition & 1 deletion src/nodes/typeGuards/compound.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it } from "vitest";

import { createNode } from "../../test/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/typeGuards/compound.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";

import { isSuperExpression } from "./single";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/typeGuards/single.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it } from "vitest";

import { createNode } from "../../test/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/typeGuards/single.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";

/**
* A node that represents the any keyword.
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/typeGuards/union.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it } from "vitest";

import { createNode } from "../../test/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/typeGuards/union.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";

import { isTsVersionAtLeast } from "../../utils";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import { isTransientSymbolLinksFlagSet } from "../flags";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/scopes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

/**
* Is the node a scope boundary, specifically due to it being a function.
Expand Down
2 changes: 1 addition & 1 deletion src/syntax.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it } from "vitest";

import {
Expand Down
2 changes: 1 addition & 1 deletion src/syntax.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

/**
* Test of the kind given is for assignment.
Expand Down
2 changes: 1 addition & 1 deletion src/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as tsvfs from "@typescript/vfs";
import ts from "typescript";
import * as ts from "typescript";

interface SourceFileAndTypeChecker {
sourceFile: ts.SourceFile;
Expand Down
2 changes: 1 addition & 1 deletion src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Original license MIT:
// https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

/**
* Callback type used for {@link forEachToken}.
Expand Down
2 changes: 1 addition & 1 deletion src/types/getters.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it } from "vitest";

import { createSourceFileAndTypeChecker } from "../test/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/types/getters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import { isNamedDeclarationWithName } from "../nodes/typeGuards";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/types/typeGuards/compound.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it } from "vitest";

import { createSourceFileAndTypeChecker } from "../../test/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/types/typeGuards/compound.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";

import { type IntrinsicType, isIntrinsicType } from "./intrinsic";
import { isTupleType, isTypeReference } from "./objects";
Expand Down
2 changes: 1 addition & 1 deletion src/types/typeGuards/intrinsic.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it } from "vitest";

import { createSourceFileAndTypeChecker } from "../../test/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/types/typeGuards/intrinsic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";

import { isTypeFlagSet } from "../../flags";

Expand Down
2 changes: 1 addition & 1 deletion src/types/typeGuards/literal.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it } from "vitest";

import { createSourceFileAndTypeChecker } from "../../test/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/types/typeGuards/literal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";

import { isTypeFlagSet } from "../../flags";
import { type FreshableIntrinsicType } from "./compound";
Expand Down
2 changes: 1 addition & 1 deletion src/types/typeGuards/objects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";

import { isObjectFlagSet } from "../../flags";
import { isObjectType } from "./single";
Expand Down
2 changes: 1 addition & 1 deletion src/types/typeGuards/single.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, expectTypeOf, it } from "vitest";

import { createSourceFileAndTypeChecker } from "../../test/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/types/typeGuards/single.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";

import { isTypeFlagSet } from "../../flags";

Expand Down
2 changes: 1 addition & 1 deletion src/types/utilities.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, it } from "vitest";

import { createSourceFileAndTypeChecker } from "../test/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/types/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import {
isModifierFlagSet,
Expand Down
2 changes: 1 addition & 1 deletion src/usage/Scope.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import type { EnumScope, NamespaceScope } from "./scopes";

Expand Down
2 changes: 1 addition & 1 deletion src/usage/UsageWalker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import { includesModifier } from "../modifiers";
import { DeclarationDomain } from "./declarations";
Expand Down
2 changes: 1 addition & 1 deletion src/usage/collectVariableUsage.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { query } from "@phenomnomnominal/tsquery";
import ts from "typescript";
import * as ts from "typescript";
import { describe, expect, test } from "vitest";

import { createSourceFile } from "../test/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/usage/collectVariableUsage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import { UsageInfo } from "./usage";
import { UsageWalker } from "./UsageWalker";
Expand Down
2 changes: 1 addition & 1 deletion src/usage/declarations.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import { identifierToKeywordKind } from "./utils";

Expand Down
2 changes: 1 addition & 1 deletion src/usage/getPropertyName.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import { isNumericOrStringLikeLiteral } from "../nodes/typeGuards/compound";

Expand Down
2 changes: 1 addition & 1 deletion src/usage/getUsageDomain.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import { identifierToKeywordKind } from "./utils";

Expand Down
2 changes: 1 addition & 1 deletion src/usage/scopes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import {
DeclarationDomain,
Expand Down
2 changes: 1 addition & 1 deletion src/usage/usage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import ts from "typescript";
import * as ts from "typescript";

import { DeclarationDomain, DeclarationInfo } from "./declarations";
import { UsageDomain } from "./getUsageDomain";
Expand Down
2 changes: 1 addition & 1 deletion src/usage/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";

/**
* Supports TypeScript<5 versions that don't have identifierToKeywordKind.
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import * as ts from "typescript";

const [tsMajor, tsMinor] = ts.versionMajorMinor
.split(".")
Expand Down
Loading