diff --git a/linter/src/CompilerWrapper.ts b/linter/src/CompilerWrapper.ts index a92a316b2e7dc900dcf2161ce5bbea3509c03ddc..080906125bc8022e4fb1119365ea076c85edecf3 100644 --- a/linter/src/CompilerWrapper.ts +++ b/linter/src/CompilerWrapper.ts @@ -19,11 +19,11 @@ import { consoleLog } from './TypeScriptLinter'; import { CommandLineOptions } from './CommandLineOptions'; import { LintOptions } from './LintOptions'; -export function compile(options: LintOptions, logTscErrors: boolean | undefined): ts.Program { - const createProgramOptions = formTscOptions(options.cmdOptions); +export function compile(options: LintOptions, extraOptions?: any): ts.Program { + const createProgramOptions = formTscOptions(options.cmdOptions, extraOptions); const program = ts.createProgram(createProgramOptions); // Log Tsc errors if needed - if (logTscErrors) { + if (options.cmdOptions.logTscErrors) { const diagnostics = ts.getPreEmitDiagnostics(program); logTscDiagnostic(diagnostics, consoleLog); diagnostics.forEach((diagnostic) => { @@ -39,7 +39,7 @@ export function compile(options: LintOptions, logTscErrors: boolean | undefined) return program; } -function formTscOptions(cmdOptions: CommandLineOptions): ts.CreateProgramOptions { +function formTscOptions(cmdOptions: CommandLineOptions, extraOptions?: any): ts.CreateProgramOptions { if (cmdOptions.parsedConfigFile) { let options: ts.CreateProgramOptions = { rootNames: cmdOptions.parsedConfigFile.fileNames, @@ -48,6 +48,10 @@ function formTscOptions(cmdOptions: CommandLineOptions): ts.CreateProgramOptions configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(cmdOptions.parsedConfigFile), }; + if (extraOptions) { + options.options = Object.assign(options.options, extraOptions); + } + return options; } @@ -56,5 +60,9 @@ function formTscOptions(cmdOptions: CommandLineOptions): ts.CreateProgramOptions options: { target: ts.ScriptTarget.Latest, module: ts.ModuleKind.CommonJS, }, }; + if (extraOptions) { + options.options = Object.assign(options.options, extraOptions); + } + return options; } diff --git a/linter/src/LinterRunner.ts b/linter/src/LinterRunner.ts index b6f0111338a9141b432de8afb37401165336e1a7..05191bcfb45963704cfd701971168a92f98212b2 100644 --- a/linter/src/LinterRunner.ts +++ b/linter/src/LinterRunner.ts @@ -29,6 +29,8 @@ import { compile } from './CompilerWrapper'; import { CommandLineOptions } from './CommandLineOptions'; import { LintOptions } from './LintOptions'; import { AutofixInfoSet } from './Autofixer'; +import { TSCCompiledProgram, getStrictOptions } from './ts-diagnostics/TSCCompiledProgram'; +import { mergeArrayMaps } from './Utils'; const logger = Logger.getLogger(); @@ -36,7 +38,8 @@ const logger = Logger.getLogger(); export function lint(options: LintOptions): LintRunResult { const cmdOptions = options.cmdOptions; - const tsProgram = options.tsProgram ?? compile(options, cmdOptions.logTscErrors); + const tscDiagnosticsLinter = createLinter(options); + const tsProgram = tscDiagnosticsLinter.getOriginalProgram(); const linter = new TypeScriptLinter( tsProgram.getTypeChecker(), new AutofixInfoSet(cmdOptions.autofixInfo), @@ -63,28 +66,37 @@ export function lint(options: LintOptions): LintRunResult { if (srcFile) srcFiles.push(srcFile); } - let lintResults = lintFiles(srcFiles, linter); + const { errorNodes, problemsInfos } = lintFiles(srcFiles, linter); + const tscProblemsInfos = getTscDiagnostics(tscDiagnosticsLinter, srcFiles); consoleLog('\n\n\nFiles scanned: ', srcFiles.length); - consoleLog('\nFiles with problems: ', lintResults.errorNodes); + consoleLog('\nFiles with problems: ', errorNodes); - let errorNodes = 0, warningNodes = 0; + let errorNodesTotal = 0, warningNodes = 0; for (let i = 0; i < FaultID.LAST_ID; i++) { // if Strict mode - count all cases if (!linter.strictMode && faultsAttrs[i].migratable) // In relax mode skip migratable continue; if (faultsAttrs[i].warning) warningNodes += linter.nodeCounters[i]; - else errorNodes += linter.nodeCounters[i]; + else errorNodesTotal += linter.nodeCounters[i]; } - logTotalProblemsInfo(errorNodes, warningNodes, linter); + logTotalProblemsInfo(errorNodesTotal, warningNodes, linter); logProblemsPercentageByFeatures(linter); return { - errorNodes: errorNodes, - problemsInfos: lintResults.problemsInfos, + errorNodes: errorNodesTotal, + problemsInfos: mergeArrayMaps(problemsInfos, tscProblemsInfos), }; } +export function createLinter(options: LintOptions): TSCCompiledProgram { + if (options.tscDiagnosticsLinter) { + return options.tscDiagnosticsLinter; + } + const tsProgram = options.tsProgram ?? compile(options, getStrictOptions()); + return new TSCCompiledProgram(tsProgram, options); +} + function lintFiles(srcFiles: ts.SourceFile[], linter: TypeScriptLinter): LintRunResult { let problemFiles = 0; let problemsInfos: Map = new Map(); @@ -121,6 +133,28 @@ function lintFiles(srcFiles: ts.SourceFile[], linter: TypeScriptLinter): LintRun }; } +/** + * Extracts TSC diagnostics emitted by strict checks. + * Function might be time-consuming, as it runs second compilation. + * @param sourceFiles AST of the processed files + * @param tscDiagnosticsLinter linter initialized with the processed program + * @returns problems found by TSC, mapped by `ts.SourceFile.fileName` field + */ +function getTscDiagnostics( + tscDiagnosticsLinter: TSCCompiledProgram, + sourceFiles: ts.SourceFile[], +): Map { + const problemsInfos = new Map(); + sourceFiles.forEach(file => { + const problems = tscDiagnosticsLinter.getStrictDiagnostics(file); + if (problems.length != 0) { + logger.info(`Found ${problems.length} TSC strict diagnostics in ${file.fileName}`); + problemsInfos.set(path.normalize(file.fileName), problems); + } + }); + return problemsInfos; +} + function countProblemFiles( nodeCounters: number[], filesNumber: number, tsSrcFile: ts.SourceFile, fileNodes: number, fileErrorLines: number, fileWarningLines: number, linter: TypeScriptLinter, diff --git a/linter/src/Problems.ts b/linter/src/Problems.ts index f4c3f3bd86099c344d0f80680ad35cf1a76f4afd..efe3cec4ac3086128e3978a179e935f08eafdcbb 100644 --- a/linter/src/Problems.ts +++ b/linter/src/Problems.ts @@ -33,7 +33,7 @@ export enum FaultID { InstanceofUnsupported, ShorthandAmbientModuleDecl, WildcardsInModuleName, UMDModuleDefinition, JSExtensionInModuleIdent, NewTarget, DynamicImport, DefiniteAssignment, IifeAsNamespace, Prototype, GlobalThis, UtilityType, PropertyDeclOnFunction, FunctionApplyBindCall, ReadonlyArr, ConstAssertion, ImportAssertion, - BigIntLiteral, SpreadOperator, LimitedStdLibApi, ErrorSuppression, + BigIntLiteral, SpreadOperator, LimitedStdLibApi, ErrorSuppression, StrictDiagnostic, LAST_ID, // this should always be last enum` } @@ -140,3 +140,4 @@ faultsAttrs[FaultID.ConstAssertion] = {cookBookRef: '142',}; faultsAttrs[FaultID.ImportAssertion] = {cookBookRef: '143',}; faultsAttrs[FaultID.LimitedStdLibApi] = {cookBookRef: '144',}; faultsAttrs[FaultID.ErrorSuppression] = {cookBookRef: '146',}; +faultsAttrs[FaultID.StrictDiagnostic] = {cookBookRef: '0'}; diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 5dcc8e50124ee504266a7dd4a05a1fdd5aaf36be..9b7705fb012d9e6645fee15c7e52e40ffcc1b94c 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -14,7 +14,7 @@ */ import * as ts from 'typescript'; -import { TsUtils } from './Utils'; +import { TsUtils, getNodeOrLineEnd } from './Utils'; import { FaultID, faultsAttrs } from './Problems'; import { cookBookMsg, cookBookTag } from './CookBookMsg'; import { LinterConfig } from './TypeScriptLinterConfig'; @@ -144,7 +144,7 @@ export class TypeScriptLinter { const badNodeInfo: ProblemInfo = { line: line, column: character, - endColumn: this.getNodeOrLineEnd(node, line), + endColumn: getNodeOrLineEnd(this.sourceFile!, startPos, endPos, line), start: startPos, end: endPos, type: faultType, @@ -440,18 +440,6 @@ export class TypeScriptLinter { } } - /** - * @param node AST node belonging to this `sourceFile` - * @param startLine node's start line - * @returns column index of the node's end if node is located on one line, line's end otherwise - */ - private getNodeOrLineEnd(node: ts.Node | ts.CommentRange, startLine: number): number { - const pos = this.sourceFile!.getLineAndCharacterOfPosition(this.tsUtils.getEndPos(node)); - return pos.line === startLine - ? pos.character - : this.sourceFile!.getLineEndOfPosition(this.tsUtils.getStartPos(node)); - } - private handleObjectLiteralExpression(node: ts.Node) { let objectLiteralExpr = node as ts.ObjectLiteralExpression; diff --git a/linter/src/TypeScriptLinterConfig.ts b/linter/src/TypeScriptLinterConfig.ts index c4cdb85389963e414b17a81ef6fae7ceaf9696f8..80bdfb332b7b1f8cf49133baf9bfb9c7524f17a0 100644 --- a/linter/src/TypeScriptLinterConfig.ts +++ b/linter/src/TypeScriptLinterConfig.ts @@ -126,6 +126,7 @@ export class LinterConfig { LinterConfig.nodeDesc[FaultID.SpreadOperator] = 'Spread operation'; LinterConfig.nodeDesc[FaultID.LimitedStdLibApi] = 'Limited standard library API'; LinterConfig.nodeDesc[FaultID.ErrorSuppression] = 'Error suppression annotation'; + LinterConfig.nodeDesc[FaultID.StrictDiagnostic] = 'Strict diagnostic'; LinterConfig.initTsSyntaxKindNames(); } diff --git a/linter/src/Utils.ts b/linter/src/Utils.ts index 67421d305f2ffdf418251dd474b6ef534bd913be..4fda6bf6e1a62fd3e30348d9778ad332ae25f3fe 100644 --- a/linter/src/Utils.ts +++ b/linter/src/Utils.ts @@ -39,6 +39,46 @@ export function decodeAutofixInfo(info: string): AutofixInfo { return { problemID: infos[0], start: Number.parseInt(infos[1]), end: Number.parseInt(infos[2]) }; } +/** + * @param sourceFile AST of the processed file + * @param nodeStartPos node's start position (`node.getStart()`) + * @param nodeEndPos node's end position (`node.getEnd()`) + * @param nodeStartLine node's start line. NB! line count from 1, in contrast to TSC + * @returns column index of the node's end if node is located on one line, line's end otherwise + */ +export function getNodeOrLineEnd( + sourceFile: ts.SourceFile, + nodeStartPos: number, + nodeEndPos: number, + nodeStartLine: number, +): number { + const pos = sourceFile.getLineAndCharacterOfPosition(nodeEndPos); + // TSC counts lines and columns from zero + return (pos.line + 1) === nodeStartLine + ? pos.character + : sourceFile.getLineEndOfPosition(nodeStartPos); +} + +export function mergeArrayMaps(lhs: Map, rhs: Map): Map { + if (lhs.size == 0) { + return rhs; + } + if (rhs.size == 0) { + return lhs; + } + + rhs.forEach((values, key) => { + if (values.length != 0) { + if (lhs.has(key)) { + lhs.get(key)!.push(...values); + } else { + lhs.set(key, values); + } + } + }); + return lhs; +} + export class TsUtils { static statementKinds = [ ts.SyntaxKind.Block,ts.SyntaxKind.EmptyStatement,ts.SyntaxKind.VariableStatement,ts.SyntaxKind.ExpressionStatement, diff --git a/linter/src/ts-diagnostics/TSCCompiledProgram.ts b/linter/src/ts-diagnostics/TSCCompiledProgram.ts new file mode 100644 index 0000000000000000000000000000000000000000..b1e531e6a3391ecbca901841effc19a9fc28b3ca --- /dev/null +++ b/linter/src/ts-diagnostics/TSCCompiledProgram.ts @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as ts from 'typescript'; +import { ProblemInfo } from '../ProblemInfo'; +import { ProblemSeverity } from '../ProblemSeverity'; +import { LintOptions } from '../LintOptions'; +import { TypeScriptDiagnosticsExtractor } from './TypeScriptDiagnosticsExtractor'; +import { compile } from '../CompilerWrapper'; +import { getNodeOrLineEnd } from '../Utils'; +import { FaultID } from '../Problems'; + +export class TSCCompiledProgram { + private diagnosticsExtractor: TypeScriptDiagnosticsExtractor; + private wasStrict: boolean; + + constructor(program: ts.Program, options: LintOptions) { + const { strict, nonStrict, wasStrict } = getTwoCompiledVersions(program, options); + this.diagnosticsExtractor = new TypeScriptDiagnosticsExtractor(strict, nonStrict); + this.wasStrict = wasStrict; + } + + public getOriginalProgram(): ts.Program { + return this.wasStrict + ? this.diagnosticsExtractor.strictProgram + : this.diagnosticsExtractor.nonStrictProgram; + } + + public getStrictDiagnostics(sourceFile: ts.SourceFile): ProblemInfo[] { + return this.diagnosticsExtractor.getStrictDiagnostics(sourceFile) + .map(x => transformDiagnostics(x)); + } +} + +export function getStrictOptions(strict: boolean = true) { + return { + strictNullChecks: strict, + strictFunctionTypes: strict, + strictPropertyInitialization: strict, + noImplicitReturns: strict, + } +} + +function getTwoCompiledVersions( + program: ts.Program, + options: LintOptions, +): { strict: ts.Program; nonStrict: ts.Program; wasStrict: boolean } { + const compilerOptions = { ...program.getCompilerOptions()}; + + const wasStrict = inverseStrictOptions(compilerOptions); + const inversedOptions = getStrictOptions(!wasStrict); + const withInversedOptions = compile(options, inversedOptions); + + return { + strict: wasStrict ? program : withInversedOptions, + nonStrict: wasStrict ? withInversedOptions : program, + wasStrict: wasStrict, + } +} + +/** + * Returns true if options were initially strict + */ +function inverseStrictOptions(compilerOptions: ts.CompilerOptions): boolean { + const strictOptions = getStrictOptions(); + let wasStrict = false; + Object.keys(strictOptions).forEach(x => { + wasStrict = wasStrict || !!compilerOptions[x]; + }); + // wasStrict evaluates true if any of the strict options was set + return wasStrict; +} + +function transformDiagnostics(diagnostic: ts.Diagnostic): ProblemInfo { + const { line, column } = getLineAndColumn(diagnostic); + const startPos = diagnostic.start!; + const endPos = startPos + diagnostic.length!; + // TODO: set correct information & create .md rule description + return { + line: line, + column: column, + endColumn: getNodeOrLineEnd(diagnostic.file!, startPos, endPos, line), + start: startPos, + end: endPos, + type: 'StrictModeError', + severity: ProblemSeverity.ERROR, // expect strict options to always present + problem: FaultID[FaultID.StrictDiagnostic], + suggest: diagnostic.messageText.toString(), + rule: diagnostic.messageText.toString(), + ruleTag: 0, + autofixable: false, + }; +} + +/** + * Returns line and column of the diagnostic's node, counts from 1 + */ +function getLineAndColumn(diagnostic: ts.Diagnostic): { line: number; column: number } { + let { line, character } = diagnostic.file!.getLineAndCharacterOfPosition(diagnostic.start!); + // TSC counts lines and columns from zero + return { + line: line + 1, + column: character + 1, + } +} diff --git a/linter/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts b/linter/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts new file mode 100644 index 0000000000000000000000000000000000000000..b025367244300f7f89758303167225f7530e28bc --- /dev/null +++ b/linter/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as ts from 'typescript'; + +export class TypeScriptDiagnosticsExtractor { + constructor(public strictProgram: ts.Program, public nonStrictProgram: ts.Program) { + } + + /** + * Returns diagnostics which appear in strict compilation mode only + */ + public getStrictDiagnostics(sourceFile: ts.SourceFile): ts.Diagnostic[] { + const strict = getAllDiagnostics(this.strictProgram, sourceFile); + const nonStrict = getAllDiagnostics(this.nonStrictProgram, sourceFile); + + // collect hashes for later easier comparison + const nonStrictHashes = nonStrict.reduce((result, value) => { + const hash = hashDiagnostic(value); + if (hash) { + result.add(hash); + } + return result; + }, new Set()); + // return diagnostics which weren't detected in non-strict mode + return strict.filter(value => { + const hash = hashDiagnostic(value); + return (hash && !nonStrictHashes.has(hash)); + }); + } +} + +function getAllDiagnostics(program: ts.Program, sourceFile: ts.SourceFile): ts.Diagnostic[] { + return program.getSemanticDiagnostics(sourceFile) + .concat(program.getSyntacticDiagnostics(sourceFile)) + .filter(diag => diag.file === sourceFile); +} + +function hashDiagnostic(diagnostic: ts.Diagnostic): string | undefined { + if (diagnostic.start === undefined || diagnostic.length === undefined) { + return undefined; + } + return `${diagnostic.code}%${diagnostic.start}%${diagnostic.length}`; +} diff --git a/linter/test/array_literals.ts.relax.json b/linter/test/array_literals.ts.relax.json index c026bdf47f20313c48c5169ef785e7536e8d60a6..bd8629495f8736b1f36ed50de157cdf0b40da290 100644 --- a/linter/test/array_literals.ts.relax.json +++ b/linter/test/array_literals.ts.relax.json @@ -118,6 +118,21 @@ "line": 126, "column": 30, "problem": "ObjectLiteralNoContextType" + }, + { + "line": 18, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 19, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 20, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/array_literals.ts.strict.json b/linter/test/array_literals.ts.strict.json index 71304420b55194e5d6198c24ffe4d9719c939eff..f2aced3ffb50a88b207d2e34a548c2086a88565e 100644 --- a/linter/test/array_literals.ts.strict.json +++ b/linter/test/array_literals.ts.strict.json @@ -123,6 +123,21 @@ "line": 126, "column": 30, "problem": "ObjectLiteralNoContextType" + }, + { + "line": 18, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 19, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 20, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/delete_operator.ts.relax.json b/linter/test/delete_operator.ts.relax.json index 1af2b8cadafc701c48d76ec63b28e362757fb9f1..2addafd48ca717f4504bee9d7708f24964da3a1e 100644 --- a/linter/test/delete_operator.ts.relax.json +++ b/linter/test/delete_operator.ts.relax.json @@ -73,6 +73,11 @@ "line": 44, "column": 23, "problem": "DeleteOperator" + }, + { + "line": 44, + "column": 30, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/delete_operator.ts.strict.json b/linter/test/delete_operator.ts.strict.json index 1af2b8cadafc701c48d76ec63b28e362757fb9f1..2addafd48ca717f4504bee9d7708f24964da3a1e 100644 --- a/linter/test/delete_operator.ts.strict.json +++ b/linter/test/delete_operator.ts.strict.json @@ -73,6 +73,11 @@ "line": 44, "column": 23, "problem": "DeleteOperator" + }, + { + "line": 44, + "column": 30, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/func_def_params.ts.strict.json b/linter/test/func_def_params.ts.strict.json index 9ef9898408bf9c5ea3e83bb864a24990bad74aa7..88261a03f2098c8ec8e1f742e89350462e21579a 100644 --- a/linter/test/func_def_params.ts.strict.json +++ b/linter/test/func_def_params.ts.strict.json @@ -14,5 +14,10 @@ "limitations under the License." ], "nodes": [ + { + "line": 16, + "column": 1, + "problem": "LimitedReturnTypeInference" + } ] } \ No newline at end of file diff --git a/linter/test/func_inferred_type_args.ts.relax.json b/linter/test/func_inferred_type_args.ts.relax.json index 6138cc504f943977055f24d208a0a07a8672a255..dcc02fc62df7e0b8acc65c242ac3e48d467c82c9 100644 --- a/linter/test/func_inferred_type_args.ts.relax.json +++ b/linter/test/func_inferred_type_args.ts.relax.json @@ -123,6 +123,11 @@ "line": 60, "column": 18, "problem": "TupleType" + }, + { + "line": 61, + "column": 1, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/func_inferred_type_args.ts.strict.json b/linter/test/func_inferred_type_args.ts.strict.json index 6138cc504f943977055f24d208a0a07a8672a255..dcc02fc62df7e0b8acc65c242ac3e48d467c82c9 100644 --- a/linter/test/func_inferred_type_args.ts.strict.json +++ b/linter/test/func_inferred_type_args.ts.strict.json @@ -123,6 +123,11 @@ "line": 60, "column": 18, "problem": "TupleType" + }, + { + "line": 61, + "column": 1, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/functions.ts.autofix.json b/linter/test/functions.ts.autofix.json index 1494a96b12782b37e06e9f07b66b79f5d1acd8f3..9e96283aa935b70c7c6a9ac6b5dc03dbf8fec795 100755 --- a/linter/test/functions.ts.autofix.json +++ b/linter/test/functions.ts.autofix.json @@ -208,6 +208,12 @@ "column": 1, "problem": "FunctionContainsThis", "autofixable": false + }, + { + "line": 107, + "column": 3, + "problem": "StrictDiagnostic", + "autofixable": false } ] } \ No newline at end of file diff --git a/linter/test/functions.ts.relax.json b/linter/test/functions.ts.relax.json index bd460a79893a2a7bdc1d8ca738c6316f122c2497..6e7f7d3992d8cc25679adaa76e811260b51342f6 100644 --- a/linter/test/functions.ts.relax.json +++ b/linter/test/functions.ts.relax.json @@ -28,6 +28,11 @@ "line": 103, "column": 1, "problem": "FunctionContainsThis" + }, + { + "line": 107, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/functions.ts.strict.json b/linter/test/functions.ts.strict.json index 66f8cf949ecb65b91998e6c0a2fc18b4da229a4d..726203465d60fd317a31734afd93b83c23acb338 100644 --- a/linter/test/functions.ts.strict.json +++ b/linter/test/functions.ts.strict.json @@ -123,6 +123,11 @@ "line": 103, "column": 1, "problem": "FunctionContainsThis" + }, + { + "line": 107, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/interfaces_optional_props.ts.relax.json b/linter/test/interfaces_optional_props.ts.relax.json index 18ac144f5d3d23452ecc2c434dc236ece2a7b633..ce85cb8b418cc4c3b9db13654208c20266720729 100644 --- a/linter/test/interfaces_optional_props.ts.relax.json +++ b/linter/test/interfaces_optional_props.ts.relax.json @@ -14,5 +14,10 @@ "limitations under the License." ], "nodes": [ + { + "line": 22, + "column": 34, + "problem": "ObjectLiteralNoContextType" + } ] } \ No newline at end of file diff --git a/linter/test/interfaces_optional_props.ts.strict.json b/linter/test/interfaces_optional_props.ts.strict.json index 18ac144f5d3d23452ecc2c434dc236ece2a7b633..ce85cb8b418cc4c3b9db13654208c20266720729 100644 --- a/linter/test/interfaces_optional_props.ts.strict.json +++ b/linter/test/interfaces_optional_props.ts.strict.json @@ -14,5 +14,10 @@ "limitations under the License." ], "nodes": [ + { + "line": 22, + "column": 34, + "problem": "ObjectLiteralNoContextType" + } ] } \ No newline at end of file diff --git a/linter/test/literals_as_prop_names.ts.autofix.json b/linter/test/literals_as_prop_names.ts.autofix.json index 3527aaf7465b527a65512037333cfc404e713afa..6fa935a2208899e916a699c90cf1eef681d0a801 100644 --- a/linter/test/literals_as_prop_names.ts.autofix.json +++ b/linter/test/literals_as_prop_names.ts.autofix.json @@ -168,6 +168,30 @@ "column": 13, "problem": "ObjectLiteralNoContextType", "autofixable": false + }, + { + "line": 34, + "column": 11, + "problem": "StrictDiagnostic", + "autofixable": false + }, + { + "line": 35, + "column": 3, + "problem": "StrictDiagnostic", + "autofixable": false + }, + { + "line": 55, + "column": 12, + "problem": "StrictDiagnostic", + "autofixable": false + }, + { + "line": 56, + "column": 12, + "problem": "StrictDiagnostic", + "autofixable": false } ] } \ No newline at end of file diff --git a/linter/test/literals_as_prop_names.ts.relax.json b/linter/test/literals_as_prop_names.ts.relax.json index 212bf339f67d7baf457ee2a3ad9c9d9ca64ad794..4093c99242f47749d47f36f5d59a29c50bafe406 100644 --- a/linter/test/literals_as_prop_names.ts.relax.json +++ b/linter/test/literals_as_prop_names.ts.relax.json @@ -23,6 +23,26 @@ "line": 59, "column": 13, "problem": "ObjectLiteralNoContextType" + }, + { + "line": 34, + "column": 11, + "problem": "StrictDiagnostic" + }, + { + "line": 35, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 55, + "column": 12, + "problem": "StrictDiagnostic" + }, + { + "line": 56, + "column": 12, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/literals_as_prop_names.ts.strict.json b/linter/test/literals_as_prop_names.ts.strict.json index f4cd055c3c5de6ee9d1f7d6befa4712990fcd202..da9706e0fd41657f3f5a78aa0febee3fc010174f 100644 --- a/linter/test/literals_as_prop_names.ts.strict.json +++ b/linter/test/literals_as_prop_names.ts.strict.json @@ -78,6 +78,26 @@ "line": 59, "column": 13, "problem": "ObjectLiteralNoContextType" + }, + { + "line": 34, + "column": 11, + "problem": "StrictDiagnostic" + }, + { + "line": 35, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 55, + "column": 12, + "problem": "StrictDiagnostic" + }, + { + "line": 56, + "column": 12, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/modules.ts.autofix.json b/linter/test/modules.ts.autofix.json index fbb25f5c24f414399c1d237bba3b86862335a93b..fa89cb438932be591711ebf7622a8ca13107bff1 100755 --- a/linter/test/modules.ts.autofix.json +++ b/linter/test/modules.ts.autofix.json @@ -248,6 +248,12 @@ "column": 7, "problem": "ImportAssignment", "autofixable": false + }, + { + "line": 103, + "column": 10, + "problem": "StrictDiagnostic", + "autofixable": false } ] } \ No newline at end of file diff --git a/linter/test/modules.ts.relax.json b/linter/test/modules.ts.relax.json index cf6083c3a0a4d0d90ddcaa6535e839348266e204..f5029c0bada347e363d67222f35b83720f38a619 100644 --- a/linter/test/modules.ts.relax.json +++ b/linter/test/modules.ts.relax.json @@ -103,6 +103,11 @@ "line": 114, "column": 7, "problem": "ImportAssignment" + }, + { + "line": 103, + "column": 10, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/modules.ts.strict.json b/linter/test/modules.ts.strict.json index 899f9cd50ed3fc008052efed1356a04de7e21627..d282c25af6464e737ddb2f660e9d0ebbb179128a 100644 --- a/linter/test/modules.ts.strict.json +++ b/linter/test/modules.ts.strict.json @@ -168,6 +168,11 @@ "line": 114, "column": 7, "problem": "ImportAssignment" + }, + { + "line": 103, + "column": 10, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/object_literals.ts.relax.json b/linter/test/object_literals.ts.relax.json index 0ac869033594242bb3b3bedb2a457ff836f33a1b..fc1fdd35c4ab152a289acbfaf0c19567503ddaec 100644 --- a/linter/test/object_literals.ts.relax.json +++ b/linter/test/object_literals.ts.relax.json @@ -253,6 +253,31 @@ "line": 129, "column": 5, "problem": "ObjectLiteralNoContextType" + }, + { + "line": 22, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 23, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 27, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 29, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 30, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/object_literals.ts.strict.json b/linter/test/object_literals.ts.strict.json index c4c6f0b2ffe1dd2aad40e5bd7a44daad5a69823a..d301f909035f0f13d2cd84e01bfe378b3f716879 100644 --- a/linter/test/object_literals.ts.strict.json +++ b/linter/test/object_literals.ts.strict.json @@ -303,6 +303,31 @@ "line": 129, "column": 5, "problem": "ObjectLiteralNoContextType" + }, + { + "line": 22, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 23, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 27, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 29, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 30, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/property_runtime_check.ts.relax.json b/linter/test/property_runtime_check.ts.relax.json index 33c5b9a065161a0868ff8f7a69e8c75082a629c2..97c35791e6c101c041bd79b3987b34d6497c948d 100644 --- a/linter/test/property_runtime_check.ts.relax.json +++ b/linter/test/property_runtime_check.ts.relax.json @@ -183,6 +183,11 @@ "line": 110, "column": 7, "problem": "PropertyRuntimeCheck" + }, + { + "line": 17, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/property_runtime_check.ts.strict.json b/linter/test/property_runtime_check.ts.strict.json index 33c5b9a065161a0868ff8f7a69e8c75082a629c2..97c35791e6c101c041bd79b3987b34d6497c948d 100644 --- a/linter/test/property_runtime_check.ts.strict.json +++ b/linter/test/property_runtime_check.ts.strict.json @@ -183,6 +183,11 @@ "line": 110, "column": 7, "problem": "PropertyRuntimeCheck" + }, + { + "line": 17, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/prototype_assignment.ts.autofix.json b/linter/test/prototype_assignment.ts.autofix.json index 214ac1d3e94d49483d44ccaf2e8886232375478c..235d8662c18eb8aac12d98c0c3836ccc359064c6 100755 --- a/linter/test/prototype_assignment.ts.autofix.json +++ b/linter/test/prototype_assignment.ts.autofix.json @@ -145,6 +145,24 @@ "column": 20, "problem": "Prototype", "autofixable": false + }, + { + "line": 40, + "column": 5, + "problem": "StrictDiagnostic", + "autofixable": false + }, + { + "line": 47, + "column": 3, + "problem": "StrictDiagnostic", + "autofixable": false + }, + { + "line": 48, + "column": 3, + "problem": "StrictDiagnostic", + "autofixable": false } ] } \ No newline at end of file diff --git a/linter/test/prototype_assignment.ts.relax.json b/linter/test/prototype_assignment.ts.relax.json index 44898e57120346a4e21cbe5cf32508d380c972fb..892b5d4df23235a5d0ac69e7aaea56a5c2a6448f 100644 --- a/linter/test/prototype_assignment.ts.relax.json +++ b/linter/test/prototype_assignment.ts.relax.json @@ -93,6 +93,21 @@ "line": 53, "column": 20, "problem": "Prototype" + }, + { + "line": 40, + "column": 5, + "problem": "StrictDiagnostic" + }, + { + "line": 47, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 48, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/prototype_assignment.ts.strict.json b/linter/test/prototype_assignment.ts.strict.json index 3349069b13fab2db25fb417a5dedec78adf6a618..2aaead98e3452d0593b327324a75aa2f8ee9f3e3 100644 --- a/linter/test/prototype_assignment.ts.strict.json +++ b/linter/test/prototype_assignment.ts.strict.json @@ -123,6 +123,21 @@ "line": 53, "column": 20, "problem": "Prototype" + }, + { + "line": 40, + "column": 5, + "problem": "StrictDiagnostic" + }, + { + "line": 47, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 48, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/readonly_arr.ts.autofix.json b/linter/test/readonly_arr.ts.autofix.json index 12dc0b60b0fcdabfa2adfc83047f077f0fac206c..bd3479561a3b4d5d6e5313a3a336648f9aedfd58 100644 --- a/linter/test/readonly_arr.ts.autofix.json +++ b/linter/test/readonly_arr.ts.autofix.json @@ -26,6 +26,18 @@ "replacementText": "string[]" } ] + }, + { + "line": 17, + "column": 12, + "problem": "StrictDiagnostic", + "autofixable": false + }, + { + "line": 18, + "column": 3, + "problem": "StrictDiagnostic", + "autofixable": false } ] } \ No newline at end of file diff --git a/linter/test/readonly_arr.ts.relax.json b/linter/test/readonly_arr.ts.relax.json index b06227021f092f20110cdafb2a6d660605c2ff96..ac1284435817d0f67e436555207d30f3608aa8fd 100644 --- a/linter/test/readonly_arr.ts.relax.json +++ b/linter/test/readonly_arr.ts.relax.json @@ -13,5 +13,16 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "nodes": [] + "nodes": [ + { + "line": 17, + "column": 12, + "problem": "StrictDiagnostic" + }, + { + "line": 18, + "column": 3, + "problem": "StrictDiagnostic" + } + ] } \ No newline at end of file diff --git a/linter/test/readonly_arr.ts.strict.json b/linter/test/readonly_arr.ts.strict.json index 4218e52961c80cefb675d7bf030e38f0e4d4b6b1..5f11751c532ba65de437922eeaf6f259c652dedf 100644 --- a/linter/test/readonly_arr.ts.strict.json +++ b/linter/test/readonly_arr.ts.strict.json @@ -18,6 +18,16 @@ "line": 21, "column": 19, "problem": "ReadonlyArr" + }, + { + "line": 17, + "column": 12, + "problem": "StrictDiagnostic" + }, + { + "line": 18, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/structural_identity.ts.relax.json b/linter/test/structural_identity.ts.relax.json index 903c94d19240558131aec30a4d84fb95b46834c9..30c667dac07c751626327d98eb12afa073b55c9a 100755 --- a/linter/test/structural_identity.ts.relax.json +++ b/linter/test/structural_identity.ts.relax.json @@ -43,6 +43,11 @@ "line": 37, "column": 13, "problem": "StructuralIdentity" + }, + { + "line": 37, + "column": 5, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/structural_identity.ts.strict.json b/linter/test/structural_identity.ts.strict.json index 903c94d19240558131aec30a4d84fb95b46834c9..30c667dac07c751626327d98eb12afa073b55c9a 100755 --- a/linter/test/structural_identity.ts.strict.json +++ b/linter/test/structural_identity.ts.strict.json @@ -43,6 +43,11 @@ "line": 37, "column": 13, "problem": "StructuralIdentity" + }, + { + "line": 37, + "column": 5, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/ts_ignore.ts.relax.json b/linter/test/ts_ignore.ts.relax.json index 76b4c6138f79897e52166c1074f9184e02b5c347..a8d64b5a531442167f4a21d4c401708fd9ce3fd1 100644 --- a/linter/test/ts_ignore.ts.relax.json +++ b/linter/test/ts_ignore.ts.relax.json @@ -28,6 +28,11 @@ "line": 25, "column": 19, "problem": "ErrorSuppression" + }, + { + "line": 18, + "column": 5, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/ts_ignore.ts.strict.json b/linter/test/ts_ignore.ts.strict.json index 76b4c6138f79897e52166c1074f9184e02b5c347..a8d64b5a531442167f4a21d4c401708fd9ce3fd1 100644 --- a/linter/test/ts_ignore.ts.strict.json +++ b/linter/test/ts_ignore.ts.strict.json @@ -28,6 +28,11 @@ "line": 25, "column": 19, "problem": "ErrorSuppression" + }, + { + "line": 18, + "column": 5, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/type_declarations.ts.relax.json b/linter/test/type_declarations.ts.relax.json index 9bb0205d92c2de81cb2f23e6dea81f704ddbb2ba..ef4475e80dc3f327f6d04f81b9c498b5161bbee0 100644 --- a/linter/test/type_declarations.ts.relax.json +++ b/linter/test/type_declarations.ts.relax.json @@ -63,6 +63,11 @@ "line": 96, "column": 13, "problem": "AnyType" + }, + { + "line": 42, + "column": 11, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/type_declarations.ts.strict.json b/linter/test/type_declarations.ts.strict.json index bf5339e00c84823c499e4a8b9c4ba8782a9033cc..27aaac08802fa51717ede4912e5d37807cb924ab 100644 --- a/linter/test/type_declarations.ts.strict.json +++ b/linter/test/type_declarations.ts.strict.json @@ -73,6 +73,11 @@ "line": 96, "column": 13, "problem": "AnyType" + }, + { + "line": 42, + "column": 11, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/types.ts.autofix.json b/linter/test/types.ts.autofix.json index 54f54a35a9db47948a262a2d229df283ac6994ba..ef7f93ac4a4bbd1a631b0553221c055ca418adc8 100644 --- a/linter/test/types.ts.autofix.json +++ b/linter/test/types.ts.autofix.json @@ -340,6 +340,30 @@ "replacementText": "x: T" } ] + }, + { + "line": 106, + "column": 3, + "problem": "StrictDiagnostic", + "autofixable": false + }, + { + "line": 148, + "column": 3, + "problem": "StrictDiagnostic", + "autofixable": false + }, + { + "line": 149, + "column": 18, + "problem": "StrictDiagnostic", + "autofixable": false + }, + { + "line": 150, + "column": 17, + "problem": "StrictDiagnostic", + "autofixable": false } ] } \ No newline at end of file diff --git a/linter/test/types.ts.relax.json b/linter/test/types.ts.relax.json index 2a6cbf9a643d0330d6cf70cb9066ccaf9d10e220..77ee7275e2192f417fbf1d7ccfe972c2f57c1779 100644 --- a/linter/test/types.ts.relax.json +++ b/linter/test/types.ts.relax.json @@ -178,6 +178,26 @@ "line": 128, "column": 18, "problem": "ObjectLiteralNoContextType" + }, + { + "line": 106, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 148, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 149, + "column": 18, + "problem": "StrictDiagnostic" + }, + { + "line": 150, + "column": 17, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/types.ts.strict.json b/linter/test/types.ts.strict.json index 47a59aca914387d738f18ff2ad913bc20f732720..dba26d03211df25e1e1413989d19d077b3e4282d 100644 --- a/linter/test/types.ts.strict.json +++ b/linter/test/types.ts.strict.json @@ -233,6 +233,26 @@ "line": 139, "column": 22, "problem": "ArrowFunctionWithOmittedTypes" + }, + { + "line": 106, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 148, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 149, + "column": 18, + "problem": "StrictDiagnostic" + }, + { + "line": 150, + "column": 17, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/unique_names.ts.relax.json b/linter/test/unique_names.ts.relax.json index 854cc77a7c71d4a30d63a5ef631c85c5878c0c1d..d468701cf8a9596b3af88efa69443b1e4d347e5d 100644 --- a/linter/test/unique_names.ts.relax.json +++ b/linter/test/unique_names.ts.relax.json @@ -53,6 +53,21 @@ "line": 134, "column": 19, "problem": "ObjectLiteralNoContextType" + }, + { + "line": 163, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 164, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 173, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/unique_names.ts.strict.json b/linter/test/unique_names.ts.strict.json index e868237f3e5f358a4edff2817bc151f61a549431..3b6a44084fe51100d37485b99a21dbfb52342ada 100644 --- a/linter/test/unique_names.ts.strict.json +++ b/linter/test/unique_names.ts.strict.json @@ -353,6 +353,21 @@ "line": 174, "column": 3, "problem": "PrivateIdentifier" + }, + { + "line": 163, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 164, + "column": 3, + "problem": "StrictDiagnostic" + }, + { + "line": 173, + "column": 3, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/utility_types.ts.relax.json b/linter/test/utility_types.ts.relax.json index ab7e78c41521bbf11509a21c189d282e843addb4..a68bcd54d4d0393057fc79d3a0a65f21ded73b62 100644 --- a/linter/test/utility_types.ts.relax.json +++ b/linter/test/utility_types.ts.relax.json @@ -59,6 +59,11 @@ "column": 35, "problem": "ObjectLiteralNoContextType" }, + { + "line": 50, + "column": 22, + "problem": "ObjectLiteralNoContextType" + }, { "line": 51, "column": 15, diff --git a/linter/test/utility_types.ts.strict.json b/linter/test/utility_types.ts.strict.json index 1e90114550a9c46d24dc3948f012bdd386496d7e..06d9ddc094dd8be62b0af7ad784fa226ee4eaa94 100644 --- a/linter/test/utility_types.ts.strict.json +++ b/linter/test/utility_types.ts.strict.json @@ -64,6 +64,11 @@ "column": 35, "problem": "ObjectLiteralNoContextType" }, + { + "line": 50, + "column": 22, + "problem": "ObjectLiteralNoContextType" + }, { "line": 51, "column": 15, diff --git a/linter/test/var_declarations.ts.relax.json b/linter/test/var_declarations.ts.relax.json index fa5ed280bcffcff748cfaa2e4491f6ed2bb782f2..87eabb4e19f3a605cb7e12b9986268f2e46788ca 100644 --- a/linter/test/var_declarations.ts.relax.json +++ b/linter/test/var_declarations.ts.relax.json @@ -18,6 +18,11 @@ "line": 31, "column": 3, "problem": "ForInStatement" + }, + { + "line": 23, + "column": 12, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file diff --git a/linter/test/var_declarations.ts.strict.json b/linter/test/var_declarations.ts.strict.json index 4cabc048c4d2102bb5e498305a0cf4569f82bc00..fd22371de602464d0a25cbff6ba39c87dee87df3 100644 --- a/linter/test/var_declarations.ts.strict.json +++ b/linter/test/var_declarations.ts.strict.json @@ -53,6 +53,11 @@ "line": 37, "column": 8, "problem": "VarDeclaration" + }, + { + "line": 23, + "column": 12, + "problem": "StrictDiagnostic" } ] } \ No newline at end of file