|
| 1 | +import globals from 'globals'; |
| 2 | +import typescriptEslint from '@typescript-eslint/eslint-plugin'; |
| 3 | +import tsParser from '@typescript-eslint/parser'; |
| 4 | +import path from 'node:path'; |
| 5 | +import { fileURLToPath } from 'node:url'; |
| 6 | +import js from '@eslint/js'; |
| 7 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 8 | + |
| 9 | +const __filename = fileURLToPath(import.meta.url); |
| 10 | +const __dirname = path.dirname(__filename); |
| 11 | +const compat = new FlatCompat({ |
| 12 | + baseDirectory: __dirname, |
| 13 | + recommendedConfig: js.configs.recommended, |
| 14 | + allConfig: js.configs.all |
| 15 | +}); |
| 16 | + |
| 17 | +export default [ |
| 18 | + { |
| 19 | + ignores: [ |
| 20 | + 'coverage/**/*.js', |
| 21 | + 'dist/**/*.cjs', |
| 22 | + 'dist/**/*.js', |
| 23 | + 'tests/**/*.snap', |
| 24 | + 'tests/format/**/*.sol', |
| 25 | + 'tests/format/Markdown/Markdown.md', |
| 26 | + 'tests/format/RespectDefaultOptions/respect-default-options.js', |
| 27 | + 'tests/config/**/*.*js', |
| 28 | + 'src/prettier-comments/**/*.js' |
| 29 | + ] |
| 30 | + }, |
| 31 | + { |
| 32 | + languageOptions: { |
| 33 | + globals: { |
| 34 | + ...globals.jest, |
| 35 | + runFormatTest: 'readonly' |
| 36 | + } |
| 37 | + }, |
| 38 | + |
| 39 | + rules: { |
| 40 | + 'no-console': [ |
| 41 | + 'warn', |
| 42 | + { |
| 43 | + allow: ['warn'] |
| 44 | + } |
| 45 | + ] |
| 46 | + } |
| 47 | + }, |
| 48 | + ...compat |
| 49 | + .extends( |
| 50 | + 'prettier', |
| 51 | + 'plugin:@typescript-eslint/recommended', |
| 52 | + 'plugin:@typescript-eslint/stylistic', |
| 53 | + 'plugin:@typescript-eslint/recommended-type-checked' |
| 54 | + ) |
| 55 | + .map((config) => ({ |
| 56 | + ...config, |
| 57 | + files: ['**/*.ts'] |
| 58 | + })), |
| 59 | + { |
| 60 | + files: ['**/*.ts'], |
| 61 | + |
| 62 | + plugins: { |
| 63 | + '@typescript-eslint': typescriptEslint |
| 64 | + }, |
| 65 | + |
| 66 | + languageOptions: { |
| 67 | + parser: tsParser, |
| 68 | + ecmaVersion: 5, |
| 69 | + sourceType: 'script', |
| 70 | + |
| 71 | + parserOptions: { |
| 72 | + project: ['tsconfig.json'] |
| 73 | + } |
| 74 | + }, |
| 75 | + |
| 76 | + rules: { |
| 77 | + '@typescript-eslint/explicit-function-return-type': 'error' |
| 78 | + } |
| 79 | + }, |
| 80 | + ...compat.extends('prettier').map((config) => ({ |
| 81 | + ...config, |
| 82 | + files: ['**/*.*js'] |
| 83 | + })), |
| 84 | + { |
| 85 | + files: ['**/*.*js'], |
| 86 | + |
| 87 | + languageOptions: { |
| 88 | + ecmaVersion: 'latest', |
| 89 | + sourceType: 'module' |
| 90 | + } |
| 91 | + } |
| 92 | +]; |
0 commit comments