|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const js = require('@eslint/js'); |
| 4 | +const globals = require('globals'); |
| 5 | +const importX = require('eslint-plugin-import-x'); |
| 6 | +const n = require('eslint-plugin-n'); |
| 7 | +const eslintConfigPrettier = require('eslint-config-prettier/flat'); |
| 8 | + |
| 9 | +const devDependencyFiles = [ |
| 10 | + '**/*.test.js', |
| 11 | + '**/scripts/**', |
| 12 | + '**/test/**', |
| 13 | + '**/tests/**', |
| 14 | + 'eslint.config.js', |
| 15 | + 'prettier.config.js', |
| 16 | +]; |
| 17 | + |
| 18 | +module.exports = [ |
| 19 | + { |
| 20 | + linterOptions: { |
| 21 | + reportUnusedDisableDirectives: 'warn', |
| 22 | + }, |
| 23 | + }, |
| 24 | + { |
| 25 | + ignores: ['**/.*'], |
| 26 | + }, |
| 27 | + js.configs.recommended, |
| 28 | + n.configs['flat/recommended-script'], |
| 29 | + importX.flatConfigs.recommended, |
| 30 | + eslintConfigPrettier, |
| 31 | + { |
| 32 | + files: ['**/*.{cjs,js,mjs}'], |
| 33 | + languageOptions: { |
| 34 | + ecmaVersion: 2023, |
| 35 | + sourceType: 'commonjs', |
| 36 | + globals: { |
| 37 | + ...globals.node, |
| 38 | + fetch: 'readonly', |
| 39 | + }, |
| 40 | + }, |
| 41 | + rules: { |
| 42 | + 'import-x/no-extraneous-dependencies': [ |
| 43 | + 'error', |
| 44 | + { |
| 45 | + devDependencies: devDependencyFiles, |
| 46 | + }, |
| 47 | + ], |
| 48 | + 'import-x/no-unresolved': ['error', { commonjs: true }], |
| 49 | + 'no-unused-vars': ['error', { caughtErrors: 'none' }], |
| 50 | + 'n/no-unsupported-features/node-builtins': ['error', { allowExperimental: true }], |
| 51 | + 'n/no-extraneous-require': 'off', |
| 52 | + 'n/no-unpublished-require': 'off', |
| 53 | + 'n/no-missing-require': 'off', |
| 54 | + 'n/no-process-exit': 'off', |
| 55 | + 'n/no-deprecated-api': 'off', |
| 56 | + 'n/hashbang': 'off', |
| 57 | + }, |
| 58 | + }, |
| 59 | + { |
| 60 | + files: ['**/*.mjs'], |
| 61 | + languageOptions: { |
| 62 | + sourceType: 'module', |
| 63 | + }, |
| 64 | + }, |
| 65 | + { |
| 66 | + files: ['**/*.test.js', '**/test/**'], |
| 67 | + languageOptions: { |
| 68 | + globals: globals.mocha, |
| 69 | + }, |
| 70 | + rules: { |
| 71 | + 'no-unused-expressions': 'off', |
| 72 | + }, |
| 73 | + }, |
| 74 | +]; |
0 commit comments