@nx/eslint 0.0.0-pr-22179-271588f

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.
Files changed (86) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +66 -0
  3. package/executors.json +10 -0
  4. package/generators.json +28 -0
  5. package/index.d.ts +4 -0
  6. package/index.js +14 -0
  7. package/migrations.json +138 -0
  8. package/package.json +52 -0
  9. package/plugin.d.ts +1 -0
  10. package/plugin.js +5 -0
  11. package/src/executors/lint/hasher.d.ts +9 -0
  12. package/src/executors/lint/hasher.js +43 -0
  13. package/src/executors/lint/lint.impl.d.ts +5 -0
  14. package/src/executors/lint/lint.impl.js +174 -0
  15. package/src/executors/lint/schema.d.ts +40 -0
  16. package/src/executors/lint/schema.json +148 -0
  17. package/src/executors/lint/utility/eslint-utils.d.ts +6 -0
  18. package/src/executors/lint/utility/eslint-utils.js +75 -0
  19. package/src/generators/convert-to-flat-config/converters/json-converter.d.ts +11 -0
  20. package/src/generators/convert-to-flat-config/converters/json-converter.js +175 -0
  21. package/src/generators/convert-to-flat-config/generator.d.ts +4 -0
  22. package/src/generators/convert-to-flat-config/generator.js +139 -0
  23. package/src/generators/convert-to-flat-config/schema.d.ts +3 -0
  24. package/src/generators/convert-to-flat-config/schema.json +17 -0
  25. package/src/generators/init/global-eslint-config.d.ts +29 -0
  26. package/src/generators/init/global-eslint-config.js +102 -0
  27. package/src/generators/init/init-migration.d.ts +3 -0
  28. package/src/generators/init/init-migration.js +137 -0
  29. package/src/generators/init/init.d.ts +9 -0
  30. package/src/generators/init/init.js +93 -0
  31. package/src/generators/init/schema.json +28 -0
  32. package/src/generators/lint-project/lint-project.d.ts +22 -0
  33. package/src/generators/lint-project/lint-project.js +227 -0
  34. package/src/generators/lint-project/setup-root-eslint.d.ts +7 -0
  35. package/src/generators/lint-project/setup-root-eslint.js +33 -0
  36. package/src/generators/utils/eslint-file.d.ts +16 -0
  37. package/src/generators/utils/eslint-file.js +287 -0
  38. package/src/generators/utils/eslint-targets.d.ts +2 -0
  39. package/src/generators/utils/eslint-targets.js +18 -0
  40. package/src/generators/utils/flat-config/ast-utils.d.ts +60 -0
  41. package/src/generators/utils/flat-config/ast-utils.js +573 -0
  42. package/src/generators/utils/flat-config/path-utils.d.ts +3 -0
  43. package/src/generators/utils/flat-config/path-utils.js +28 -0
  44. package/src/generators/utils/linter.d.ts +4 -0
  45. package/src/generators/utils/linter.js +8 -0
  46. package/src/generators/utils/plugin.d.ts +2 -0
  47. package/src/generators/utils/plugin.js +11 -0
  48. package/src/generators/workspace-rule/files/__name__.spec.ts__tmpl__ +11 -0
  49. package/src/generators/workspace-rule/files/__name__.ts__tmpl__ +37 -0
  50. package/src/generators/workspace-rule/schema.json +26 -0
  51. package/src/generators/workspace-rule/workspace-rule.d.ts +6 -0
  52. package/src/generators/workspace-rule/workspace-rule.js +78 -0
  53. package/src/generators/workspace-rules-project/files/index.ts__tmpl__ +27 -0
  54. package/src/generators/workspace-rules-project/files/tsconfig.json__tmpl__ +14 -0
  55. package/src/generators/workspace-rules-project/files/tsconfig.lint.json__tmpl__ +9 -0
  56. package/src/generators/workspace-rules-project/schema.json +23 -0
  57. package/src/generators/workspace-rules-project/workspace-rules-project.d.ts +8 -0
  58. package/src/generators/workspace-rules-project/workspace-rules-project.js +82 -0
  59. package/src/migrations/update-15-0-0/add-eslint-inputs.d.ts +2 -0
  60. package/src/migrations/update-15-0-0/add-eslint-inputs.js +27 -0
  61. package/src/migrations/update-15-7-1/add-eslint-ignore.d.ts +2 -0
  62. package/src/migrations/update-15-7-1/add-eslint-ignore.js +36 -0
  63. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  64. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  65. package/src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files.d.ts +2 -0
  66. package/src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files.js +44 -0
  67. package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.d.ts +2 -0
  68. package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.js +47 -0
  69. package/src/migrations/update-17-1-0/update-typescript-eslint.d.ts +2 -0
  70. package/src/migrations/update-17-1-0/update-typescript-eslint.js +74 -0
  71. package/src/migrations/update-17-2-0/simplify-eslint-patterns.d.ts +2 -0
  72. package/src/migrations/update-17-2-0/simplify-eslint-patterns.js +46 -0
  73. package/src/migrations/update-17-2-9/move-options-to-target-defaults.d.ts +2 -0
  74. package/src/migrations/update-17-2-9/move-options-to-target-defaults.js +107 -0
  75. package/src/plugins/plugin.d.ts +5 -0
  76. package/src/plugins/plugin.js +92 -0
  77. package/src/utils/config-file.d.ts +5 -0
  78. package/src/utils/config-file.js +35 -0
  79. package/src/utils/flat-config.d.ts +2 -0
  80. package/src/utils/flat-config.js +7 -0
  81. package/src/utils/rules-requiring-type-checking.d.ts +3 -0
  82. package/src/utils/rules-requiring-type-checking.js +84 -0
  83. package/src/utils/versions.d.ts +5 -0
  84. package/src/utils/versions.js +8 -0
  85. package/src/utils/workspace-lint-rules.d.ts +1 -0
  86. package/src/utils/workspace-lint-rules.js +5 -0
