diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 32ed786ab2eb..6aa369134a07 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -106,6 +106,11 @@ function parseForESLint( 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, @@ -123,6 +128,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, }); 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