File size: 1,531 Bytes
61d39e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// This script does not validate that eslint rules are followed; it only
// ensures that the eslint configuration is valid. When there are errors
// present in the eslint configuration, vscode pretends everything is
// fine and that there are no linter errors in any files.

import { ESLint } from 'eslint';

async function validateConfig() {
    let exitWithError = false;

    try {
        const eslint = new ESLint();
        await eslint.lintText('', { filePath: 'src/gui/**/*.js' });
    } catch (error) {
        console.error('❌ ESLint configuration error (general):', error.message);
        exitWithError = true;
    }

    try {
        const eslint = new ESLint();
        await eslint.lintText('', { filePath: 'src/backend/**/*.js' });
    } catch (error) {
        console.error('❌ ESLint configuration error (backend):', error.message);
        exitWithError = true;
    }

    try {
        const eslint = new ESLint();
        await eslint.lintText('', { filePath: 'extensions/**/*.js' });
    } catch (error) {
        console.error('❌ ESLint configuration error (extensions):', error.message);
        exitWithError = true;
    }
    
    if ( exitWithError ) {
        console.log('\x1B[36;1mYou should edit eslint.config.js to resolve this issue.\x1B[0m');
        console.log('\x1B[31;1mIf this is an emergency, use `git commit --no-verify`.\x1B[0m');
        process.exit(1);
    }

    console.log('✅ ESLint configuration is valid');
}

validateConfig();