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

Revert "feat(typescript-estree): add EXPERIMENTAL_useProjectService option to use TypeScript project service" #7251

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 0 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,38 +192,6 @@ jobs:
# Sadly 1 day is the minimum
retention-days: 1

unit_tests_tsserver:
name: Run Unit Tests with Experimental TSServer
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
package:
[
'eslint-plugin',
'eslint-plugin-internal',
'eslint-plugin-tslint',
'typescript-estree',
]
env:
COLLECT_COVERAGE: false
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Install
uses: ./.github/actions/prepare-install
with:
node-version: 18
- name: Build
uses: ./.github/actions/prepare-build
- name: Run unit tests for ${{ matrix.package }}
run: npx nx test ${{ matrix.package }} --coverage=false
env:
CI: true
TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER: true

website_tests:
# The NETLIFY_TOKEN secret will not be available on forks
if: github.repository_owner == 'typescript-eslint'
Expand Down
34 changes: 0 additions & 34 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,40 +141,6 @@
"${workspaceFolder}/packages/scope-manager/dist/index.js",
],
},
{
"type": "node",
"request": "launch",
"name": "Jest Test Current eslint-plugin-tslint Rule",
"cwd": "${workspaceFolder}/packages/eslint-plugin-tslint/",
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"args": [
"--runInBand",
"--no-cache",
"--no-coverage",
"${fileBasenameNoExtension}"
],
"sourceMaps": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": [
"${workspaceFolder}/packages/utils/src/index.ts",
"${workspaceFolder}/packages/utils/dist/index.js",
"${workspaceFolder}/packages/utils/src/ts-estree.ts",
"${workspaceFolder}/packages/utils/dist/ts-estree.js",
"${workspaceFolder}/packages/type-utils/src/index.ts",
"${workspaceFolder}/packages/type-utils/dist/index.js",
"${workspaceFolder}/packages/parser/src/index.ts",
"${workspaceFolder}/packages/parser/dist/index.js",
"${workspaceFolder}/packages/typescript-estree/src/index.ts",
"${workspaceFolder}/packages/typescript-estree/dist/index.js",
"${workspaceFolder}/packages/types/src/index.ts",
"${workspaceFolder}/packages/types/dist/index.js",
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
],
},
{
"type": "node",
"request": "launch",
Expand Down
11 changes: 1 addition & 10 deletions docs/packages/TypeScript_ESTree.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,6 @@ interface ParseAndGenerateServicesOptions extends ParseOptions {
*/
errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;

/**
* ***EXPERIMENTAL FLAG*** - Use this at your own risk.
*
* Whether to create a shared TypeScript server to power program creation.
*
* @see https://github.com/typescript-eslint/typescript-eslint/issues/6575
*/
EXPERIMENTAL_useProjectService?: boolean;

/**
* ***EXPERIMENTAL FLAG*** - Use this at your own risk.
*
Expand All @@ -164,7 +155,7 @@ interface ParseAndGenerateServicesOptions extends ParseOptions {
*
* This flag REQUIRES at least TS v3.9, otherwise it does nothing.
*
* @see https://github.com/typescript-eslint/typescript-eslint/issues/2094
* See: https://github.com/typescript-eslint/typescript-eslint/issues/2094
*/
EXPERIMENTAL_useSourceOfProjectReferenceRedirect?: boolean;

Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-plugin-tslint/src/rules/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ESLintUtils } from '@typescript-eslint/utils';
import path from 'path';
import type { RuleSeverity } from 'tslint';
import { Configuration } from 'tslint';

Expand Down Expand Up @@ -119,7 +118,7 @@ export default createRule<Options, MessageIds>({
context,
[{ rules: tslintRules, rulesDirectory: tslintRulesDirectory, lintFile }],
) {
const fileName = path.resolve(context.getCwd(), context.getFilename());
const fileName = context.getFilename();
const sourceCode = context.getSourceCode().text;
const services = ESLintUtils.getParserServices(context);
const program = services.program;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const ruleTester = new RuleTester({
});

const withMetaParserOptions = {
EXPERIMENTAL_useProjectService: false,
tsconfigRootDir: getFixturesRootDir(),
project: './tsconfig-withmeta.json',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ function getElem(dict: Record<string, { foo: string }>, key: string) {
}
`,
parserOptions: {
EXPERIMENTAL_useProjectService: false,
tsconfigRootDir: getFixturesRootDir(),
project: './tsconfig.noUncheckedIndexedAccess.json',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function assignmentTest(
const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
parserOptions: {
EXPERIMENTAL_useProjectService: false,
project: './tsconfig.noImplicitThis.json',
tsconfigRootDir: getFixturesRootDir(),
},
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin/tests/rules/no-unsafe-call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getFixturesRootDir } from '../RuleTester';
const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
parserOptions: {
EXPERIMENTAL_useProjectService: false,
project: './tsconfig.noImplicitThis.json',
tsconfigRootDir: getFixturesRootDir(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getFixturesRootDir } from '../RuleTester';
const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
parserOptions: {
EXPERIMENTAL_useProjectService: false,
project: './tsconfig.noImplicitThis.json',
tsconfigRootDir: getFixturesRootDir(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getFixturesRootDir } from '../RuleTester';
const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
parserOptions: {
EXPERIMENTAL_useProjectService: false,
project: './tsconfig.noImplicitThis.json',
tsconfigRootDir: getFixturesRootDir(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const ruleTester = new RuleTester({
});

const withMetaParserOptions = {
EXPERIMENTAL_useProjectService: false,
tsconfigRootDir: getFixturesRootDir(),
project: './tsconfig-withmeta.json',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ const y = x!;

const ruleTesterWithNoUncheckedIndexAccess = new RuleTester({
parserOptions: {
EXPERIMENTAL_useProjectService: false,
sourceType: 'module',
tsconfigRootDir: getFixturesRootDir(),
project: './tsconfig.noUncheckedIndexedAccess.json',
Expand Down
7 changes: 3 additions & 4 deletions packages/parser/tests/lib/parser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as scopeManager from '@typescript-eslint/scope-manager';
import type { ParserOptions } from '@typescript-eslint/types';
import * as typescriptESTree from '@typescript-eslint/typescript-estree';
import path from 'path';

import { parse, parseForESLint } from '../../src/parser';

Expand Down Expand Up @@ -34,10 +33,10 @@ describe('parser', () => {
jsx: false,
},
// ts-estree specific
filePath: './isolated-file.src.ts',
filePath: 'isolated-file.src.ts',
project: 'tsconfig.json',
errorOnTypeScriptSyntacticAndSemanticIssues: false,
tsconfigRootDir: path.resolve(__dirname, '../fixtures/services'),
tsconfigRootDir: 'tests/fixtures/services',
extraFileExtensions: ['.foo'],
};
parseForESLint(code, config);
Expand Down Expand Up @@ -90,7 +89,7 @@ describe('parser', () => {
filePath: 'isolated-file.src.ts',
project: 'tsconfig.json',
errorOnTypeScriptSyntacticAndSemanticIssues: false,
tsconfigRootDir: path.join(__dirname, '../fixtures/services'),
tsconfigRootDir: 'tests/fixtures/services',
extraFileExtensions: ['.foo'],
};
parseForESLint(code, config);
Expand Down
2 changes: 0 additions & 2 deletions packages/rule-tester/tests/RuleTester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ describe('RuleTester', () => {
{
code: 'type-aware parser options should override the constructor config',
parserOptions: {
EXPERIMENTAL_useProjectService: false,
project: 'tsconfig.test-specific.json',
tsconfigRootDir: '/set/in/the/test/',
},
Expand Down Expand Up @@ -210,7 +209,6 @@ describe('RuleTester', () => {
"code": "type-aware parser options should override the constructor config",
"filename": "/set/in/the/test/file.ts",
"parserOptions": {
"EXPERIMENTAL_useProjectService": false,
"project": "tsconfig.test-specific.json",
"tsconfigRootDir": "/set/in/the/test/",
},
Expand Down
20 changes: 10 additions & 10 deletions packages/type-utils/tests/TypeOrValueSpecifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,42 +196,42 @@ describe('TypeOrValueSpecifier', () => {
],
[
'interface Foo {prop: string}; type Test = Foo;',
{ from: 'file', name: 'Foo', path: 'file.ts' },
{ from: 'file', name: 'Foo', path: 'tests/fixtures/file.ts' },
],
[
'type Foo = {prop: string}; type Test = Foo;',
{ from: 'file', name: 'Foo', path: 'file.ts' },
{ from: 'file', name: 'Foo', path: 'tests/fixtures/file.ts' },
],
[
'interface Foo {prop: string}; type Test = Foo;',
{
from: 'file',
name: 'Foo',
path: './////file.ts',
path: 'tests/../tests/fixtures/////file.ts',
},
],
[
'type Foo = {prop: string}; type Test = Foo;',
{
from: 'file',
name: 'Foo',
path: './////file.ts',
path: 'tests/../tests/fixtures/////file.ts',
},
],
[
'interface Foo {prop: string}; type Test = Foo;',
{
from: 'file',
name: ['Foo', 'Bar'],
path: 'file.ts',
path: 'tests/fixtures/file.ts',
},
],
[
'type Foo = {prop: string}; type Test = Foo;',
{
from: 'file',
name: ['Foo', 'Bar'],
path: 'file.ts',
path: 'tests/fixtures/file.ts',
},
],
])('matches a matching file specifier: %s', runTestPositive);
Expand All @@ -247,14 +247,14 @@ describe('TypeOrValueSpecifier', () => {
],
[
'interface Foo {prop: string}; type Test = Foo;',
{ from: 'file', name: 'Foo', path: 'wrong-file.ts' },
{ from: 'file', name: 'Foo', path: 'tests/fixtures/wrong-file.ts' },
],
[
'interface Foo {prop: string}; type Test = Foo;',
{
from: 'file',
name: ['Foo', 'Bar'],
path: 'wrong-file.ts',
path: 'tests/fixtures/wrong-file.ts',
},
],
])("doesn't match a mismatched file specifier: %s", runTestNegative);
Expand Down Expand Up @@ -399,14 +399,14 @@ describe('TypeOrValueSpecifier', () => {
['type Test = RegExp;', { from: 'file', name: ['RegExp', 'BigInt'] }],
[
'type Test = RegExp;',
{ from: 'file', name: 'RegExp', path: 'file.ts' },
{ from: 'file', name: 'RegExp', path: 'tests/fixtures/file.ts' },
],
[
'type Test = RegExp;',
{
from: 'file',
name: ['RegExp', 'BigInt'],
path: 'file.ts',
path: 'tests/fixtures/file.ts',
},
],
[
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/parser-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ interface ParserOptions {
debugLevel?: DebugLevel;
errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;
errorOnUnknownASTType?: boolean;
EXPERIMENTAL_useProjectService?: boolean; // purposely undocumented for now
EXPERIMENTAL_useSourceOfProjectReferenceRedirect?: boolean; // purposely undocumented for now
extraFileExtensions?: string[];
filePath?: string;
Expand Down
6 changes: 1 addition & 5 deletions packages/typescript-estree/src/clear-caches.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { clearWatchCaches } from './create-program/getWatchProgramsForProjects';
import { clearProgramCache as clearProgramCacheOriginal } from './parser';
import {
clearTSConfigMatchCache,
clearTSServerProjectService,
} from './parseSettings/createParseSettings';
import { clearTSConfigMatchCache } from './parseSettings/createParseSettings';
import { clearGlobCache } from './parseSettings/resolveProjectList';

/**
Expand All @@ -17,7 +14,6 @@ export function clearCaches(): void {
clearProgramCacheOriginal();
clearWatchCaches();
clearTSConfigMatchCache();
clearTSServerProjectService();
clearGlobCache();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as ts from 'typescript';
import { firstDefined } from '../node-utils';
import type { ParseSettings } from '../parseSettings';
import { describeFilePath } from './describeFilePath';
import { getWatchProgramsForProjects } from './getWatchProgramsForProjects';
import type { ASTAndDefiniteProgram } from './shared';
import { getAstFromProgram } from './shared';

Expand All @@ -27,12 +28,12 @@ const DEFAULT_EXTRA_FILE_EXTENSIONS = [
*/
function createProjectProgram(
parseSettings: ParseSettings,
programsForProjects: readonly ts.Program[],
): ASTAndDefiniteProgram | undefined {
log('Creating project program for: %s', parseSettings.filePath);

const programsForProjects = getWatchProgramsForProjects(parseSettings);
const astAndProgram = firstDefined(programsForProjects, currentProgram =>
getAstFromProgram(currentProgram, parseSettings.filePath),
getAstFromProgram(currentProgram, parseSettings),
);

// The file was either matched within the tsconfig, or we allow creating a default program
Expand Down