Esempio n. 1
0
        internal static FileInfo GetConfigInfo(string relativePath)
        {
            OutputWindowHelper.DebugLine($"ShouldOverrideEslintConfig: {Options.ShouldOverrideEslintConfig}");

            // resolve override eslint config path
            if (Options.ShouldOverrideEslintConfig)
            {
                var overridePath = GetOverrideEslintConfigPath() ??
                                   throw new Exception("exception: option 'Override .eslintignore path' is set to true-- but no path is set");

                OutputWindowHelper.DebugLine($"using override eslint config @ {overridePath}");

                if (false == File.Exists(overridePath))
                {
                    throw new FileNotFoundException($"exception: could not find file '{overridePath}'");
                }

                return(new FileInfo(overridePath));
            }

            OutputWindowHelper.DebugLine($"UsePersonalConfig: {Options.UsePersonalConfig}");

            // resolve personal config path
            if (Options.UsePersonalConfig)
            {
                var globalPath = GetPersonalConfigPath() ??
                                 throw new Exception("exception: no personal eslint config found");

                OutputWindowHelper.DebugLine($"using personal eslint config @ {globalPath}");

                return(globalPath);
            }

            // resolve eslint config path
            var cwd = new DirectoryInfo(relativePath);

            var end = VsixHelper.GetSolutionPath() ??
                      throw new Exception("exception: could not get solution path");

            var info = FindRecursive(cwd, end, ResolveConfigPath);

            if (null == info)
            {
                OutputWindowHelper.DebugLine($"could not resolve eslint config relative to '{relativePath}', handing over config resolving to eslint"
                                             + Environment.NewLine
                                             + "WARNING! this could result in unexpected behavior");
            }

            return(info);
        }
Esempio n. 2
0
        internal static FileInfo GetIgnoreInfo(string relativePath)
        {
            OutputWindowHelper.DebugLine($"DisableIgnorePath: {Options.DisableIgnorePath}");

            // disable eslint ignore
            if (Options.DisableIgnorePath)
            {
                OutputWindowHelper.DebugLine("not using eslint ignore");

                return(null);
            }

            OutputWindowHelper.DebugLine($"ShouldOverrideEslintIgnore: {Options.ShouldOverrideEslintIgnore}");

            // resolve override eslint ignore path
            if (Options.ShouldOverrideEslintIgnore)
            {
                var overridePath = GetOverrideEslintIgnorePath() ??
                                   throw new Exception("exception: option 'Override ESLint ignore path' is set to true-- but no path is set");

                OutputWindowHelper.DebugLine($"using override eslint ignore @ {overridePath}");

                if (false == File.Exists(overridePath))
                {
                    throw new FileNotFoundException($"exception: could not find file '{overridePath}'");
                }

                return(new FileInfo(overridePath));
            }

            // resolve eslint ignore path
            var cwd = new DirectoryInfo(relativePath);

            var end = VsixHelper.GetSolutionPath() ??
                      throw new Exception("exception: could not get solution path");

            var info = FindRecursive(cwd, end, ResolveIgnorePath);

            OutputWindowHelper.DebugLine($"using eslint ignore @ {info?.FullName ?? "not found"}");

            return(info);
        }
Esempio n. 3
0
        internal static string GetIgnorePath(string directoryPath)
        {
            OutputWindowHelper.DebugLine($"DisableIgnorePath: {Options.DisableIgnorePath}");

            // disable eslint ignore
            if (Options.DisableIgnorePath)
            {
                OutputWindowHelper.DebugLine("not using eslint ignore");

                return(null);
            }

            OutputWindowHelper.DebugLine($"ShouldOverrideEslintIgnore: {Options.ShouldOverrideEslintIgnore}");

            // resolve override eslint ignore path
            if (Options.ShouldOverrideEslintIgnore)
            {
                var overridePath = GetOverrideEslintIgnorePath() ??
                                   throw new Exception("exception: option 'Override ESLint ignore path' is set to true-- but no path is set");

                OutputWindowHelper.DebugLine($"using override eslint ignore @ {overridePath}");

                return(ValidateOverridePath(overridePath));
            }

            // resolve eslint ignore path
            var solutionPath = VsixHelper.GetSolutionPath() ??
                               throw new Exception("exception: could not get solution path");

            var workingDirectory = new DirectoryInfo(directoryPath);

            var path = FindRecursive(workingDirectory, solutionPath, ResolveIgnorePath);

            OutputWindowHelper.DebugLine($"using eslint ignore @ {path ?? "not found"}");

            return(path);
        }