|
1 | 1 | // eslint.config.js |
2 | 2 | const js = require('@eslint/js'); |
3 | 3 | const pluginPromise = require('eslint-plugin-promise'); |
4 | | -const pluginUnicorn = require('eslint-plugin-unicorn'); |
| 4 | +const pluginUnicorn = require('eslint-plugin-unicorn').default; |
5 | 5 | const pluginN = require('eslint-plugin-n'); |
6 | 6 | const prettier = require('eslint-config-prettier'); |
| 7 | +const pluginMocha = require('eslint-plugin-mocha').default; |
| 8 | +const globals = require('globals'); |
7 | 9 |
|
8 | 10 | module.exports = [ |
| 11 | + js.configs.recommended, |
9 | 12 | { |
| 13 | + files: ['**/*.js'], |
10 | 14 | ignores: ['dist/**', 'tmp/**', 'coverage/**'], |
| 15 | + languageOptions: { |
| 16 | + ecmaVersion: 2022, |
| 17 | + sourceType: 'commonjs', |
| 18 | + globals: { |
| 19 | + // Node.js globals |
| 20 | + ...globals.node, |
| 21 | + ...globals.mocha, |
| 22 | + }, |
| 23 | + }, |
11 | 24 | plugins: { |
12 | 25 | promise: pluginPromise, |
13 | 26 | unicorn: pluginUnicorn, |
14 | 27 | n: pluginN, |
| 28 | + mocha: pluginMocha, |
| 29 | + }, |
| 30 | + rules: { |
| 31 | + ...pluginPromise.configs.recommended.rules, |
| 32 | + ...pluginN.configs.recommended.rules, |
| 33 | + ...pluginUnicorn.configs.recommended.rules, |
| 34 | + ...pluginMocha.configs.recommended.rules, |
| 35 | + // Give warnings for rules should fix in the future |
| 36 | + 'no-prototype-builtins': 'warn', |
| 37 | + // Disable rules that don't fit this CommonJS project |
| 38 | + 'unicorn/prefer-module': 'off', |
| 39 | + 'unicorn/prevent-abbreviations': 'off', |
| 40 | + 'unicorn/no-null': 'off', |
| 41 | + 'unicorn/prefer-spread': 'warn', |
| 42 | + 'unicorn/no-immediate-mutation': 'warn', |
| 43 | + 'unicorn/prefer-single-call': 'warn', |
| 44 | + 'unicorn/no-array-reduce': 'warn', |
| 45 | + 'unicorn/no-await-expression-member': 'warn', |
| 46 | + 'unicorn/prefer-structured-clone': 'warn', |
| 47 | + // Disable Mocha rule that doesn't fit existing test patterns |
| 48 | + 'mocha/no-setup-in-describe': 'off', |
15 | 49 | }, |
16 | 50 | }, |
17 | 51 | prettier, |
18 | | -] |
| 52 | +]; |
0 commit comments