|
| 1 | +const { builtinModules } = require('module'); |
| 2 | + |
| 3 | +const ALLOWED_NODE_BUILTINS = new Set(['assert']); |
| 4 | + |
| 5 | +module.exports = { |
| 6 | + root: true, |
| 7 | + parser: '@typescript-eslint/parser', |
| 8 | + parserOptions: { |
| 9 | + project: './tsconfig.json', |
| 10 | + tsconfigRootDir: __dirname, |
| 11 | + }, |
| 12 | + plugins: ['@typescript-eslint', 'deprecation'], |
| 13 | + extends: [ |
| 14 | + 'eslint:recommended', |
| 15 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 16 | + 'plugin:@typescript-eslint/recommended', |
| 17 | + 'prettier', |
| 18 | + ], |
| 19 | + rules: { |
| 20 | + // recommended for safety |
| 21 | + '@typescript-eslint/no-floating-promises': 'error', // forgetting to await Activities and Workflow APIs is bad |
| 22 | + 'deprecation/deprecation': 'warn', |
| 23 | + |
| 24 | + // code style preference |
| 25 | + 'object-shorthand': ['error', 'always'], |
| 26 | + |
| 27 | + // relaxed rules, for convenience |
| 28 | + '@typescript-eslint/no-unused-vars': [ |
| 29 | + 'warn', |
| 30 | + { |
| 31 | + argsIgnorePattern: '^_', |
| 32 | + varsIgnorePattern: '^_', |
| 33 | + }, |
| 34 | + ], |
| 35 | + '@typescript-eslint/no-explicit-any': 'off', |
| 36 | + }, |
| 37 | + overrides: [ |
| 38 | + { |
| 39 | + files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'], |
| 40 | + rules: { |
| 41 | + 'no-restricted-imports': [ |
| 42 | + 'error', |
| 43 | + ...builtinModules.filter((m) => !ALLOWED_NODE_BUILTINS.has(m)).flatMap((m) => [m, `node:${m}`]), |
| 44 | + ], |
| 45 | + }, |
| 46 | + }, |
| 47 | + ], |
| 48 | +}; |
0 commit comments