|
| 1 | +/* |
| 2 | + * Copyright (c) 2025, Salesforce, Inc. |
| 3 | + * SPDX-License-Identifier: Apache-2 |
| 4 | + * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +/** |
| 8 | + * Shared ESLint configuration for the b2c-cli monorepo. |
| 9 | + * Packages import from this file to maintain consistency. |
| 10 | + */ |
| 11 | + |
| 12 | +import prettierPlugin from 'eslint-plugin-prettier/recommended'; |
| 13 | + |
| 14 | +/** |
| 15 | + * The standard copyright header block used across all packages. |
| 16 | + */ |
| 17 | +export const copyrightHeader = [ |
| 18 | + '', |
| 19 | + ' * Copyright (c) 2025, Salesforce, Inc.', |
| 20 | + ' * SPDX-License-Identifier: Apache-2', |
| 21 | + ' * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0', |
| 22 | + ' ', |
| 23 | +]; |
| 24 | + |
| 25 | +/** |
| 26 | + * Shared rules used across all packages. |
| 27 | + */ |
| 28 | +export const sharedRules = { |
| 29 | + // Allow underscore-prefixed unused variables (common convention for intentionally unused params) |
| 30 | + '@typescript-eslint/no-unused-vars': [ |
| 31 | + 'error', |
| 32 | + { |
| 33 | + argsIgnorePattern: '^_', |
| 34 | + varsIgnorePattern: '^_', |
| 35 | + }, |
| 36 | + ], |
| 37 | + // Disable new-cap - incompatible with openapi-fetch (uses GET, POST, etc. methods) |
| 38 | + 'new-cap': 'off', |
| 39 | +}; |
| 40 | + |
| 41 | +/** |
| 42 | + * Rules for packages using eslint-config-oclif. |
| 43 | + * Disables perfectionist and stylistic rules that conflict with our style. |
| 44 | + */ |
| 45 | +export const oclifRules = { |
| 46 | + // Disable perfectionist rules - we use prettier for formatting |
| 47 | + 'perfectionist/sort-imports': 'off', |
| 48 | + 'perfectionist/sort-objects': 'off', |
| 49 | + 'perfectionist/sort-object-types': 'off', |
| 50 | + 'perfectionist/sort-interfaces': 'off', |
| 51 | + 'perfectionist/sort-named-exports': 'off', |
| 52 | + 'perfectionist/sort-named-imports': 'off', |
| 53 | + // Disable stylistic rules that conflict with our style |
| 54 | + '@stylistic/lines-between-class-members': 'off', |
| 55 | + '@stylistic/padding-line-between-statements': 'off', |
| 56 | + // Allow TODO comments |
| 57 | + 'no-warning-comments': 'off', |
| 58 | + // Don't require destructuring |
| 59 | + 'prefer-destructuring': 'off', |
| 60 | +}; |
| 61 | + |
| 62 | +/** |
| 63 | + * Rules for test files using Chai assertions. |
| 64 | + */ |
| 65 | +export const chaiTestRules = { |
| 66 | + // Allow Chai property-based assertions in test files (e.g., expect(x).to.be.true) |
| 67 | + '@typescript-eslint/no-unused-expressions': 'off', |
| 68 | +}; |
| 69 | + |
| 70 | +/** |
| 71 | + * Re-export prettier plugin for convenience. |
| 72 | + */ |
| 73 | +export {prettierPlugin}; |
0 commit comments