@@ -0,0 +1,16 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ import type { Linter } from 'eslint';
3
+ export declare function findEslintFile(tree: Tree, projectRoot?: string): string | null;
4
+ export declare function isEslintConfigSupported(tree: Tree, projectRoot?: string): boolean;
5
+ export declare function updateRelativePathsInConfig(tree: Tree, sourcePath: string, destinationPath: string): void;
6
+ export declare function addOverrideToLintConfig(tree: Tree, root: string, override: Linter.ConfigOverride<Linter.RulesRecord>, options?: {
7
+ insertAtTheEnd?: boolean;
8
+ checkBaseConfig?: boolean;
9
+ }): void;
10
+ export declare function updateOverrideInLintConfig(tree: Tree, root: string, lookup: (override: Linter.ConfigOverride<Linter.RulesRecord>) => boolean, update: (override: Linter.ConfigOverride<Linter.RulesRecord>) => Linter.ConfigOverride<Linter.RulesRecord>): void;
11
+ export declare function lintConfigHasOverride(tree: Tree, root: string, lookup: (override: Linter.ConfigOverride<Linter.RulesRecord>) => boolean, checkBaseConfig?: boolean): boolean;
12
+ export declare function replaceOverridesInLintConfig(tree: Tree, root: string, overrides: Linter.ConfigOverride<Linter.RulesRecord>[]): void;
13
+ export declare function addExtendsToLintConfig(tree: Tree, root: string, plugin: string | string[]): void;
14
+ export declare function addPluginsToLintConfig(tree: Tree, root: string, plugin: string | string[]): void;
15
+ export declare function addIgnoresToLintConfig(tree: Tree, root: string, ignorePatterns: string[]): void;
16
+ export declare function getPluginImport(pluginName: string): string;
@@ -0,0 +1,287 @@
1
+ "use strict";
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 = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const flat_config_1 = require("../../utils/flat-config");
6
+ const ast_utils_1 = require("./flat-config/ast-utils");
7
+ const path_utils_1 = require("./flat-config/path-utils");
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;
12
+ }
13
+ if (projectRoot === undefined && tree.exists(config_file_1.baseEsLintFlatConfigFile)) {
14
+ return config_file_1.baseEsLintFlatConfigFile;
15
+ }
16
+ projectRoot ??= '';
17
+ for (const file of config_file_1.ESLINT_CONFIG_FILENAMES) {
18
+ if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, file))) {
19
+ return file;
20
+ }
21
+ }
22
+ return null;
23
+ }
24
+ exports.findEslintFile = findEslintFile;
25
+ function isEslintConfigSupported(tree, projectRoot = '') {
26
+ const eslintFile = findEslintFile(tree, projectRoot);
27
+ if (!eslintFile) {
28
+ return false;
29
+ }
30
+ return eslintFile.endsWith('.json') || eslintFile.endsWith('.config.js');
31
+ }
32
+ exports.isEslintConfigSupported = isEslintConfigSupported;
33
+ function updateRelativePathsInConfig(tree, sourcePath, destinationPath) {
34
+ if (sourcePath === destinationPath ||
35
+ !isEslintConfigSupported(tree, destinationPath)) {
36
+ return;
37
+ }
38
+ const configPath = (0, devkit_1.joinPathFragments)(destinationPath, findEslintFile(tree, destinationPath));
39
+ const offset = (0, devkit_1.offsetFromRoot)(destinationPath);
40
+ if ((0, flat_config_1.useFlatConfig)(tree)) {
41
+ const config = tree.read(configPath, 'utf-8');
42
+ tree.write(configPath, replaceFlatConfigPaths(config, sourcePath, offset, destinationPath, tree));
43
+ }
44
+ else {
45
+ (0, devkit_1.updateJson)(tree, configPath, (json) => {
46
+ if (typeof json.extends === 'string') {
47
+ json.extends = offsetFilePath(sourcePath, json.extends, offset, tree);
48
+ }
49
+ else if (json.extends) {
50
+ json.extends = json.extends.map((extend) => offsetFilePath(sourcePath, extend, offset, tree));
51
+ }
52
+ json.overrides?.forEach((o) => {
53
+ if (o.parserOptions?.project) {
54
+ o.parserOptions.project = Array.isArray(o.parserOptions.project)
55
+ ? o.parserOptions.project.map((p) => p.replace(sourcePath, destinationPath))
56
+ : o.parserOptions.project.replace(sourcePath, destinationPath);
57
+ }
58
+ });
59
+ return json;
60
+ });
61
+ }
62
+ }
63
+ exports.updateRelativePathsInConfig = updateRelativePathsInConfig;
64
+ function replaceFlatConfigPaths(config, sourceRoot, offset, destinationRoot, tree) {
65
+ let match;
66
+ let newConfig = config;
67
+ // replace requires
68
+ const requireRegex = RegExp(/require\(['"](.*)['"]\)/g);
69
+ while ((match = requireRegex.exec(newConfig)) !== null) {
70
+ const newPath = offsetFilePath(sourceRoot, match[1], offset, tree);
71
+ newConfig =
72
+ newConfig.slice(0, match.index) +
73
+ `require('${newPath}')` +
74
+ newConfig.slice(match.index + match[0].length);
75
+ }
76
+ // replace projects
77
+ const projectRegex = RegExp(/project:\s?\[?['"](.*)['"]\]?/g);
78
+ while ((match = projectRegex.exec(newConfig)) !== null) {
79
+ const newProjectDef = match[0].replaceAll(sourceRoot, destinationRoot);
80
+ newConfig =
81
+ newConfig.slice(0, match.index) +
82
+ newProjectDef +
83
+ newConfig.slice(match.index + match[0].length);
84
+ }
85
+ return newConfig;
86
+ }
87
+ function offsetFilePath(projectRoot, pathToFile, offset, tree) {
88
+ if (config_file_1.ESLINT_CONFIG_FILENAMES.some((eslintFile) => pathToFile.includes(eslintFile))) {
89
+ // if the file is point to base eslint
90
+ const rootEslint = findEslintFile(tree);
91
+ if (rootEslint) {
92
+ return (0, devkit_1.joinPathFragments)(offset, rootEslint);
93
+ }
94
+ }
95
+ if (!pathToFile.startsWith('..')) {
96
+ // not a relative path
97
+ return pathToFile;
98
+ }
99
+ return (0, devkit_1.joinPathFragments)(offset, projectRoot, pathToFile);
100
+ }
101
+ function addOverrideToLintConfig(tree, root, override, options = {
102
+ insertAtTheEnd: true,
103
+ }) {
104
+ const isBase = options.checkBaseConfig && findEslintFile(tree, root).includes('.base');
105
+ if ((0, flat_config_1.useFlatConfig)(tree)) {
106
+ const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? config_file_1.baseEsLintFlatConfigFile : 'eslint.config.js');
107
+ const flatOverride = (0, ast_utils_1.generateFlatOverride)(override);
108
+ let content = tree.read(fileName, 'utf8');
109
+ // we will be using compat here so we need to make sure it's added
110
+ if (overrideNeedsCompat(override)) {
111
+ content = (0, ast_utils_1.addCompatToFlatConfig)(content);
112
+ }
113
+ tree.write(fileName, (0, ast_utils_1.addBlockToFlatConfigExport)(content, flatOverride, options));
114
+ }
115
+ else {
116
+ const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? config_file_1.baseEsLintConfigFile : '.eslintrc.json');
117
+ (0, devkit_1.updateJson)(tree, fileName, (json) => {
118
+ json.overrides ??= [];
119
+ if (options.insertAtTheEnd) {
120
+ json.overrides.push(override);
121
+ }
122
+ else {
123
+ json.overrides.unshift(override);
124
+ }
125
+ return json;
126
+ });
127
+ }
128
+ }
129
+ exports.addOverrideToLintConfig = addOverrideToLintConfig;
130
+ function overrideNeedsCompat(override) {
131
+ return (override.env || override.extends || override.plugins || override.parser);
132
+ }
133
+ function updateOverrideInLintConfig(tree, root, lookup, update) {
134
+ if ((0, flat_config_1.useFlatConfig)(tree)) {
135
+ const fileName = (0, devkit_1.joinPathFragments)(root, 'eslint.config.js');
136
+ let content = tree.read(fileName, 'utf8');
137
+ content = (0, ast_utils_1.replaceOverride)(content, root, lookup, update);
138
+ tree.write(fileName, content);
139
+ }
140
+ else {
141
+ const fileName = (0, devkit_1.joinPathFragments)(root, '.eslintrc.json');
142
+ if (!tree.exists(fileName)) {
143
+ return;
144
+ }
145
+ const existingJson = (0, devkit_1.readJson)(tree, fileName);
146
+ if (!existingJson.overrides || !existingJson.overrides.some(lookup)) {
147
+ return;
148
+ }
149
+ (0, devkit_1.updateJson)(tree, fileName, (json) => {
150
+ const index = json.overrides.findIndex(lookup);
151
+ if (index !== -1) {
152
+ const newOverride = update(json.overrides[index]);
153
+ if (newOverride) {
154
+ json.overrides[index] = newOverride;
155
+ }
156
+ else {
157
+ json.overrides.splice(index, 1);
158
+ }
159
+ }
160
+ return json;
161
+ });
162
+ }
163
+ }
164
+ exports.updateOverrideInLintConfig = updateOverrideInLintConfig;
165
+ function lintConfigHasOverride(tree, root, lookup, checkBaseConfig = false) {
166
+ if (!isEslintConfigSupported(tree, root)) {
167
+ return false;
168
+ }
169
+ const isBase = checkBaseConfig && findEslintFile(tree, root).includes('.base');
170
+ if ((0, flat_config_1.useFlatConfig)(tree)) {
171
+ const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? config_file_1.baseEsLintFlatConfigFile : 'eslint.config.js');
172
+ const content = tree.read(fileName, 'utf8');
173
+ return (0, ast_utils_1.hasOverride)(content, lookup);
174
+ }
175
+ else {
176
+ const fileName = (0, devkit_1.joinPathFragments)(root, isBase ? config_file_1.baseEsLintConfigFile : '.eslintrc.json');
177
+ return (0, devkit_1.readJson)(tree, fileName).overrides?.some(lookup) || false;
178
+ }
179
+ }
180
+ exports.lintConfigHasOverride = lintConfigHasOverride;
181
+ function replaceOverridesInLintConfig(tree, root, overrides) {
182
+ if ((0, flat_config_1.useFlatConfig)(tree)) {
183
+ const fileName = (0, devkit_1.joinPathFragments)(root, 'eslint.config.js');
184
+ let content = tree.read(fileName, 'utf8');
185
+ // we will be using compat here so we need to make sure it's added
186
+ if (overrides.some(overrideNeedsCompat)) {
187
+ content = (0, ast_utils_1.addCompatToFlatConfig)(content);
188
+ }
189
+ content = (0, ast_utils_1.removeOverridesFromLintConfig)(content);
190
+ overrides.forEach((override) => {
191
+ const flatOverride = (0, ast_utils_1.generateFlatOverride)(override);
192
+ (0, ast_utils_1.addBlockToFlatConfigExport)(content, flatOverride);
193
+ });
194
+ tree.write(fileName, content);
195
+ }
196
+ else {
197
+ const fileName = (0, devkit_1.joinPathFragments)(root, '.eslintrc.json');
198
+ (0, devkit_1.updateJson)(tree, fileName, (json) => {
199
+ json.overrides = overrides;
200
+ return json;
201
+ });
202
+ }
203
+ }
204
+ exports.replaceOverridesInLintConfig = replaceOverridesInLintConfig;
205
+ function addExtendsToLintConfig(tree, root, plugin) {
206
+ const plugins = Array.isArray(plugin) ? plugin : [plugin];
207
+ if ((0, flat_config_1.useFlatConfig)(tree)) {
208
+ const fileName = (0, devkit_1.joinPathFragments)(root, 'eslint.config.js');
209
+ const pluginExtends = (0, ast_utils_1.generatePluginExtendsElement)(plugins);
210
+ let content = tree.read(fileName, 'utf8');
211
+ content = (0, ast_utils_1.addCompatToFlatConfig)(content);
212
+ tree.write(fileName, (0, ast_utils_1.addBlockToFlatConfigExport)(content, pluginExtends));
213
+ }
214
+ else {
215
+ const fileName = (0, devkit_1.joinPathFragments)(root, '.eslintrc.json');
216
+ (0, devkit_1.updateJson)(tree, fileName, (json) => {
217
+ json.extends ??= [];
218
+ json.extends = [
219
+ ...plugins,
220
+ ...(Array.isArray(json.extends) ? json.extends : [json.extends]),
221
+ ];
222
+ return json;
223
+ });
224
+ }
225
+ }
226
+ exports.addExtendsToLintConfig = addExtendsToLintConfig;
227
+ function addPluginsToLintConfig(tree, root, plugin) {
228
+ const plugins = Array.isArray(plugin) ? plugin : [plugin];
229
+ if ((0, flat_config_1.useFlatConfig)(tree)) {
230
+ const fileName = (0, devkit_1.joinPathFragments)(root, 'eslint.config.js');
231
+ let content = tree.read(fileName, 'utf8');
232
+ const mappedPlugins = [];
233
+ plugins.forEach((name) => {
234
+ const imp = getPluginImport(name);
235
+ const varName = (0, devkit_1.names)(imp).propertyName;
236
+ mappedPlugins.push({ name, varName, imp });
237
+ });
238
+ mappedPlugins.forEach(({ varName, imp }) => {
239
+ content = (0, ast_utils_1.addImportToFlatConfig)(content, varName, imp);
240
+ });
241
+ content = (0, ast_utils_1.addPluginsToExportsBlock)(content, mappedPlugins);
242
+ tree.write(fileName, content);
243
+ }
244
+ else {
245
+ const fileName = (0, devkit_1.joinPathFragments)(root, '.eslintrc.json');
246
+ (0, devkit_1.updateJson)(tree, fileName, (json) => {
247
+ json.plugins = [...plugins, ...(json.plugins ?? [])];
248
+ return json;
249
+ });
250
+ }
251
+ }
252
+ exports.addPluginsToLintConfig = addPluginsToLintConfig;
253
+ function addIgnoresToLintConfig(tree, root, ignorePatterns) {
254
+ if ((0, flat_config_1.useFlatConfig)(tree)) {
255
+ const fileName = (0, devkit_1.joinPathFragments)(root, 'eslint.config.js');
256
+ const block = (0, ast_utils_1.generateAst)({
257
+ ignores: ignorePatterns.map((path) => (0, path_utils_1.mapFilePath)(path)),
258
+ });
259
+ tree.write(fileName, (0, ast_utils_1.addBlockToFlatConfigExport)(tree.read(fileName, 'utf8'), block));
260
+ }
261
+ else {
262
+ const fileName = (0, devkit_1.joinPathFragments)(root, '.eslintrc.json');
263
+ (0, devkit_1.updateJson)(tree, fileName, (json) => {
264
+ const ignoreSet = new Set([
265
+ ...(json.ignorePatterns ?? []),
266
+ ...ignorePatterns,
267
+ ]);
268
+ json.ignorePatterns = Array.from(ignoreSet);
269
+ return json;
270
+ });
271
+ }
272
+ }
273
+ exports.addIgnoresToLintConfig = addIgnoresToLintConfig;
274
+ function getPluginImport(pluginName) {
275
+ if (pluginName.includes('eslint-plugin-')) {
276
+ return pluginName;
277
+ }
278
+ if (!pluginName.startsWith('@')) {
279
+ return `eslint-plugin-${pluginName}`;
280
+ }
281
+ if (!pluginName.includes('/')) {
282
+ return `${pluginName}/eslint-plugin`;
283
+ }
284
+ const [scope, name] = pluginName.split('/');
285
+ return `${scope}/eslint-plugin-${name}`;
286
+ }
287
+ exports.getPluginImport = getPluginImport;
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function getEslintTargets(tree: Tree): Set<string>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEslintTargets = void 0;
4
+ const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
5
+ function getEslintTargets(tree) {
6
+ const eslintTargetNames = new Set();
7
+ (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/eslint:lint', (_, __, target) => {
8
+ eslintTargetNames.add(target);
9
+ });
10
+ (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/linter:eslint', (_, __, target) => {
11
+ eslintTargetNames.add(target);
12
+ });
13
+ (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/linter:eslint', (_, __, target) => {
14
+ eslintTargetNames.add(target);
15
+ });
16
+ return eslintTargetNames;
17
+ }
18
+ exports.getEslintTargets = getEslintTargets;
@@ -0,0 +1,60 @@
1
+ import { Linter } from 'eslint';
2
+ import * as ts from 'typescript';
3
+ /**
4
+ * Remove all overrides from the config file
5
+ */
6
+ export declare function removeOverridesFromLintConfig(content: string): string;
7
+ export declare function hasOverride(content: string, lookup: (override: Linter.ConfigOverride<Linter.RulesRecord>) => boolean): boolean;
8
+ /**
9
+ * Finds an override matching the lookup function and applies the update function to it
10
+ */
11
+ export declare function replaceOverride(content: string, root: string, lookup: (override: Linter.ConfigOverride<Linter.RulesRecord>) => boolean, update?: (override: Linter.ConfigOverride<Linter.RulesRecord>) => Linter.ConfigOverride<Linter.RulesRecord>): string;
12
+ /**
13
+ * Adding require statement to the top of the file
14
+ */
15
+ export declare function addImportToFlatConfig(content: string, variable: string | string[], imp: string): string;
16
+ /**
17
+ * Injects new ts.expression to the end of the module.exports array.
18
+ */
19
+ export declare function addBlockToFlatConfigExport(content: string, config: ts.Expression | ts.SpreadElement, options?: {
20
+ insertAtTheEnd?: boolean;
21
+ checkBaseConfig?: boolean;
22
+ }): string;
23
+ export declare function removePlugin(content: string, pluginName: string, pluginImport: string): string;
24
+ export declare function removeCompatExtends(content: string, compatExtends: string[]): string;
25
+ /**
26
+ * Add plugins block to the top of the export blocks
27
+ */
28
+ export declare function addPluginsToExportsBlock(content: string, plugins: {
29
+ name: string;
30
+ varName: string;
31
+ imp: string;
32
+ }[]): string;
33
+ /**
34
+ * Adds compat if missing to flat config
35
+ */
36
+ export declare function addCompatToFlatConfig(content: string): string;
37
+ /**
38
+ * Generate node list representing the imports and the exports blocks
39
+ * Optionally add flat compat initialization
40
+ */
41
+ export declare function createNodeList(importsMap: Map<string, string>, exportElements: ts.Expression[], isFlatCompatNeeded: boolean): ts.NodeArray<ts.VariableStatement | ts.Identifier | ts.ExpressionStatement | ts.SourceFile>;
42
+ export declare function generateSpreadElement(name: string): ts.SpreadElement;
43
+ export declare function generatePluginExtendsElement(plugins: string[]): ts.SpreadElement;
44
+ /**
45
+ * Stringifies TS nodes to file content string
46
+ */
47
+ export declare function stringifyNodeList(nodes: ts.NodeArray<ts.VariableStatement | ts.Identifier | ts.ExpressionStatement | ts.SourceFile>): string;
48
+ /**
49
+ * generates AST require statement
50
+ */
51
+ export declare function generateRequire(variableName: string | ts.ObjectBindingPattern, imp: string): ts.VariableStatement;
52
+ /**
53
+ * Generates AST object or spread element based on JSON override object
54
+ */
55
+ export declare function generateFlatOverride(override: Linter.ConfigOverride<Linter.RulesRecord>): ts.ObjectLiteralExpression | ts.SpreadElement;
56
+ export declare function mapFilePaths(override: Linter.ConfigOverride<Linter.RulesRecord>): void;
57
+ /**
58
+ * Generates an AST from a JSON-type input
59
+ */
60
+ export declare function generateAst<T>(input: unknown): T;