From af9fb0cb90dd504246da605f7501b05f34c6c473 Mon Sep 17 00:00:00 2001 From: Mark de Dios Date: Fri, 15 Mar 2024 14:45:17 -0700 Subject: [PATCH 1/2] set errorOnTypeScriptSyntacticAndSemanticIssues in parseForESLint to false and add, modify relevant tests respectively --- packages/parser/src/parser.ts | 7 ++++++ packages/parser/tests/lib/parser.test.ts | 31 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 32ed786ab2eb..57dd5264e064 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -103,6 +103,12 @@ function parseForESLint( options.ecmaFeatures = {}; } + /** + * Override errorOnTypeScriptSyntacticAndSemanticIssues and set it to false to prevent use from user config + * https://github.com/typescript-eslint/typescript-eslint/issues/8681#issuecomment-2000411834 + */ + options.errorOnTypeScriptSyntacticAndSemanticIssues = false; + const parserOptions: TSESTreeOptions = {}; Object.assign(parserOptions, options, { jsx: validateBoolean(options.ecmaFeatures.jsx), @@ -123,6 +129,7 @@ function parseForESLint( options.warnOnUnsupportedTypeScriptVersion, true, ); + if (!warnOnUnsupportedTypeScriptVersion) { parserOptions.loggerFn = false; } diff --git a/packages/parser/tests/lib/parser.test.ts b/packages/parser/tests/lib/parser.test.ts index e6bd731db075..cf373ebe2370 100644 --- a/packages/parser/tests/lib/parser.test.ts +++ b/packages/parser/tests/lib/parser.test.ts @@ -48,12 +48,42 @@ describe('parser', () => { }); }); + it('parseAndGenerateServices() should be called with options.errorOnTypeScriptSyntacticAndSemanticIssues overriden to false', () => { + const code = 'const valid = true;'; + const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices'); + const config: ParserOptions = { + loc: false, + comment: false, + range: false, + tokens: false, + sourceType: 'module' as const, + ecmaFeatures: { + globalReturn: false, + jsx: false, + }, + // ts-estree specific + filePath: './isolated-file.src.ts', + project: 'tsconfig.json', + errorOnTypeScriptSyntacticAndSemanticIssues: true, + tsconfigRootDir: path.resolve(__dirname, '../fixtures/services'), + extraFileExtensions: ['.foo'], + }; + parseForESLint(code, config); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy).toHaveBeenLastCalledWith(code, { + jsx: false, + ...config, + errorOnTypeScriptSyntacticAndSemanticIssues: false, + }); + }); + it('`warnOnUnsupportedTypeScriptVersion: false` should set `loggerFn: false` on typescript-estree', () => { const code = 'const valid = true;'; const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices'); parseForESLint(code, { warnOnUnsupportedTypeScriptVersion: true }); expect(spy).toHaveBeenCalledWith(code, { ecmaFeatures: {}, + errorOnTypeScriptSyntacticAndSemanticIssues: false, jsx: false, sourceType: 'script', warnOnUnsupportedTypeScriptVersion: true, @@ -64,6 +94,7 @@ describe('parser', () => { ecmaFeatures: {}, jsx: false, sourceType: 'script', + errorOnTypeScriptSyntacticAndSemanticIssues: false, loggerFn: false, warnOnUnsupportedTypeScriptVersion: false, }); From afcca53996d95b538b98adef00f0044bc6dc60a4 Mon Sep 17 00:00:00 2001 From: Mark de Dios Date: Wed, 27 Mar 2024 10:40:47 -0700 Subject: [PATCH 2/2] Move assignment of errors on ts syntactic and semantic issues to object assign --- packages/parser/src/parser.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 57dd5264e064..6aa369134a07 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -103,15 +103,14 @@ function parseForESLint( options.ecmaFeatures = {}; } - /** - * Override errorOnTypeScriptSyntacticAndSemanticIssues and set it to false to prevent use from user config - * https://github.com/typescript-eslint/typescript-eslint/issues/8681#issuecomment-2000411834 - */ - options.errorOnTypeScriptSyntacticAndSemanticIssues = false; - const parserOptions: TSESTreeOptions = {}; Object.assign(parserOptions, options, { jsx: validateBoolean(options.ecmaFeatures.jsx), + /** + * Override errorOnTypeScriptSyntacticAndSemanticIssues and set it to false to prevent use from user config + * https://github.com/typescript-eslint/typescript-eslint/issues/8681#issuecomment-2000411834 + */ + errorOnTypeScriptSyntacticAndSemanticIssues: false, }); const analyzeOptions: AnalyzeOptions = { globalReturn: options.ecmaFeatures.globalReturn, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy