eslintrc.d.cts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @fileoverview This file contains the core types for ESLint. It was initially extracted
  3. * from the `@types/eslint__eslintrc` package.
  4. */
  5. /*
  6. * MIT License
  7. * Copyright (c) Microsoft Corporation.
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. * The above copyright notice and this permission notice shall be included in all
  16. * copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. * SOFTWARE
  25. */
  26. import type { Linter } from "eslint";
  27. /**
  28. * A compatibility class for working with configs.
  29. */
  30. export class FlatCompat {
  31. constructor({
  32. baseDirectory,
  33. resolvePluginsRelativeTo,
  34. recommendedConfig,
  35. allConfig,
  36. }?: {
  37. /**
  38. * default: process.cwd()
  39. */
  40. baseDirectory?: string;
  41. resolvePluginsRelativeTo?: string;
  42. recommendedConfig?: Linter.LegacyConfig;
  43. allConfig?: Linter.LegacyConfig;
  44. });
  45. /**
  46. * Translates an ESLintRC-style config into a flag-config-style config.
  47. * @param eslintrcConfig The ESLintRC-style config object.
  48. * @returns A flag-config-style config object.
  49. */
  50. config(eslintrcConfig: Linter.LegacyConfig): Linter.Config[];
  51. /**
  52. * Translates the `env` section of an ESLintRC-style config.
  53. * @param envConfig The `env` section of an ESLintRC config.
  54. * @returns An array of flag-config objects representing the environments.
  55. */
  56. env(envConfig: { [name: string]: boolean }): Linter.Config[];
  57. /**
  58. * Translates the `extends` section of an ESLintRC-style config.
  59. * @param configsToExtend The names of the configs to load.
  60. * @returns An array of flag-config objects representing the config.
  61. */
  62. extends(...configsToExtend: string[]): Linter.Config[];
  63. /**
  64. * Translates the `plugins` section of an ESLintRC-style config.
  65. * @param plugins The names of the plugins to load.
  66. * @returns An array of flag-config objects representing the plugins.
  67. */
  68. plugins(...plugins: string[]): Linter.Config[];
  69. }