@nx/eslint 17.2.0-beta.10 → 17.2.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/eslint",
3
- "version": "17.2.0-beta.10",
3
+ "version": "17.2.0-beta.12",
4
4
  "private": false,
5
5
  "description": "The ESLint plugin for Nx contains executors, generators and utilities used for linting JavaScript/TypeScript projects within an Nx workspace.",
6
6
  "repository": {
@@ -27,18 +27,18 @@
27
27
  "requirements": {},
28
28
  "migrations": "./migrations.json"
29
29
  },
30
- "executors": "./executors.json",
31
30
  "generators": "./generators.json",
31
+ "executors": "./executors.json",
32
32
  "peerDependencies": {
33
33
  "eslint": "^8.0.0",
34
34
  "js-yaml": "4.1.0"
35
35
  },
36
36
  "dependencies": {
37
+ "@nx/devkit": "17.2.0-beta.12",
38
+ "@nx/js": "17.2.0-beta.12",
37
39
  "tslib": "^2.3.0",
38
- "@nx/devkit": "17.2.0-beta.10",
39
- "@nx/js": "17.2.0-beta.10",
40
40
  "typescript": "~5.2.2",
41
- "@nx/linter": "17.2.0-beta.10"
41
+ "@nx/linter": "17.2.0-beta.12"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "eslint": {
package/plugin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { createNodes, EslintPluginOptions } from './src/plugins/plugin';
package/plugin.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNodes = void 0;
4
+ var plugin_1 = require("./src/plugins/plugin");
5
+ Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
@@ -5,18 +5,22 @@ const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("../../utils/versions");
6
6
  const eslint_file_1 = require("../utils/eslint-file");
7
7
  const global_eslint_config_1 = require("./global-eslint-config");
8
- function addTargetDefaults(tree) {
8
+ function updateProductionFileset(tree) {
9
9
  const nxJson = (0, devkit_1.readNxJson)(tree);
10
10
  const productionFileSet = nxJson.namedInputs?.production;
11
11
  if (productionFileSet) {
12
- // Remove .eslintrc.json
13
12
  productionFileSet.push('!{projectRoot}/.eslintrc.json');
14
13
  productionFileSet.push('!{projectRoot}/eslint.config.js');
15
14
  // Dedupe and set
16
15
  nxJson.namedInputs.production = Array.from(new Set(productionFileSet));
17
16
  }
17
+ (0, devkit_1.updateNxJson)(tree, nxJson);
18
+ }
19
+ function addTargetDefaults(tree) {
20
+ const nxJson = (0, devkit_1.readNxJson)(tree);
18
21
  nxJson.targetDefaults ??= {};
19
22
  nxJson.targetDefaults.lint ??= {};
23
+ nxJson.targetDefaults.lint.cache ??= true;
20
24
  nxJson.targetDefaults.lint.inputs ??= [
21
25
  'default',
22
26
  `{workspaceRoot}/.eslintrc.json`,
@@ -25,6 +29,36 @@ function addTargetDefaults(tree) {
25
29
  ];
26
30
  (0, devkit_1.updateNxJson)(tree, nxJson);
27
31
  }
32
+ function addPlugin(tree) {
33
+ const nxJson = (0, devkit_1.readNxJson)(tree);
34
+ nxJson.plugins ??= [];
35
+ for (const plugin of nxJson.plugins) {
36
+ if (typeof plugin === 'string'
37
+ ? plugin === '@nx/eslint/plugin'
38
+ : plugin.plugin === '@nx/eslint/plugin') {
39
+ return;
40
+ }
41
+ }
42
+ nxJson.plugins.push({
43
+ plugin: '@nx/eslint/plugin',
44
+ options: {
45
+ targetName: 'lint',
46
+ },
47
+ });
48
+ (0, devkit_1.updateNxJson)(tree, nxJson);
49
+ }
50
+ function updateVSCodeExtensions(tree) {
51
+ if (tree.exists('.vscode/extensions.json')) {
52
+ (0, devkit_1.updateJson)(tree, '.vscode/extensions.json', (json) => {
53
+ json.recommendations ||= [];
54
+ const extension = 'dbaeumer.vscode-eslint';
55
+ if (!json.recommendations.includes(extension)) {
56
+ json.recommendations.push(extension);
57
+ }
58
+ return json;
59
+ });
60
+ }
61
+ }
28
62
  /**
29
63
  * Initializes ESLint configuration in a workspace and adds necessary dependencies.
30
64
  */
@@ -37,17 +71,15 @@ function initEsLint(tree, options) {
37
71
  }
38
72
  (0, devkit_1.writeJson)(tree, '.eslintrc.json', (0, global_eslint_config_1.getGlobalEsLintConfiguration)(options.unitTestRunner, options.rootProject));
39
73
  tree.write('.eslintignore', 'node_modules\n');
40
- addTargetDefaults(tree);
41
- if (tree.exists('.vscode/extensions.json')) {
42
- (0, devkit_1.updateJson)(tree, '.vscode/extensions.json', (json) => {
43
- json.recommendations ||= [];
44
- const extension = 'dbaeumer.vscode-eslint';
45
- if (!json.recommendations.includes(extension)) {
46
- json.recommendations.push(extension);
47
- }
48
- return json;
49
- });
74
+ updateProductionFileset(tree);
75
+ const addPlugins = process.env.NX_PCV3 === 'true';
76
+ if (addPlugins) {
77
+ addPlugin(tree);
78
+ }
79
+ else {
80
+ addTargetDefaults(tree);
50
81
  }
82
+ updateVSCodeExtensions(tree);
51
83
  return !options.skipPackageJson
52
84
  ? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
53
85
  '@nx/eslint': versions_1.nxVersion,
@@ -9,6 +9,7 @@ const init_migration_1 = require("../init/init-migration");
9
9
  const project_configuration_1 = require("nx/src/generators/utils/project-configuration");
10
10
  const flat_config_1 = require("../../utils/flat-config");
11
11
  const ast_utils_1 = require("../utils/flat-config/ast-utils");
12
+ const config_file_1 = require("../../utils/config-file");
12
13
  async function lintProjectGenerator(tree, options) {
13
14
  const installTask = (0, init_1.lintInitGenerator)(tree, {
14
15
  linter: options.linter,
@@ -17,23 +18,42 @@ async function lintProjectGenerator(tree, options) {
17
18
  rootProject: options.rootProject,
18
19
  });
19
20
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
20
- projectConfig.targets['lint'] = {
21
- executor: '@nx/eslint:lint',
22
- outputs: ['{options.outputFile}'],
23
- };
24
21
  let lintFilePatterns = options.eslintFilePatterns;
25
22
  if (!lintFilePatterns && options.rootProject && projectConfig.root === '.') {
26
23
  lintFilePatterns = ['./src'];
27
24
  }
28
- if (lintFilePatterns && lintFilePatterns.length) {
29
- if (isBuildableLibraryProject(projectConfig) &&
30
- !lintFilePatterns.includes('{projectRoot}')) {
31
- lintFilePatterns.push(`{projectRoot}/package.json`);
25
+ if (lintFilePatterns &&
26
+ lintFilePatterns.length &&
27
+ !lintFilePatterns.includes('{projectRoot}') &&
28
+ isBuildableLibraryProject(projectConfig)) {
29
+ lintFilePatterns.push(`{projectRoot}/package.json`);
30
+ }
31
+ const nxJson = (0, devkit_1.readNxJson)(tree);
32
+ const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
33
+ ? p === '@nx/eslint/plugin'
34
+ : p.plugin === '@nx/eslint/plugin');
35
+ if (hasPlugin) {
36
+ if (lintFilePatterns &&
37
+ lintFilePatterns.length &&
38
+ lintFilePatterns.some((p) => !['./src', '{projectRoot}', projectConfig.root].includes(p))) {
39
+ projectConfig.targets['lint'] = {
40
+ command: `eslint ${lintFilePatterns
41
+ .join(' ')
42
+ .replace('{projectRoot}', projectConfig.root)}`,
43
+ };
32
44
  }
33
- // only add lintFilePatterns if they are explicitly defined
34
- projectConfig.targets['lint'].options = {
35
- lintFilePatterns,
45
+ }
46
+ else {
47
+ projectConfig.targets['lint'] = {
48
+ executor: '@nx/eslint:lint',
49
+ outputs: ['{options.outputFile}'],
36
50
  };
51
+ if (lintFilePatterns && lintFilePatterns.length) {
52
+ // only add lintFilePatterns if they are explicitly defined
53
+ projectConfig.targets['lint'].options = {
54
+ lintFilePatterns,
55
+ };
56
+ }
37
57
  }
38
58
  // we are adding new project which is not the root project or
39
59
  // companion e2e app so we should check if migration to
@@ -168,8 +188,8 @@ function isBuildableLibraryProject(projectConfig) {
168
188
  */
169
189
  function isMigrationToMonorepoNeeded(projects, tree) {
170
190
  // the base config is already created, migration has been done
171
- if (tree.exists(eslint_file_1.baseEsLintConfigFile) ||
172
- tree.exists(eslint_file_1.baseEsLintFlatConfigFile)) {
191
+ if (tree.exists(config_file_1.baseEsLintConfigFile) ||
192
+ tree.exists(config_file_1.baseEsLintFlatConfigFile)) {
173
193
  return false;
174
194
  }
175
195
  const configs = Object.values(projects);
@@ -1,8 +1,5 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { Linter } from 'eslint';
3
- export declare const eslintConfigFileWhitelist: string[];
4
- export declare const baseEsLintConfigFile = ".eslintrc.base.json";
5
- export declare const baseEsLintFlatConfigFile = "eslint.base.config.js";
6
3
  export declare function findEslintFile(tree: Tree, projectRoot?: string): string | null;
7
4
  export declare function isEslintConfigSupported(tree: Tree, projectRoot?: string): boolean;
8
5
  export declare function updateRelativePathsInConfig(tree: Tree, sourcePath: string, destinationPath: string): void;
@@ -1,29 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPluginImport = exports.addIgnoresToLintConfig = exports.addPluginsToLintConfig = exports.addExtendsToLintConfig = exports.replaceOverridesInLintConfig = exports.lintConfigHasOverride = exports.updateOverrideInLintConfig = exports.addOverrideToLintConfig = exports.updateRelativePathsInConfig = exports.isEslintConfigSupported = exports.findEslintFile = exports.baseEsLintFlatConfigFile = exports.baseEsLintConfigFile = exports.eslintConfigFileWhitelist = void 0;
3
+ exports.getPluginImport = exports.addIgnoresToLintConfig = exports.addPluginsToLintConfig = exports.addExtendsToLintConfig = exports.replaceOverridesInLintConfig = exports.lintConfigHasOverride = exports.updateOverrideInLintConfig = exports.addOverrideToLintConfig = exports.updateRelativePathsInConfig = exports.isEslintConfigSupported = exports.findEslintFile = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const flat_config_1 = require("../../utils/flat-config");
6
6
  const ast_utils_1 = require("./flat-config/ast-utils");
7
7
  const path_utils_1 = require("./flat-config/path-utils");
8
- exports.eslintConfigFileWhitelist = [
9
- '.eslintrc',
10
- '.eslintrc.js',
11
- '.eslintrc.cjs',
12
- '.eslintrc.yaml',
13
- '.eslintrc.yml',
14
- '.eslintrc.json',
15
- 'eslint.config.js',
16
- ];
17
- exports.baseEsLintConfigFile = '.eslintrc.base.json';
18
- exports.baseEsLintFlatConfigFile = 'eslint.base.config.js';
19
- function findEslintFile(tree, projectRoot = '') {
20
- if (projectRoot === '' && tree.exists(exports.baseEsLintConfigFile)) {
21
- return exports.baseEsLintConfigFile;
8
+ const config_file_1 = require("../../utils/config-file");
9
+ function findEslintFile(tree, projectRoot) {
10
+ if (projectRoot === undefined && tree.exists(config_file_1.baseEsLintConfigFile)) {
11
+ return config_file_1.baseEsLintConfigFile;
22
12
  }
23
- if (projectRoot === '' && tree.exists(exports.baseEsLintFlatConfigFile)) {
24
- return exports.baseEsLintFlatConfigFile;
13
+ if (projectRoot === undefined && tree.exists(config_file_1.baseEsLintFlatConfigFile)) {
14
+ return config_file_1.baseEsLintFlatConfigFile;
25
15
  }
26
- for (const file of exports.eslintConfigFileWhitelist) {
16
+ projectRoot ??= '';
17
+ for (const file of config_file_1.ESLINT_CONFIG_FILENAMES) {
27
18
  if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, file))) {
28
19
  return file;
29
20
  }
@@ -94,7 +85,7 @@ function replaceFlatConfigPaths(config, sourceRoot, offset, destinationRoot, tre
94
85
  return newConfig;
95
86
  }
96
87
  function offsetFilePath(projectRoot, pathToFile, offset, tree) {
97
- if (exports.eslintConfigFileWhitelist.some((eslintFile) => pathToFile.includes(eslintFile))) {
88
+ if (config_file_1.ESLINT_CONFIG_FILENAMES.some((eslintFile) => pathToFile.includes(eslintFile))) {
98
89
  // if the file is point to base eslint
99
90
  const rootEslint = findEslintFile(tree);
100
91
  if (rootEslint) {
@@ -112,7 +103,7 @@ function addOverrideToLintConfig(tree, root, override, options = {
112
103
  }) {
113
104
  const isBase = options.checkBaseConfig && findEslintFile(tree, root).includes('.base');
114
105
  if ((0, flat_config_1.useFlatConfig)(tree)) {
115
- const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? exports.baseEsLintFlatConfigFile : 'eslint.config.js');
106
+ const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? config_file_1.baseEsLintFlatConfigFile : 'eslint.config.js');
116
107
  const flatOverride = (0, ast_utils_1.generateFlatOverride)(override);
117
108
  let content = tree.read(fileName, 'utf8');
118
109
  // we will be using compat here so we need to make sure it's added
@@ -122,7 +113,7 @@ function addOverrideToLintConfig(tree, root, override, options = {
122
113
  tree.write(fileName, (0, ast_utils_1.addBlockToFlatConfigExport)(content, flatOverride, options));
123
114
  }
124
115
  else {
125
- const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? exports.baseEsLintConfigFile : '.eslintrc.json');
116
+ const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? config_file_1.baseEsLintConfigFile : '.eslintrc.json');
126
117
  (0, devkit_1.updateJson)(tree, fileName, (json) => {
127
118
  json.overrides ??= [];
128
119
  if (options.insertAtTheEnd) {
@@ -164,12 +155,12 @@ function lintConfigHasOverride(tree, root, lookup, checkBaseConfig = false) {
164
155
  }
165
156
  const isBase = checkBaseConfig && findEslintFile(tree, root).includes('.base');
166
157
  if ((0, flat_config_1.useFlatConfig)(tree)) {
167
- const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? exports.baseEsLintFlatConfigFile : 'eslint.config.js');
158
+ const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? config_file_1.baseEsLintFlatConfigFile : 'eslint.config.js');
168
159
  const content = tree.read(fileName, 'utf8');
169
160
  return (0, ast_utils_1.hasOverride)(content, lookup);
170
161
  }
171
162
  else {
172
- const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? exports.baseEsLintConfigFile : '.eslintrc.json');
163
+ const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? config_file_1.baseEsLintConfigFile : '.eslintrc.json');
173
164
  return (0, devkit_1.readJson)(tree, fileName).overrides?.some(lookup) || false;
174
165
  }
175
166
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devkit_1 = require("@nx/devkit");
4
- const eslint_file_1 = require("../../generators/utils/eslint-file");
5
4
  const eslint_targets_1 = require("../../generators/utils/eslint-targets");
5
+ const config_file_1 = require("../../utils/config-file");
6
6
  async function addEslintInputs(tree) {
7
7
  const nxJson = (0, devkit_1.readNxJson)(tree);
8
- const globalEslintFile = eslint_file_1.eslintConfigFileWhitelist.find((file) => tree.exists(file));
8
+ const globalEslintFile = config_file_1.ESLINT_CONFIG_FILENAMES.find((file) => tree.exists(file));
9
9
  if (globalEslintFile && nxJson.namedInputs?.production) {
10
10
  const productionFileset = new Set(nxJson.namedInputs.production);
11
11
  productionFileset.add(`!{projectRoot}/${globalEslintFile}`);
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devkit_1 = require("@nx/devkit");
4
- const eslint_file_1 = require("../../generators/utils/eslint-file");
5
4
  const eslint_targets_1 = require("../../generators/utils/eslint-targets");
5
+ const config_file_1 = require("../../utils/config-file");
6
6
  async function addEslintIgnore(tree) {
7
7
  const nxJson = (0, devkit_1.readJson)(tree, 'nx.json');
8
- const globalEslintFile = eslint_file_1.eslintConfigFileWhitelist.find((file) => tree.exists(file));
8
+ const globalEslintFile = config_file_1.ESLINT_CONFIG_FILENAMES.find((file) => tree.exists(file));
9
9
  if (globalEslintFile) {
10
10
  if (tree.exists('.eslintignore')) {
11
11
  const content = tree.read('.eslintignore', 'utf-8');
@@ -0,0 +1,5 @@
1
+ import { CreateNodes } from '@nx/devkit';
2
+ export interface EslintPluginOptions {
3
+ targetName?: string;
4
+ }
5
+ export declare const createNodes: CreateNodes<EslintPluginOptions>;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNodes = void 0;
4
+ const path_1 = require("path");
5
+ const project_configuration_utils_1 = require("nx/src/project-graph/utils/project-configuration-utils");
6
+ const fs_1 = require("fs");
7
+ const globs_1 = require("nx/src/utils/globs");
8
+ const config_file_1 = require("../utils/config-file");
9
+ exports.createNodes = [
10
+ (0, globs_1.combineGlobPatterns)(['**/project.json', '**/package.json']),
11
+ (configFilePath, options, context) => {
12
+ const projectRoot = (0, path_1.dirname)(configFilePath);
13
+ options = normalizeOptions(options);
14
+ const eslintConfigs = getEslintConfigsForProject(projectRoot, context.workspaceRoot);
15
+ if (!eslintConfigs.length) {
16
+ return {};
17
+ }
18
+ return {
19
+ projects: {
20
+ [projectRoot]: {
21
+ targets: buildEslintTargets(eslintConfigs, projectRoot, options, context),
22
+ },
23
+ },
24
+ };
25
+ },
26
+ ];
27
+ function getEslintConfigsForProject(projectRoot, workspaceRoot) {
28
+ const detectedConfigs = new Set();
29
+ const baseConfig = (0, config_file_1.findBaseEslintFile)(workspaceRoot);
30
+ if (baseConfig) {
31
+ detectedConfigs.add(baseConfig);
32
+ }
33
+ let siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(workspaceRoot, projectRoot));
34
+ if (projectRoot === '.') {
35
+ // If there's no src folder, it's not a standalone project
36
+ if (!siblingFiles.includes('src')) {
37
+ return [];
38
+ }
39
+ // If it's standalone but doesn't have eslint config, it's not a lintable
40
+ const config = siblingFiles.find((f) => config_file_1.ESLINT_CONFIG_FILENAMES.includes(f));
41
+ if (!config) {
42
+ return [];
43
+ }
44
+ detectedConfigs.add(config);
45
+ return Array.from(detectedConfigs);
46
+ }
47
+ while (projectRoot !== '.') {
48
+ // if it has an eslint config it's lintable
49
+ const config = siblingFiles.find((f) => config_file_1.ESLINT_CONFIG_FILENAMES.includes(f));
50
+ if (config) {
51
+ detectedConfigs.add(`${projectRoot}/${config}`);
52
+ return Array.from(detectedConfigs);
53
+ }
54
+ projectRoot = (0, path_1.dirname)(projectRoot);
55
+ siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(workspaceRoot, projectRoot));
56
+ }
57
+ // check whether the root has an eslint config
58
+ const config = (0, fs_1.readdirSync)(workspaceRoot).find((f) => config_file_1.ESLINT_CONFIG_FILENAMES.includes(f));
59
+ if (config) {
60
+ detectedConfigs.add(config);
61
+ return Array.from(detectedConfigs);
62
+ }
63
+ return [];
64
+ }
65
+ function buildEslintTargets(eslintConfigs, projectRoot, options, context) {
66
+ const targetDefaults = (0, project_configuration_utils_1.readTargetDefaultsForTarget)(options.targetName, context.nxJsonConfiguration.targetDefaults, '@nx/eslint:lint');
67
+ const isRootProject = projectRoot === '.';
68
+ const targets = {};
69
+ const baseTargetConfig = {
70
+ command: `eslint ${isRootProject ? './src' : '.'}`,
71
+ options: {
72
+ cwd: projectRoot,
73
+ },
74
+ };
75
+ if (eslintConfigs.some((config) => (0, config_file_1.isFlatConfig)(config))) {
76
+ baseTargetConfig.options.env = {
77
+ ESLINT_USE_FLAT_CONFIG: 'true',
78
+ };
79
+ }
80
+ targets[options.targetName] = {
81
+ ...baseTargetConfig,
82
+ cache: targetDefaults?.cache ?? true,
83
+ inputs: targetDefaults?.inputs ?? [
84
+ 'default',
85
+ ...eslintConfigs.map((config) => `{workspaceRoot}/${config}`),
86
+ '{workspaceRoot}/tools/eslint-rules/**/*',
87
+ { externalDependencies: ['eslint'] },
88
+ ],
89
+ options: {
90
+ ...baseTargetConfig.options,
91
+ },
92
+ };
93
+ return targets;
94
+ }
95
+ function normalizeOptions(options) {
96
+ options ??= {};
97
+ options.targetName ??= 'lint';
98
+ return options;
99
+ }
@@ -0,0 +1,5 @@
1
+ export declare const ESLINT_CONFIG_FILENAMES: string[];
2
+ export declare const baseEsLintConfigFile = ".eslintrc.base.json";
3
+ export declare const baseEsLintFlatConfigFile = "eslint.base.config.js";
4
+ export declare function findBaseEslintFile(workspaceRoot?: string): string | null;
5
+ export declare function isFlatConfig(configFilePath: string): boolean;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFlatConfig = exports.findBaseEslintFile = exports.baseEsLintFlatConfigFile = exports.baseEsLintConfigFile = exports.ESLINT_CONFIG_FILENAMES = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const fs_1 = require("fs");
6
+ exports.ESLINT_CONFIG_FILENAMES = [
7
+ '.eslintrc',
8
+ '.eslintrc.js',
9
+ '.eslintrc.cjs',
10
+ '.eslintrc.yaml',
11
+ '.eslintrc.yml',
12
+ '.eslintrc.json',
13
+ 'eslint.config.js',
14
+ ];
15
+ exports.baseEsLintConfigFile = '.eslintrc.base.json';
16
+ exports.baseEsLintFlatConfigFile = 'eslint.base.config.js';
17
+ function findBaseEslintFile(workspaceRoot = '') {
18
+ if ((0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(workspaceRoot, exports.baseEsLintConfigFile))) {
19
+ return exports.baseEsLintConfigFile;
20
+ }
21
+ if ((0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(workspaceRoot, exports.baseEsLintFlatConfigFile))) {
22
+ return exports.baseEsLintFlatConfigFile;
23
+ }
24
+ for (const file of exports.ESLINT_CONFIG_FILENAMES) {
25
+ if ((0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(workspaceRoot, file))) {
26
+ return file;
27
+ }
28
+ }
29
+ return null;
30
+ }
31
+ exports.findBaseEslintFile = findBaseEslintFile;
32
+ function isFlatConfig(configFilePath) {
33
+ return configFilePath.endsWith('.config.js');
34
+ }
35
+ exports.isFlatConfig = isFlatConfig;