|
| 1 | +/* Copyright © 2025 Apeleg Limited. All rights reserved. |
| 2 | + * |
| 3 | + * Permission to use, copy, modify, and distribute this software for any |
| 4 | + * purpose with or without fee is hereby granted, provided that the above |
| 5 | + * copyright notice and this permission notice appear in all copies. |
| 6 | + * |
| 7 | + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
| 8 | + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 9 | + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
| 10 | + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 11 | + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
| 12 | + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 13 | + * PERFORMANCE OF THIS SOFTWARE. |
| 14 | + */ |
| 15 | + |
| 16 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 17 | +import js from '@eslint/js'; |
| 18 | +import plugin from '@typescript-eslint/eslint-plugin'; |
| 19 | +import parser from '@typescript-eslint/parser'; |
| 20 | +import prettierRecommended from 'eslint-plugin-prettier/recommended'; |
| 21 | +import globals from 'globals'; |
| 22 | +import path from 'node:path'; |
| 23 | +import { fileURLToPath } from 'node:url'; |
| 24 | +import importMap from './import_map.json' with { type: 'json' }; |
| 25 | + |
| 26 | +// mimic CommonJS variables -- not needed if using CommonJS |
| 27 | +const __filename = fileURLToPath(import.meta.url); |
| 28 | +const __dirname = path.dirname(__filename); |
| 29 | + |
| 30 | +const compat = new FlatCompat({ |
| 31 | + baseDirectory: __dirname, |
| 32 | +}); |
| 33 | + |
| 34 | +export default [ |
| 35 | + { |
| 36 | + ignores: [ |
| 37 | + '**/node_modules/*', |
| 38 | + '**/.nyc_output/*', |
| 39 | + '**/dist/*', |
| 40 | + '**/build/*', |
| 41 | + '**/coverage/*', |
| 42 | + '**/package-lock.json', |
| 43 | + ], |
| 44 | + }, |
| 45 | + js.configs.recommended, |
| 46 | + ...compat.extends('plugin:@typescript-eslint/recommended'), |
| 47 | + prettierRecommended, |
| 48 | + { |
| 49 | + languageOptions: { |
| 50 | + parser, |
| 51 | + globals: { |
| 52 | + ...globals.node, |
| 53 | + }, |
| 54 | + }, |
| 55 | + plugins: { plugin }, |
| 56 | + rules: { |
| 57 | + '@typescript-eslint/naming-convention': [ |
| 58 | + 'error', |
| 59 | + { |
| 60 | + selector: 'typeParameter', |
| 61 | + format: ['PascalCase'], |
| 62 | + prefix: ['T'], |
| 63 | + }, |
| 64 | + { |
| 65 | + selector: 'interface', |
| 66 | + format: ['PascalCase'], |
| 67 | + prefix: ['I'], |
| 68 | + }, |
| 69 | + { |
| 70 | + selector: 'enumMember', |
| 71 | + format: ['UPPER_CASE'], |
| 72 | + }, |
| 73 | + { |
| 74 | + selector: 'variable', |
| 75 | + modifiers: ['exported'], |
| 76 | + format: ['camelCase', 'PascalCase'], |
| 77 | + }, |
| 78 | + { |
| 79 | + selector: 'typeProperty', |
| 80 | + format: ['camelCase'], |
| 81 | + }, |
| 82 | + { |
| 83 | + selector: 'method', |
| 84 | + format: ['camelCase'], |
| 85 | + }, |
| 86 | + ], |
| 87 | + }, |
| 88 | + settings: { |
| 89 | + 'import/resolver': { |
| 90 | + alias: { |
| 91 | + map: Object.entries(importMap.imports), |
| 92 | + extensions: [ |
| 93 | + '.cjs', |
| 94 | + '.mjs', |
| 95 | + '.mts', |
| 96 | + '.js', |
| 97 | + '.json', |
| 98 | + '.tsx', |
| 99 | + ], |
| 100 | + }, |
| 101 | + }, |
| 102 | + }, |
| 103 | + }, |
| 104 | + { |
| 105 | + files: ['**/*.js', '**/*.schema.json', '**/package.json', '**/*.d.ts'], |
| 106 | + rules: { |
| 107 | + '@typescript-eslint/naming-convention': 'off', |
| 108 | + }, |
| 109 | + }, |
| 110 | + { |
| 111 | + files: ['**/*.json', '**/closure-externs.js'], |
| 112 | + rules: { |
| 113 | + '@typescript-eslint/no-unused-expressions': 'off', |
| 114 | + }, |
| 115 | + }, |
| 116 | + { |
| 117 | + files: ['**/*.cjs', '**/*.cts'], |
| 118 | + rules: { |
| 119 | + '@typescript-eslint/no-require-imports': 'off', |
| 120 | + }, |
| 121 | + }, |
| 122 | +]; |
0 commit comments