source: imaps-frontend/node_modules/eslint/lib/api.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @fileoverview Expose out ESLint and CLI to require.
3 * @author Ian Christian Myers
4 */
5
6"use strict";
7
8//-----------------------------------------------------------------------------
9// Requirements
10//-----------------------------------------------------------------------------
11
12const { ESLint, FlatESLint } = require("./eslint");
13const { shouldUseFlatConfig } = require("./eslint/flat-eslint");
14const { Linter } = require("./linter");
15const { RuleTester } = require("./rule-tester");
16const { SourceCode } = require("./source-code");
17
18//-----------------------------------------------------------------------------
19// Functions
20//-----------------------------------------------------------------------------
21
22/**
23 * Loads the correct ESLint constructor given the options.
24 * @param {Object} [options] The options object
25 * @param {boolean} [options.useFlatConfig] Whether or not to use a flat config
26 * @param {string} [options.cwd] The current working directory
27 * @returns {Promise<ESLint|LegacyESLint>} The ESLint constructor
28 */
29async function loadESLint({ useFlatConfig, cwd = process.cwd() } = {}) {
30
31 /*
32 * Note: The v9.x version of this function doesn't have a cwd option
33 * because it's not used. It's only used in the v8.x version of this
34 * function.
35 */
36
37 const shouldESLintUseFlatConfig = typeof useFlatConfig === "boolean"
38 ? useFlatConfig
39 : await shouldUseFlatConfig({ cwd });
40
41 return shouldESLintUseFlatConfig ? FlatESLint : ESLint;
42}
43
44//-----------------------------------------------------------------------------
45// Exports
46//-----------------------------------------------------------------------------
47
48module.exports = {
49 Linter,
50 loadESLint,
51 ESLint,
52 RuleTester,
53 SourceCode
54};
Note: See TracBrowser for help on using the repository browser.