|
| 1 | +import globals from 'globals'; |
| 2 | +import path from 'node:path'; |
| 3 | +import { fileURLToPath } from 'node:url'; |
| 4 | +import js from '@eslint/js'; |
| 5 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 6 | + |
| 7 | +const __filename = fileURLToPath(import.meta.url); |
| 8 | +const __dirname = path.dirname(__filename); |
| 9 | +const compat = new FlatCompat({ |
| 10 | + baseDirectory: __dirname, |
| 11 | + recommendedConfig: js.configs.recommended, |
| 12 | + allConfig: js.configs.all |
| 13 | +}); |
| 14 | + |
| 15 | +export default [ |
| 16 | + { |
| 17 | + ignores: ['**/.vscode', '**/api', '**/node_modules', '**/samples', '**/*.md', '**/*.json', '**/LICENSE'] |
| 18 | + }, |
| 19 | + ...compat.extends('plugin:prettier/recommended'), |
| 20 | + { |
| 21 | + languageOptions: { |
| 22 | + globals: { |
| 23 | + ...globals.node, |
| 24 | + Promise: true, |
| 25 | + global: true |
| 26 | + }, |
| 27 | + |
| 28 | + ecmaVersion: 2021, |
| 29 | + sourceType: 'module', |
| 30 | + |
| 31 | + parserOptions: { |
| 32 | + ecmaFeatures: { |
| 33 | + jsx: true |
| 34 | + } |
| 35 | + } |
| 36 | + }, |
| 37 | + |
| 38 | + rules: { |
| 39 | + indent: [ |
| 40 | + 'error', |
| 41 | + 2, |
| 42 | + { |
| 43 | + SwitchCase: 1 |
| 44 | + } |
| 45 | + ], |
| 46 | + |
| 47 | + 'default-case': 'error', |
| 48 | + 'linebreak-style': ['error', 'unix'], |
| 49 | + semi: ['error', 'always'], |
| 50 | + 'no-console': 'error', |
| 51 | + 'no-undef': 'error', |
| 52 | + 'no-var': 'error', |
| 53 | + 'no-caller': 'error', |
| 54 | + 'no-throw-literal': 'error', |
| 55 | + 'no-unneeded-ternary': 'error', |
| 56 | + 'prefer-const': 'error', |
| 57 | + |
| 58 | + 'comma-spacing': [ |
| 59 | + 'error', |
| 60 | + { |
| 61 | + before: false, |
| 62 | + after: true |
| 63 | + } |
| 64 | + ], |
| 65 | + |
| 66 | + 'comma-style': ['error', 'last'], |
| 67 | + 'handle-callback-err': ['error', '^(err|error)$'] |
| 68 | + } |
| 69 | + } |
| 70 | +]; |
0 commit comments