|
| 1 | +/*! |
| 2 | + * Copyright 2026 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import { defineConfig } from 'eslint/config'; |
| 18 | +import eslint from '@eslint/js'; |
| 19 | +import tseslint from 'typescript-eslint'; |
| 20 | +import globals from 'globals'; |
| 21 | + |
| 22 | +export default defineConfig([ |
| 23 | + eslint.configs.recommended, |
| 24 | + ...tseslint.configs.recommended, |
| 25 | + { |
| 26 | + files: ['src/**/*.ts', 'test/**/*.ts'], |
| 27 | + languageOptions: { |
| 28 | + globals: { |
| 29 | + ...globals.node, |
| 30 | + }, |
| 31 | + }, |
| 32 | + rules: { |
| 33 | + // Following checks are temporarily disabled. We shall incrementally enable them in the |
| 34 | + // future, fixing any violations as we go. |
| 35 | + '@typescript-eslint/no-non-null-assertion': 0, |
| 36 | + |
| 37 | + // Disabled checks |
| 38 | + '@typescript-eslint/no-explicit-any': 0, |
| 39 | + '@typescript-eslint/no-use-before-define': 0, |
| 40 | + '@typescript-eslint/no-var-requires': 0, |
| 41 | + '@typescript-eslint/no-require-imports': 0, |
| 42 | + '@typescript-eslint/no-unused-expressions': 0, |
| 43 | + |
| 44 | + // Required checks |
| 45 | + 'indent': ['error', 2], |
| 46 | + 'keyword-spacing': ['error'], |
| 47 | + 'max-len': [ |
| 48 | + 'error', |
| 49 | + { |
| 50 | + 'code': 120, |
| 51 | + 'ignoreUrls': true |
| 52 | + } |
| 53 | + ], |
| 54 | + 'object-curly-spacing': [2, 'always'], |
| 55 | + '@typescript-eslint/explicit-function-return-type': [ |
| 56 | + 'error', |
| 57 | + { |
| 58 | + 'allowExpressions': true, |
| 59 | + 'allowTypedFunctionExpressions': true, |
| 60 | + 'allowHigherOrderFunctions': true |
| 61 | + } |
| 62 | + ], |
| 63 | + 'no-unused-vars': 'off', // Must be disabled to enable the next rule |
| 64 | + '@typescript-eslint/no-unused-vars': [ |
| 65 | + 'error', |
| 66 | + { |
| 67 | + 'varsIgnorePattern': '^_', |
| 68 | + 'argsIgnorePattern': '^_', |
| 69 | + 'caughtErrors': 'none' |
| 70 | + } |
| 71 | + ], |
| 72 | + 'quotes': ['error', 'single', {'avoidEscape': true}], |
| 73 | + '@typescript-eslint/naming-convention': [ |
| 74 | + 'error', |
| 75 | + { |
| 76 | + "selector": "variable", |
| 77 | + "format": ["camelCase", "UPPER_CASE"] |
| 78 | + }, |
| 79 | + { |
| 80 | + "selector": "variable", |
| 81 | + "modifiers": ["const"], |
| 82 | + "format": ["PascalCase", "camelCase", "UPPER_CASE"], |
| 83 | + "filter": { |
| 84 | + "regex": "ErrorCode$", // Matches only if it ends exactly with ErrorCode |
| 85 | + "match": true, |
| 86 | + }, |
| 87 | + }, |
| 88 | + { |
| 89 | + "selector": "parameter", |
| 90 | + "format": ["camelCase"], |
| 91 | + "leadingUnderscore": "allow" |
| 92 | + }, |
| 93 | + |
| 94 | + { |
| 95 | + "selector": "memberLike", |
| 96 | + "format": ["camelCase"] |
| 97 | + }, |
| 98 | + |
| 99 | + { |
| 100 | + "selector": "typeLike", |
| 101 | + "format": ["PascalCase"] |
| 102 | + }, |
| 103 | + |
| 104 | + // Ignore properties that require quotes (HTTP headers, names that include spaces or dashes etc.). |
| 105 | + { |
| 106 | + "selector": [ |
| 107 | + "classProperty", |
| 108 | + "objectLiteralProperty", |
| 109 | + "typeProperty", |
| 110 | + "classMethod", |
| 111 | + "objectLiteralMethod", |
| 112 | + "typeMethod", |
| 113 | + "accessor", |
| 114 | + "enumMember" |
| 115 | + ], |
| 116 | + "format": null, |
| 117 | + "modifiers": ["requiresQuotes"] |
| 118 | + }, |
| 119 | + |
| 120 | + // Ignore destructured property names. |
| 121 | + { |
| 122 | + "selector": "variable", |
| 123 | + "modifiers": ["destructured"], |
| 124 | + "format": null |
| 125 | + }, |
| 126 | + |
| 127 | + // Following types are temporarily disabled. We shall incrementally enable them in the |
| 128 | + // future, fixing any violations as we go. |
| 129 | + { |
| 130 | + "selector": [ |
| 131 | + "classProperty", |
| 132 | + "objectLiteralProperty", |
| 133 | + "typeProperty", |
| 134 | + "enumMember" |
| 135 | + ], |
| 136 | + "format": null |
| 137 | + } |
| 138 | + ], |
| 139 | + } |
| 140 | + }, |
| 141 | + { |
| 142 | + files: ['test/**/*.ts'], |
| 143 | + languageOptions: { |
| 144 | + globals: { |
| 145 | + ...globals.mocha, |
| 146 | + }, |
| 147 | + }, |
| 148 | + }, |
| 149 | + { |
| 150 | + ignores: [ |
| 151 | + 'lib/', |
| 152 | + 'node_modules/', |
| 153 | + 'temp/', |
| 154 | + 'docgen/', |
| 155 | + 'dist/', |
| 156 | + 'coverage/', |
| 157 | + '**/*.d.ts', |
| 158 | + '**/*.js', |
| 159 | + 'firebase-admin-*.tgz' |
| 160 | + ] |
| 161 | + } |
| 162 | +]); |
0 commit comments