• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15namespace ts {
16export namespace ArkTSLinter_1_1 {
17export namespace Problems {
18
19import ProblemSeverity = Common.ProblemSeverity;
20
21export enum FaultID {
22  AnyType, SymbolType, ObjectLiteralNoContextType, ArrayLiteralNoContextType,
23  ComputedPropertyName, LiteralAsPropertyName, TypeQuery, IsOperator,
24  DestructuringParameter, YieldExpression, InterfaceMerging, EnumMerging, InterfaceExtendsClass, IndexMember, WithStatement,
25  ThrowStatement, IndexedAccessType, UnknownType, ForInStatement, InOperator,
26  FunctionExpression, IntersectionType,
27  ObjectTypeLiteral, CommaOperator, LimitedReturnTypeInference,
28  LambdaWithTypeParameters, ClassExpression, DestructuringAssignment,
29  DestructuringDeclaration, VarDeclaration, CatchWithUnsupportedType, DeleteOperator,
30  DeclWithDuplicateName, UnaryArithmNotNumber, ConstructorType, ConstructorIface, ConstructorFuncs, CallSignature,
31  TypeAssertion, PrivateIdentifier, LocalFunction,
32  ConditionalType, MappedType, NamespaceAsObject, ClassAsObject,
33  NonDeclarationInNamespace, GeneratorFunction, FunctionContainsThis, PropertyAccessByIndex, JsxElement,
34  EnumMemberNonConstInit, ImplementsClass, MethodReassignment, MultipleStaticBlocks, ThisType,
35  IntefaceExtendDifProps, StructuralIdentity, DefaultImport,
36  ExportAssignment, ImportAssignment,
37  GenericCallNoTypeArgs, ParameterProperties,
38  InstanceofUnsupported, ShorthandAmbientModuleDecl, WildcardsInModuleName, UMDModuleDefinition,
39  NewTarget, DefiniteAssignment, Prototype, GlobalThis,
40  UtilityType, PropertyDeclOnFunction, FunctionApplyCall, FunctionBind, ConstAssertion, ImportAssertion,
41  SpreadOperator, LimitedStdLibApi, ErrorSuppression, StrictDiagnostic, ImportAfterStatement,
42  EsObjectType,
43  LAST_ID, // this should always be last enum`
44}
45
46export class FaultAttributes {
47  constructor(
48    public cookBookRef: number,
49    public migratable: boolean = false,
50    public severity: ProblemSeverity = ProblemSeverity.ERROR
51  ) {}
52}
53
54export const faultsAttrs: FaultAttributes[] = [];
55
56faultsAttrs[FaultID.LiteralAsPropertyName] = new FaultAttributes(1, true);
57faultsAttrs[FaultID.ComputedPropertyName] = new FaultAttributes(1);
58faultsAttrs[FaultID.SymbolType] = new FaultAttributes(2);
59faultsAttrs[FaultID.PrivateIdentifier] = new FaultAttributes(3, true);
60faultsAttrs[FaultID.DeclWithDuplicateName] = new FaultAttributes(4, true);
61faultsAttrs[FaultID.VarDeclaration] = new FaultAttributes(5, true);
62faultsAttrs[FaultID.AnyType] = new FaultAttributes(8);
63faultsAttrs[FaultID.UnknownType] = new FaultAttributes(8);
64faultsAttrs[FaultID.CallSignature] = new FaultAttributes(14);
65faultsAttrs[FaultID.ConstructorType] = new FaultAttributes(15);
66faultsAttrs[FaultID.MultipleStaticBlocks] = new FaultAttributes(16);
67faultsAttrs[FaultID.IndexMember] = new FaultAttributes(17);
68faultsAttrs[FaultID.IntersectionType] = new FaultAttributes(19);
69faultsAttrs[FaultID.ThisType] = new FaultAttributes(21);
70faultsAttrs[FaultID.ConditionalType] = new FaultAttributes(22);
71faultsAttrs[FaultID.ParameterProperties] = new FaultAttributes(25, true);
72faultsAttrs[FaultID.ConstructorIface] = new FaultAttributes(27);
73faultsAttrs[FaultID.IndexedAccessType] = new FaultAttributes(28);
74faultsAttrs[FaultID.PropertyAccessByIndex] = new FaultAttributes(29, true);
75faultsAttrs[FaultID.StructuralIdentity] = new FaultAttributes(30);
76faultsAttrs[FaultID.GenericCallNoTypeArgs] = new FaultAttributes(34);
77faultsAttrs[FaultID.ObjectLiteralNoContextType] = new FaultAttributes(38);
78faultsAttrs[FaultID.ObjectTypeLiteral] = new FaultAttributes(40);
79faultsAttrs[FaultID.ArrayLiteralNoContextType] = new FaultAttributes(43);
80faultsAttrs[FaultID.FunctionExpression] = new FaultAttributes(46, true);
81faultsAttrs[FaultID.LambdaWithTypeParameters] = new FaultAttributes(49, true);
82faultsAttrs[FaultID.ClassExpression] = new FaultAttributes(50, true);
83faultsAttrs[FaultID.ImplementsClass] = new FaultAttributes(51);
84faultsAttrs[FaultID.MethodReassignment] = new FaultAttributes(52);
85faultsAttrs[FaultID.TypeAssertion] = new FaultAttributes(53, true);
86faultsAttrs[FaultID.JsxElement] = new FaultAttributes(54);
87faultsAttrs[FaultID.UnaryArithmNotNumber] = new FaultAttributes(55);
88faultsAttrs[FaultID.DeleteOperator] = new FaultAttributes(59);
89faultsAttrs[FaultID.TypeQuery] = new FaultAttributes(60);
90faultsAttrs[FaultID.InstanceofUnsupported] = new FaultAttributes(65);
91faultsAttrs[FaultID.InOperator] = new FaultAttributes(66);
92faultsAttrs[FaultID.DestructuringAssignment] = new FaultAttributes(69, true);
93faultsAttrs[FaultID.CommaOperator] = new FaultAttributes(71);
94faultsAttrs[FaultID.DestructuringDeclaration] = new FaultAttributes(74, true);
95faultsAttrs[FaultID.CatchWithUnsupportedType] = new FaultAttributes(79, true);
96faultsAttrs[FaultID.ForInStatement] = new FaultAttributes(80);
97faultsAttrs[FaultID.MappedType] = new FaultAttributes(83);
98faultsAttrs[FaultID.WithStatement] = new FaultAttributes(84);
99faultsAttrs[FaultID.ThrowStatement] = new FaultAttributes(87, true);
100faultsAttrs[FaultID.LimitedReturnTypeInference] = new FaultAttributes(90, true);
101faultsAttrs[FaultID.DestructuringParameter] = new FaultAttributes(91);
102faultsAttrs[FaultID.LocalFunction] = new FaultAttributes(92, true);
103faultsAttrs[FaultID.FunctionContainsThis] = new FaultAttributes(93);
104faultsAttrs[FaultID.GeneratorFunction] = new FaultAttributes(94);
105faultsAttrs[FaultID.YieldExpression] = new FaultAttributes(94);
106faultsAttrs[FaultID.IsOperator] = new FaultAttributes(96);
107faultsAttrs[FaultID.SpreadOperator] = new FaultAttributes(99);
108faultsAttrs[FaultID.IntefaceExtendDifProps] = new FaultAttributes(102);
109faultsAttrs[FaultID.InterfaceMerging] = new FaultAttributes(103);
110faultsAttrs[FaultID.InterfaceExtendsClass] = new FaultAttributes(104);
111faultsAttrs[FaultID.ConstructorFuncs] = new FaultAttributes(106);
112faultsAttrs[FaultID.EnumMemberNonConstInit] = new FaultAttributes(111);
113faultsAttrs[FaultID.EnumMerging] = new FaultAttributes(113);
114faultsAttrs[FaultID.NamespaceAsObject] = new FaultAttributes(114);
115faultsAttrs[FaultID.NonDeclarationInNamespace] = new FaultAttributes(116);
116faultsAttrs[FaultID.DefaultImport] = new FaultAttributes(120, true);
117faultsAttrs[FaultID.ImportAssignment] = new FaultAttributes(121);
118faultsAttrs[FaultID.ExportAssignment] = new FaultAttributes(126);
119faultsAttrs[FaultID.ShorthandAmbientModuleDecl] = new FaultAttributes(128);
120faultsAttrs[FaultID.WildcardsInModuleName] = new FaultAttributes(129);
121faultsAttrs[FaultID.UMDModuleDefinition] = new FaultAttributes(130);
122faultsAttrs[FaultID.NewTarget] = new FaultAttributes(132);
123faultsAttrs[FaultID.DefiniteAssignment] = new FaultAttributes(134, false, ProblemSeverity.WARNING);
124faultsAttrs[FaultID.Prototype] = new FaultAttributes(136);
125faultsAttrs[FaultID.GlobalThis] = new FaultAttributes(137, false, ProblemSeverity.WARNING);
126faultsAttrs[FaultID.UtilityType] = new FaultAttributes(138);
127faultsAttrs[FaultID.PropertyDeclOnFunction] = new FaultAttributes(139);
128faultsAttrs[FaultID.FunctionBind] = new FaultAttributes(140, false, ProblemSeverity.WARNING);
129faultsAttrs[FaultID.ConstAssertion] = new FaultAttributes(142);
130faultsAttrs[FaultID.ImportAssertion] = new FaultAttributes(143);
131faultsAttrs[FaultID.LimitedStdLibApi] = new FaultAttributes(144);
132faultsAttrs[FaultID.StrictDiagnostic] = new FaultAttributes(145);
133faultsAttrs[FaultID.ErrorSuppression] = new FaultAttributes(146);
134faultsAttrs[FaultID.ClassAsObject] = new FaultAttributes(149, false, ProblemSeverity.WARNING);
135faultsAttrs[FaultID.ImportAfterStatement] = new FaultAttributes(150);
136faultsAttrs[FaultID.EsObjectType] = new FaultAttributes(151, false, ProblemSeverity.WARNING);
137faultsAttrs[FaultID.FunctionApplyCall] = new FaultAttributes(152);
138}
139}
140}