'use strict';

const rules = require('./rules');


let hasTypescript;
try {
    require.resolve('typescript');
    hasTypescript = true;
} catch (err) {
    hasTypescript = false;
}

const overrides = [];
if (hasTypescript) {
    overrides.push(
        {
            // overrides just for react files
            files: ['.jsx', '*.tsx'],
            extends: ['plugin:@typescript-eslint/recommended', 'airbnb'],
            plugins: ['@typescript-eslint'],
            parser: '@typescript-eslint/parser',
            env: {
                jest: true,
                jasmine: false,
                node: false,
                browser: true,
            },
            parserOptions: {
                ecmaVersion: 8,
                sourceType: 'module',
                ecmaFeatures: {
                    modules: true,
                    jsx: true,
                },
                useJSXTextNode: true,
            },
            rules: rules.react,
        },
        {
            // overrides just for typescript files
            files: ['*.ts'],
            extends: ['plugin:@typescript-eslint/recommended', 'airbnb-base'],
            plugins: ['@typescript-eslint'],
            parser: '@typescript-eslint/parser',
            parserOptions: {
                ecmaVersion: 8,
                sourceType: 'module',
                ecmaFeatures: {
                    modules: true,
                    jsx: false,
                },
            },
            rules: rules.typescript,
        }
    );
}

module.exports = overrides;

@@ -8,16 +8,72 @@
 rict';%0A%0A
+const fs = require('fs');%0Aconst path = require('path');%0A
 const ru
@@ -99,17 +99,16 @@
 les');%0A%0A
-%0A
 let hasT
@@ -270,24 +270,820 @@
 pescript) %7B%0A
+    const project = %5B%5D;%0A    try %7B%0A        const pkg = JSON.parse(fs.readFileSync('./package.json'));%0A%0A        if (fs.existsSync('./tsconfig.json')) %7B%0A            project.push('./tsconfig.json');%0A        %7D%0A%0A        if (pkg.workspaces) %7B%0A            pkg.workspaces%0A                .forEach((workspace) =%3E %7B%0A                    project.push(%0A                        ...getTSProjects(workspace)%0A                            .map((ref) =%3E %60./$%7Bref%7D%60)%0A                    );%0A                %7D);%0A        %7D%0A    %7D catch (err) %7B%0A        // do nothing%0A    %7D%0A%0A    if (!project.length) %7B%0A        const projectOnlyRules = %5B'@typescript-eslint/no-misused-promises'%5D;%0A        projectOnlyRules.forEach((rule) =%3E %7B%0A            delete rules.typescript%5Brule%5D;%0A            delete rules.react%5Brule%5D;%0A        %7D);%0A    %7D%0A%0A
     override
@@ -1597,32 +1597,95 @@
 Type: 'module',%0A
+                project: project.length ? project : undefined,%0A
                 
@@ -2235,32 +2235,95 @@
 Type: 'module',%0A
+                project: project.length ? project : undefined,%0A
                 
@@ -2482,24 +2482,24 @@
 ,%0A        %7D%0A
-
     );%0A%7D%0A%0Amo
@@ -2496,16 +2496,809 @@
   );%0A%7D%0A%0A
+function getTSProjects(workspace) %7B%0A    const folderPath = workspace.replace(/%5C*$/, '');%0A    if (!fs.existsSync(folderPath)) return %5B%5D;%0A    if (fs.existsSync(path.join(folderPath, 'package.json'))) %7B%0A        const tsconfigPath = path.join(folderPath, 'tsconfig.json');%0A        if (fs.existsSync(tsconfigPath)) %7B%0A            return %5BtsconfigPath%5D;%0A        %7D%0A        return %5B%5D;%0A    %7D%0A    return fs%0A        .readdirSync(folderPath)%0A        .filter((pkgName) =%3E %7B%0A            const pkgDir = path.join(folderPath, pkgName);%0A%0A            if (!fs.statSync(pkgDir).isDirectory()) return false;%0A            const tsConfigPath = path.join(pkgDir, 'tsconfig.json');%0A            return fs.existsSync(tsConfigPath);%0A        %7D)%0A        .map((pkgName) =%3E path.join(folderPath, pkgName, 'tsconfig.json'));%0A%7D%0A%0A
 module.e

fix eslint overrides