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 */ 15 16{ 17 "files": [ // 用于表示配置适用的文件范围的 glob 模式数组。在没有指定的情况下,应用默认配置 18 "**/*.js", 19 "**/*.ts", 20 "**/*.ets", 21 "**/*.js" 22 ], 23 "ignore": [ // 一个表示配置对象不应适用的文件的 glob 模式数组。如果没有指定,配置对象将适用于所有由 files 匹配的文件 24 "**/.preview/**/*", 25 "**/build/**/*", 26 "**/oh_modules/**/*", 27 "**/ohosTest/**/*", 28 "**/node_modules/**/*", 29 "**/hvigorfile.ts" 30 ], 31 "plugins": [ 32 "@typescript-eslint" 33 ], 34 "ruleSet": [], 35 "rules": { 36 // 以下为codelinter工具默认配置 37 "@typescript-eslint/await-thenable": "warn", 38 "@typescript-eslint/explicit-function-return-type": "warn", // 函数返回值类型约束 39 "@typescript-eslint/explicit-module-boundary-types": "warn", // 函数返回值类型约束 40 "@typescript-eslint/no-dynamic-delete": "warn", 41 "@typescript-eslint/no-explicit-any": "warn", 42 "@typescript-eslint/no-for-in-array": "warn", 43 "@typescript-eslint/no-this-alias": "warn", 44 "@typescript-eslint/no-unnecessary-type-constraint": "warn", 45 "@typescript-eslint/no-unsafe-argument": "warn", 46 "@typescript-eslint/no-unsafe-assignment": "warn", 47 "@typescript-eslint/no-unsafe-call": "warn", 48 "@typescript-eslint/no-unsafe-member-access": "warn", 49 "@typescript-eslint/no-unsafe-return": "warn", 50 "@typescript-eslint/prefer-literal-enum-member": "warn", 51 // 以下为自定义配置,off表示忽略该条规则 52 "@typescript-eslint/consistent-type-imports": "off", // 忽略自动导入规则 53 "@typescript-eslint/quotes": [ // 使用字符串单引号检测 54 "warn", 55 "single" 56 ], 57 "@typescript-eslint/no-empty-function": "warn", // 空函数体警告 58 "@typescript-eslint/dot-notation": "warn" // 强制使用点符号访问对象属性,禁止使用[]方式访问属性 59 }, 60 "overrides": [] 61}