|
| 1 | +import globals from 'globals'; |
| 2 | + |
| 3 | +import path from 'path'; |
| 4 | +import { fileURLToPath } from 'url'; |
| 5 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 6 | +import pluginJs from '@eslint/js'; |
| 7 | +import importPlugin from 'eslint-plugin-import'; |
| 8 | + |
| 9 | +// mimic CommonJS variables -- not needed if using CommonJS |
| 10 | +const __filename = fileURLToPath(import.meta.url); |
| 11 | +const __dirname = path.dirname(__filename); |
| 12 | +const compat = new FlatCompat({ |
| 13 | + baseDirectory: __dirname, |
| 14 | + recommendedConfig: pluginJs.configs.recommended, |
| 15 | +}); |
| 16 | + |
| 17 | +export default [ |
| 18 | + { |
| 19 | + languageOptions: { |
| 20 | + globals: { |
| 21 | + ...globals.node, |
| 22 | + ...globals.jest, |
| 23 | + }, |
| 24 | + parserOptions: { |
| 25 | + // Eslint doesn't supply ecmaVersion in `parser.js` `context.parserOptions` |
| 26 | + // This is required to avoid ecmaVersion < 2015 error or 'import' / 'export' error |
| 27 | + ecmaVersion: 'latest', |
| 28 | + sourceType: 'module', |
| 29 | + }, |
| 30 | + }, |
| 31 | + plugins: { import: importPlugin }, |
| 32 | + rules: { |
| 33 | + ...importPlugin.configs.recommended.rules, |
| 34 | + }, |
| 35 | + }, |
| 36 | + ...compat.extends('airbnb-base'), |
| 37 | + { |
| 38 | + rules: { |
| 39 | + 'no-underscore-dangle': [ |
| 40 | + 'error', |
| 41 | + { |
| 42 | + allow: ['__filename', '__dirname'], |
| 43 | + }, |
| 44 | + ], |
| 45 | + 'import/extensions': [ |
| 46 | + 'error', |
| 47 | + { |
| 48 | + js: 'always', |
| 49 | + }, |
| 50 | + ], |
| 51 | + 'import/no-named-as-default': 'off', |
| 52 | + 'import/no-named-as-default-member': 'off', |
| 53 | + 'no-console': 'off', |
| 54 | + 'import/no-extraneous-dependencies': 'off', |
| 55 | + }, |
| 56 | + }, |
| 57 | +]; |
0 commit comments