|
| 1 | +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +import { includeIgnoreFile } from '@eslint/compat'; |
| 4 | +import eslint from '@eslint/js'; |
| 5 | +import headerPlugin from 'eslint-plugin-header'; |
| 6 | +import eslintPrettier from 'eslint-plugin-prettier/recommended'; |
| 7 | +import unicornPlugin from 'eslint-plugin-unicorn'; |
| 8 | +import globals from 'globals'; |
| 9 | +import path from 'node:path'; |
| 10 | +import tsEslint from 'typescript-eslint'; |
| 11 | + |
| 12 | +// https://github.com/Stuk/eslint-plugin-header/issues/57 |
| 13 | +headerPlugin.rules.header.meta.schema = false; |
| 14 | + |
| 15 | +export default tsEslint.config( |
| 16 | + includeIgnoreFile(path.resolve('.gitignore')), |
| 17 | + eslint.configs.recommended, |
| 18 | + tsEslint.configs.recommended, |
| 19 | + eslintPrettier, |
| 20 | + { |
| 21 | + files: ['**/*.{js,mjs,ts,tsx}'], |
| 22 | + languageOptions: { |
| 23 | + globals: { |
| 24 | + ...globals.browser, |
| 25 | + }, |
| 26 | + }, |
| 27 | + plugins: { unicorn: unicornPlugin, header: headerPlugin }, |
| 28 | + rules: { |
| 29 | + '@typescript-eslint/no-var-requires': 'off', |
| 30 | + 'header/header': [ |
| 31 | + 'error', |
| 32 | + 'line', |
| 33 | + [' Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.', ' SPDX-License-Identifier: Apache-2.0'], |
| 34 | + ], |
| 35 | + }, |
| 36 | + }, |
| 37 | + { |
| 38 | + files: ['.github/**', 'scripts/**', '*.mjs', 'test/*.mjs'], |
| 39 | + languageOptions: { |
| 40 | + globals: { |
| 41 | + ...globals.node, |
| 42 | + ...globals.commonjs, |
| 43 | + }, |
| 44 | + }, |
| 45 | + rules: { |
| 46 | + '@typescript-eslint/no-var-requires': 'off', |
| 47 | + }, |
| 48 | + }, |
| 49 | + { |
| 50 | + files: ['src/**'], |
| 51 | + rules: { |
| 52 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 53 | + '@typescript-eslint/no-unused-vars': 'warn', |
| 54 | + }, |
| 55 | + }, |
| 56 | + { |
| 57 | + files: ['src/**/__tests__/**/*.*js'], |
| 58 | + rules: { |
| 59 | + 'no-undef': 'warn', |
| 60 | + }, |
| 61 | + }, |
| 62 | +); |
0 commit comments