-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
55 lines (50 loc) · 1.67 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// eslint.config.mjs
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import js from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
export default defineConfig([
// 1. Apply general language options (like globals) globally or per file group
{
files: ['**/*.{js,mjs,cjs}'], // Apply to all relevant JS files
languageOptions: {
ecmaVersion: 'latest', // Good practice to set the ECMAScript version
globals: {
...globals.node, // Use Node.js global variables
// ... add other globals if needed (e.g., globals.jest for test files)
},
},
// You could add common rules here too if needed
},
// 2. Configure source type based on file extension
{
files: ['**/*.js', '**/*.cjs'], // CommonJS files
languageOptions: {
sourceType: 'commonjs',
},
},
{
files: ['**/*.mjs'], // ES Module files
languageOptions: {
sourceType: 'module',
},
},
// 3. Apply recommended ESLint rules (@eslint/js)
// This implicitly loads the necessary plugin and enables recommended rules.
// This should come *before* prettierConfig.
js.configs.recommended,
// 4. Apply Prettier compatibility config
// *MUST* be loaded *after* any other config that enables rules (like js.configs.recommended)
// This disables ESLint formatting rules that conflict with Prettier.
prettierConfig,
// 5. Define ignored files/directories
{
ignores: [
'build/', // Ignore build output
'coverage/', // Ignore coverage reports
'node_modules/', // Standard ignore
'test/cpp/', // Ignore C++ test files
'**/*.map', // Ignore source map files
],
},
]);