@nrwl/linter 16.0.0-beta.0 → 16.0.0-beta.1

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 (110) hide show
  1. package/executors.json +5 -5
  2. package/generators.json +2 -28
  3. package/index.d.ts +1 -5
  4. package/index.js +1 -13
  5. package/index.js.map +1 -1
  6. package/package.json +7 -20
  7. package/README.md +0 -61
  8. package/migrations.json +0 -226
  9. package/src/executors/eslint/compat.d.ts +0 -2
  10. package/src/executors/eslint/compat.js +0 -6
  11. package/src/executors/eslint/compat.js.map +0 -1
  12. package/src/executors/eslint/hasher.d.ts +0 -7
  13. package/src/executors/eslint/hasher.js +0 -47
  14. package/src/executors/eslint/hasher.js.map +0 -1
  15. package/src/executors/eslint/lint.impl.d.ts +0 -5
  16. package/src/executors/eslint/lint.impl.js +0 -116
  17. package/src/executors/eslint/lint.impl.js.map +0 -1
  18. package/src/executors/eslint/schema.d.ts +0 -38
  19. package/src/executors/eslint/schema.json +0 -139
  20. package/src/executors/eslint/utility/eslint-utils.d.ts +0 -4
  21. package/src/executors/eslint/utility/eslint-utils.js +0 -52
  22. package/src/executors/eslint/utility/eslint-utils.js.map +0 -1
  23. package/src/generators/init/global-eslint-config.d.ts +0 -36
  24. package/src/generators/init/global-eslint-config.js +0 -77
  25. package/src/generators/init/global-eslint-config.js.map +0 -1
  26. package/src/generators/init/init-migration.d.ts +0 -3
  27. package/src/generators/init/init-migration.js +0 -68
  28. package/src/generators/init/init-migration.js.map +0 -1
  29. package/src/generators/init/init.d.ts +0 -9
  30. package/src/generators/init/init.js +0 -63
  31. package/src/generators/init/init.js.map +0 -1
  32. package/src/generators/lint-project/lint-project.d.ts +0 -16
  33. package/src/generators/lint-project/lint-project.js +0 -137
  34. package/src/generators/lint-project/lint-project.js.map +0 -1
  35. package/src/generators/utils/eslint-file.d.ts +0 -4
  36. package/src/generators/utils/eslint-file.js +0 -27
  37. package/src/generators/utils/eslint-file.js.map +0 -1
  38. package/src/generators/utils/eslint-targets.d.ts +0 -2
  39. package/src/generators/utils/eslint-targets.js +0 -13
  40. package/src/generators/utils/eslint-targets.js.map +0 -1
  41. package/src/generators/utils/linter.d.ts +0 -4
  42. package/src/generators/utils/linter.js +0 -9
  43. package/src/generators/utils/linter.js.map +0 -1
  44. package/src/generators/workspace-rule/files/__name__.spec.ts__tmpl__ +0 -11
  45. package/src/generators/workspace-rule/files/__name__.ts__tmpl__ +0 -37
  46. package/src/generators/workspace-rule/schema.json +0 -26
  47. package/src/generators/workspace-rule/workspace-rule.d.ts +0 -7
  48. package/src/generators/workspace-rule/workspace-rule.js +0 -79
  49. package/src/generators/workspace-rule/workspace-rule.js.map +0 -1
  50. package/src/generators/workspace-rules-project/files/index.ts__tmpl__ +0 -27
  51. package/src/generators/workspace-rules-project/files/tsconfig.json__tmpl__ +0 -13
  52. package/src/generators/workspace-rules-project/files/tsconfig.lint.json__tmpl__ +0 -9
  53. package/src/generators/workspace-rules-project/schema.json +0 -23
  54. package/src/generators/workspace-rules-project/workspace-rules-project.d.ts +0 -8
  55. package/src/generators/workspace-rules-project/workspace-rules-project.js +0 -86
  56. package/src/generators/workspace-rules-project/workspace-rules-project.js.map +0 -1
  57. package/src/migrations/update-12-4-0/remove-eslint-project-config-if-no-type-checking-rules.d.ts +0 -2
  58. package/src/migrations/update-12-4-0/remove-eslint-project-config-if-no-type-checking-rules.js +0 -32
  59. package/src/migrations/update-12-4-0/remove-eslint-project-config-if-no-type-checking-rules.js.map +0 -1
  60. package/src/migrations/update-12-9-0/add-outputs.d.ts +0 -2
  61. package/src/migrations/update-12-9-0/add-outputs.js +0 -23
  62. package/src/migrations/update-12-9-0/add-outputs.js.map +0 -1
  63. package/src/migrations/update-13-3-0/eslint-8-updates.d.ts +0 -2
  64. package/src/migrations/update-13-3-0/eslint-8-updates.js +0 -44
  65. package/src/migrations/update-13-3-0/eslint-8-updates.js.map +0 -1
  66. package/src/migrations/update-14-1-9/add-swc-deps-if-needed.d.ts +0 -2
  67. package/src/migrations/update-14-1-9/add-swc-deps-if-needed.js +0 -20
  68. package/src/migrations/update-14-1-9/add-swc-deps-if-needed.js.map +0 -1
  69. package/src/migrations/update-14-4-4/experimental-to-utils-deps.d.ts +0 -2
  70. package/src/migrations/update-14-4-4/experimental-to-utils-deps.js +0 -30
  71. package/src/migrations/update-14-4-4/experimental-to-utils-deps.js.map +0 -1
  72. package/src/migrations/update-14-4-4/experimental-to-utils-rules.d.ts +0 -2
  73. package/src/migrations/update-14-4-4/experimental-to-utils-rules.js +0 -38
  74. package/src/migrations/update-14-4-4/experimental-to-utils-rules.js.map +0 -1
  75. package/src/migrations/update-15-0-0/add-eslint-inputs.d.ts +0 -2
  76. package/src/migrations/update-15-0-0/add-eslint-inputs.js +0 -33
  77. package/src/migrations/update-15-0-0/add-eslint-inputs.js.map +0 -1
  78. package/src/migrations/update-15-7-1/add-eslint-ignore.d.ts +0 -2
  79. package/src/migrations/update-15-7-1/add-eslint-ignore.js +0 -42
  80. package/src/migrations/update-15-7-1/add-eslint-ignore.js.map +0 -1
  81. package/src/utils/convert-tslint-to-eslint/convert-nx-enforce-module-boundaries-rule.d.ts +0 -5
  82. package/src/utils/convert-tslint-to-eslint/convert-nx-enforce-module-boundaries-rule.js +0 -57
  83. package/src/utils/convert-tslint-to-eslint/convert-nx-enforce-module-boundaries-rule.js.map +0 -1
  84. package/src/utils/convert-tslint-to-eslint/convert-to-eslint-config.d.ts +0 -9
  85. package/src/utils/convert-tslint-to-eslint/convert-to-eslint-config.js +0 -152
  86. package/src/utils/convert-tslint-to-eslint/convert-to-eslint-config.js.map +0 -1
  87. package/src/utils/convert-tslint-to-eslint/example-tslint-configs.d.ts +0 -326
  88. package/src/utils/convert-tslint-to-eslint/example-tslint-configs.js +0 -325
  89. package/src/utils/convert-tslint-to-eslint/example-tslint-configs.js.map +0 -1
  90. package/src/utils/convert-tslint-to-eslint/index.d.ts +0 -2
  91. package/src/utils/convert-tslint-to-eslint/index.js +0 -9
  92. package/src/utils/convert-tslint-to-eslint/index.js.map +0 -1
  93. package/src/utils/convert-tslint-to-eslint/project-converter.d.ts +0 -72
  94. package/src/utils/convert-tslint-to-eslint/project-converter.js +0 -396
  95. package/src/utils/convert-tslint-to-eslint/project-converter.js.map +0 -1
  96. package/src/utils/convert-tslint-to-eslint/utils.d.ts +0 -10
  97. package/src/utils/convert-tslint-to-eslint/utils.js +0 -91
  98. package/src/utils/convert-tslint-to-eslint/utils.js.map +0 -1
  99. package/src/utils/rules-requiring-type-checking.d.ts +0 -3
  100. package/src/utils/rules-requiring-type-checking.js +0 -88
  101. package/src/utils/rules-requiring-type-checking.js.map +0 -1
  102. package/src/utils/testing.d.ts +0 -2
  103. package/src/utils/testing.js +0 -13
  104. package/src/utils/testing.js.map +0 -1
  105. package/src/utils/versions.d.ts +0 -5
  106. package/src/utils/versions.js +0 -9
  107. package/src/utils/versions.js.map +0 -1
  108. package/src/utils/workspace-lint-rules.d.ts +0 -1
  109. package/src/utils/workspace-lint-rules.js +0 -6
  110. package/src/utils/workspace-lint-rules.js.map +0 -1
@@ -1,72 +0,0 @@
1
- import type { GeneratorCallback, ProjectConfiguration, Tree } from '@nrwl/devkit';
2
- import type { Linter } from 'eslint';
3
- /**
4
- * Common schema used by all implementations of convert-tslint-to-eslint generators
5
- */
6
- export interface ConvertTSLintToESLintSchema {
7
- project: string;
8
- ignoreExistingTslintConfig: boolean;
9
- removeTSLintIfNoMoreTSLintTargets: boolean;
10
- skipFormat?: boolean;
11
- }
12
- /**
13
- * When we convert a TSLint setup to an ESLint setup for a particular project, there are a number of
14
- * shared/common concerns (implemented as library utilities within @nrwl/linter), and a few things
15
- * which are specific to this package and the types of projects it produces.
16
- *
17
- * The key structure of the converted ESLint support is as follows:
18
- *
19
- * - We will first generate a workspace root .eslintrc.json which is the same as the one generated
20
- * for new workspaces (i.e. it is NOT just a converted version of their root tslint.json). This allows us
21
- * to have a consistent base for all users, as well as standardized patterns around "overrides".
22
- *
23
- * - The user's original root tslint.json will be converted and any applicable settings will be stored
24
- * within ADDITIONAL override blocks within the root .eslintrc.json.
25
- *
26
- * - The user's project-level tslint.json file will be converted into a corresponding .eslintrc.json file
27
- * and it will extend from the root workspace .eslintrc.json file as normal.
28
- */
29
- export declare class ProjectConverter {
30
- private readonly projectConfig;
31
- private readonly rootTSLintJsonPath;
32
- private readonly rootTSLintJson;
33
- private readonly projectTSLintJsonPath;
34
- private readonly projectTSLintJson;
35
- private readonly host;
36
- private readonly projectName;
37
- private readonly ignoreExistingTslintConfig;
38
- private readonly eslintInitializer;
39
- /**
40
- * Using an object as the argument to the constructor means we sacrifice some
41
- * authoring sugar around initializing these properties but it makes the usage
42
- * of the class much easier to read and maintain.
43
- */
44
- constructor({ host, projectName, ignoreExistingTslintConfig, eslintInitializer, }: {
45
- host: Tree;
46
- projectName: string;
47
- ignoreExistingTslintConfig: boolean;
48
- eslintInitializer: (projectInfo: {
49
- projectName: string;
50
- projectConfig: ProjectConfiguration;
51
- }) => Promise<void>;
52
- });
53
- initESLint(): Promise<GeneratorCallback>;
54
- /**
55
- * If the package-specific shareable config already exists then the workspace must already
56
- * be part way through migrating from TSLint to ESLint. In this case we do not want to convert
57
- * the root tslint.json again (and this utility will return a noop task), and we instead just
58
- * focus on the project-level config conversion.
59
- */
60
- convertRootTSLintConfig(applyPackageSpecificModifications: (json: Linter.Config) => Linter.Config, rootEslintConfigExists?: boolean): Promise<Exclude<GeneratorCallback, void>>;
61
- convertProjectConfig(applyPackageSpecificModifications: (json: Linter.Config) => Linter.Config): Promise<GeneratorCallback>;
62
- removeProjectTSLintFile(): void;
63
- isTSLintUsedInWorkspace(): boolean;
64
- removeTSLintFromWorkspace(): GeneratorCallback;
65
- private cleanUpGeneratorsConfig;
66
- /**
67
- * If the project which is the subject of the ProjectConverter instance is an application,
68
- * figure out its associated e2e project's name.
69
- */
70
- getE2EProjectName(): string | null;
71
- setDefaults(collectionName: string, defaults: Partial<ConvertTSLintToESLintSchema>): void;
72
- }
@@ -1,396 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProjectConverter = void 0;
4
- const tslib_1 = require("tslib");
5
- const devkit_1 = require("@nrwl/devkit");
6
- const rules_requiring_type_checking_1 = require("../rules-requiring-type-checking");
7
- const convert_to_eslint_config_1 = require("./convert-to-eslint-config");
8
- const utils_1 = require("./utils");
9
- /**
10
- * When we convert a TSLint setup to an ESLint setup for a particular project, there are a number of
11
- * shared/common concerns (implemented as library utilities within @nrwl/linter), and a few things
12
- * which are specific to this package and the types of projects it produces.
13
- *
14
- * The key structure of the converted ESLint support is as follows:
15
- *
16
- * - We will first generate a workspace root .eslintrc.json which is the same as the one generated
17
- * for new workspaces (i.e. it is NOT just a converted version of their root tslint.json). This allows us
18
- * to have a consistent base for all users, as well as standardized patterns around "overrides".
19
- *
20
- * - The user's original root tslint.json will be converted and any applicable settings will be stored
21
- * within ADDITIONAL override blocks within the root .eslintrc.json.
22
- *
23
- * - The user's project-level tslint.json file will be converted into a corresponding .eslintrc.json file
24
- * and it will extend from the root workspace .eslintrc.json file as normal.
25
- */
26
- class ProjectConverter {
27
- /**
28
- * Using an object as the argument to the constructor means we sacrifice some
29
- * authoring sugar around initializing these properties but it makes the usage
30
- * of the class much easier to read and maintain.
31
- */
32
- constructor({ host, projectName, ignoreExistingTslintConfig, eslintInitializer, }) {
33
- this.rootTSLintJsonPath = 'tslint.json';
34
- this.host = host;
35
- this.projectName = projectName;
36
- this.ignoreExistingTslintConfig = ignoreExistingTslintConfig;
37
- this.eslintInitializer = eslintInitializer;
38
- this.projectConfig = (0, devkit_1.readProjectConfiguration)(this.host, this.projectName);
39
- this.projectTSLintJsonPath = (0, devkit_1.joinPathFragments)(this.projectConfig.root, 'tslint.json');
40
- /**
41
- * Given the user is converting a project from TSLint to ESLint, we expect them
42
- * to have both a root and a project-specific tslint.json
43
- */
44
- if (!ignoreExistingTslintConfig) {
45
- if (!host.exists(this.rootTSLintJsonPath)) {
46
- throw new Error('We could not find a tslint.json at the root of your workspace, maybe you have already migrated to ESLint?');
47
- }
48
- this.rootTSLintJson = (0, devkit_1.readJson)(host, this.rootTSLintJsonPath);
49
- if (!host.exists(this.projectTSLintJsonPath)) {
50
- devkit_1.logger.warn(`We could not find a tslint.json for the selected project "${this.projectTSLintJsonPath}", maybe you have already migrated to ESLint?`);
51
- }
52
- else {
53
- this.projectTSLintJson = (0, devkit_1.readJson)(host, this.projectTSLintJsonPath);
54
- }
55
- }
56
- /**
57
- * We are not able to support --dry-run in this generator, because we need to dynamically install
58
- * and use the tslint-to-eslint-config package within the same execution.
59
- *
60
- * This is a worthwhile trade-off and the dry-run output doesn't offer a ton of value for this use-case anyway.
61
- */
62
- if (process.argv.includes('--dry-run') ||
63
- process.argv.includes('--dryRun') ||
64
- process.argv.includes('-d')) {
65
- throw new Error('NOTE: This generator does not support --dry-run. If you are running this in Nx Console, it should execute fine once you hit the "Run" button.\n');
66
- }
67
- }
68
- initESLint() {
69
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
70
- yield this.eslintInitializer({
71
- projectName: this.projectName,
72
- projectConfig: this.projectConfig,
73
- });
74
- // Ensure that all the dependencies added as part ESLint initialization are installed
75
- return () => {
76
- (0, devkit_1.installPackagesTask)(this.host);
77
- };
78
- });
79
- }
80
- /**
81
- * If the package-specific shareable config already exists then the workspace must already
82
- * be part way through migrating from TSLint to ESLint. In this case we do not want to convert
83
- * the root tslint.json again (and this utility will return a noop task), and we instead just
84
- * focus on the project-level config conversion.
85
- */
86
- convertRootTSLintConfig(applyPackageSpecificModifications, rootEslintConfigExists) {
87
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
88
- if (this.ignoreExistingTslintConfig) {
89
- return Promise.resolve(() => { });
90
- }
91
- /**
92
- * If root eslint already exists, we will not override it with converted tslint
93
- * as this might break existing configuration in place. This is the common scenario
94
- * when large projects are migrating one project at a time and apply custom
95
- * changes to root config in the meantime.
96
- *
97
- * We warn user of this action in case .eslintrc.json was created accidentally
98
- */
99
- if (rootEslintConfigExists) {
100
- devkit_1.logger.warn(`Root '.eslintrc.json' found. Assuming conversion was already run for other projects.`);
101
- return Promise.resolve(() => { });
102
- }
103
- const convertedRoot = yield (0, utils_1.convertTSLintConfig)(this.rootTSLintJson, this.rootTSLintJsonPath, []);
104
- const convertedRootESLintConfig = convertedRoot.convertedESLintConfig;
105
- /**
106
- * Already set by Nx's shareable configs
107
- */
108
- delete convertedRootESLintConfig.env;
109
- delete convertedRootESLintConfig.parser;
110
- delete convertedRootESLintConfig.parserOptions;
111
- if (convertedRootESLintConfig.plugins) {
112
- convertedRootESLintConfig.plugins =
113
- convertedRootESLintConfig.plugins.filter((p) => p !== '@typescript-eslint/tslint');
114
- }
115
- /**
116
- * The only piece of the converted root tslint.json that we need to pull out to
117
- * apply to the existing overrides within the root .eslintrc.json is the
118
- * @nrwl/nx/enforce-module-boundaries rule.
119
- */
120
- const nxRuleName = '@nrwl/nx/enforce-module-boundaries';
121
- const nxEnforceModuleBoundariesRule = convertedRootESLintConfig.rules[nxRuleName];
122
- if (nxEnforceModuleBoundariesRule) {
123
- (0, devkit_1.updateJson)(this.host, '.eslintrc.json', (json) => {
124
- if (!json.overrides) {
125
- return json;
126
- }
127
- for (const o of json.overrides) {
128
- if (!o.rules) {
129
- continue;
130
- }
131
- if (!o.rules[nxRuleName]) {
132
- continue;
133
- }
134
- o.rules[nxRuleName] = nxEnforceModuleBoundariesRule;
135
- }
136
- return json;
137
- });
138
- /**
139
- * Remove it once we've used it on the root, so that is isn't applied
140
- * to the package-specific shareable config
141
- */
142
- delete convertedRootESLintConfig.rules[nxRuleName];
143
- }
144
- /**
145
- * Update the root workspace .eslintrc.json with additional overrides
146
- */
147
- const finalConvertedRootESLintConfig = applyPackageSpecificModifications(convertedRootESLintConfig);
148
- (0, devkit_1.updateJson)(this.host, '.eslintrc.json', (json) => {
149
- json.overrides || (json.overrides = []);
150
- if (finalConvertedRootESLintConfig.overrides &&
151
- finalConvertedRootESLintConfig.overrides.length) {
152
- json.overrides = [
153
- ...json.overrides,
154
- ...finalConvertedRootESLintConfig.overrides,
155
- ];
156
- }
157
- else {
158
- json.overrides.push(Object.assign({ files: ['*.ts'] }, finalConvertedRootESLintConfig));
159
- }
160
- json.overrides = (0, utils_1.deduplicateOverrides)(json.overrides);
161
- /**
162
- * Remove the parserOptions.project config if it is not required for the final config,
163
- * so that lint runs can be as fast and efficient as possible.
164
- */
165
- return (0, rules_requiring_type_checking_1.removeParserOptionsProjectIfNotRequired)(json);
166
- });
167
- /**
168
- * Through converting the config we may encounter TSLint rules whose closest
169
- * equivalent in the ESLint ecosystem comes from a separate package/plugin.
170
- *
171
- * We therefore automatically install those extra packages for the user and
172
- * explain that that's what we are doing.
173
- */
174
- return (0, utils_1.ensureESLintPluginsAreInstalled)(this.host, convertedRoot.ensureESLintPlugins);
175
- });
176
- }
177
- convertProjectConfig(applyPackageSpecificModifications) {
178
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
179
- if (this.ignoreExistingTslintConfig || !this.projectTSLintJson) {
180
- return Promise.resolve(() => { });
181
- }
182
- const convertedProjectConfig = yield (0, utils_1.convertTSLintConfig)(this.projectTSLintJson, this.projectTSLintJsonPath,
183
- // Strip the extends on workspace tslint.json (see this util's docs for more info)
184
- [`${(0, devkit_1.offsetFromRoot)(this.projectConfig.root)}tslint.json`]);
185
- const convertedProjectESLintConfig = convertedProjectConfig.convertedESLintConfig;
186
- /**
187
- * Already set by Nx's shareable configs
188
- */
189
- delete convertedProjectESLintConfig.env;
190
- delete convertedProjectESLintConfig.parser;
191
- delete convertedProjectESLintConfig.parserOptions;
192
- if (convertedProjectESLintConfig.plugins) {
193
- convertedProjectESLintConfig.plugins =
194
- convertedProjectESLintConfig.plugins.filter((p) => p !== '@typescript-eslint/tslint');
195
- }
196
- const projectESLintConfigPath = (0, devkit_1.joinPathFragments)(this.projectConfig.root, '.eslintrc.json');
197
- /**
198
- * Apply updates to the new .eslintrc.json file for the project
199
- */
200
- (0, devkit_1.updateJson)(this.host, projectESLintConfigPath, (json) => {
201
- var _a;
202
- if (typeof json.extends === 'string') {
203
- json.extends = [json.extends];
204
- }
205
- // Custom extends from conversion
206
- if (Array.isArray(convertedProjectESLintConfig.extends) &&
207
- convertedProjectESLintConfig.extends.length) {
208
- // Ignore any tslint-to-eslint-config default extends that do not apply to Nx
209
- const applicableExtends = convertedProjectESLintConfig.extends.filter((ext) => !ext.startsWith('prettier'));
210
- if (applicableExtends.length) {
211
- json.extends = [...json.extends, ...applicableExtends];
212
- }
213
- }
214
- // Custom plugins from conversion
215
- if (Array.isArray(convertedProjectESLintConfig.plugins) &&
216
- convertedProjectESLintConfig.plugins.length) {
217
- json.plugins = [
218
- ...((_a = json.plugins) !== null && _a !== void 0 ? _a : []),
219
- ...convertedProjectESLintConfig.plugins,
220
- ];
221
- }
222
- /**
223
- * Custom rules
224
- *
225
- * By default, tslint-to-eslint-config will try and apply any rules without known converters
226
- * by using eslint-plugin-tslint. We instead explicitly warn the user about this missing converter,
227
- * and therefore at this point we strip out any rules which start with @typescript-eslint/tslint/config
228
- */
229
- json.rules || (json.rules = {});
230
- if (convertedProjectESLintConfig.rules &&
231
- Object.keys(convertedProjectESLintConfig.rules).length) {
232
- for (const [ruleName, ruleConfig] of Object.entries(convertedProjectESLintConfig.rules)) {
233
- if (!ruleName.startsWith('@typescript-eslint/tslint/config')) {
234
- // Prioritize the converted rules over any base implementations from the original Nx generator
235
- json.rules[ruleName] = ruleConfig;
236
- }
237
- }
238
- }
239
- /**
240
- * Apply any package-specific modifications to the converted config before
241
- * updating the config file.
242
- */
243
- const finalJson = applyPackageSpecificModifications(json);
244
- /**
245
- * Remove the parserOptions.project config if it is not required for the final config,
246
- * so that lint runs can be as fast and efficient as possible.
247
- */
248
- return (0, rules_requiring_type_checking_1.removeParserOptionsProjectIfNotRequired)(finalJson);
249
- });
250
- /**
251
- * Convert any instances of comment-based configuration in the source files
252
- * of the project
253
- */
254
- (0, convert_to_eslint_config_1.convertTSLintDisableCommentsForProject)(this.host, this.projectName);
255
- /**
256
- * Through converting the config we may encounter TSLint rules whose closest
257
- * equivalent in the ESLint ecosystem comes from a separate package/plugin.
258
- *
259
- * We therefore automatically install those extra packages for the user and
260
- * explain that that's what we are doing.
261
- */
262
- return (0, utils_1.ensureESLintPluginsAreInstalled)(this.host, convertedProjectConfig.ensureESLintPlugins);
263
- });
264
- }
265
- removeProjectTSLintFile() {
266
- this.host.delete((0, devkit_1.joinPathFragments)(this.projectConfig.root, 'tslint.json'));
267
- }
268
- isTSLintUsedInWorkspace() {
269
- const projects = (0, devkit_1.getProjects)(this.host);
270
- for (const [, projectConfig] of projects.entries()) {
271
- for (const [, targetConfig] of Object.entries(projectConfig.targets)) {
272
- if (targetConfig.executor === '@angular-devkit/build-angular:tslint') {
273
- // Workspace is still using TSLint, exit early
274
- return true;
275
- }
276
- }
277
- }
278
- // If we got this far the user has no remaining TSLint usage
279
- return false;
280
- }
281
- removeTSLintFromWorkspace() {
282
- devkit_1.logger.info(`No TSLint usage will remain in the workspace, removing TSLint...`);
283
- /**
284
- * Delete the root tslint.json
285
- */
286
- this.host.delete(this.rootTSLintJsonPath);
287
- /**
288
- * Prepare the package.json and the uninstall task
289
- */
290
- const uninstallTask = (0, devkit_1.removeDependenciesFromPackageJson)(this.host, [], ['tslint', 'codelyzer']);
291
- /**
292
- * Update global linter configuration defaults in project configuration
293
- */
294
- const nxJson = (0, devkit_1.readNxJson)(this.host);
295
- this.cleanUpGeneratorsConfig(nxJson);
296
- (0, devkit_1.updateNxJson)(this.host, nxJson);
297
- /**
298
- * Update project-level linter configuration defaults in project configuration
299
- */
300
- const projects = (0, devkit_1.getProjects)(this.host);
301
- for (const [projectName, { generators }] of projects.entries()) {
302
- if (!generators || Object.keys(generators).length === 0) {
303
- continue;
304
- }
305
- const project = (0, devkit_1.readProjectConfiguration)(this.host, projectName);
306
- this.cleanUpGeneratorsConfig(project);
307
- (0, devkit_1.updateProjectConfiguration)(this.host, projectName, project);
308
- }
309
- return uninstallTask;
310
- }
311
- cleanUpGeneratorsConfig(parentConfig) {
312
- if (!parentConfig.generators ||
313
- Object.keys(parentConfig.generators).length === 0) {
314
- return;
315
- }
316
- for (const [collectionName, maybeGeneratorConfig] of Object.entries(parentConfig.generators)) {
317
- // Shorthand syntax is possible
318
- if (collectionName.includes(':')) {
319
- const generatorConfig = maybeGeneratorConfig;
320
- for (const optionName of Object.keys(generatorConfig)) {
321
- if (optionName === 'linter') {
322
- // Default is eslint, so in all cases we can just remove the config altogether
323
- delete generatorConfig[optionName];
324
- }
325
- }
326
- // If removing linter leaves no other options in the config, remove the config as well
327
- if (Object.keys(generatorConfig).length === 0) {
328
- delete parentConfig.generators[collectionName];
329
- }
330
- }
331
- else {
332
- // Not shorthand syntax, so next level down is generator name -> config mapping
333
- const collectionConfig = maybeGeneratorConfig;
334
- for (const [generatorName, generatorConfig] of Object.entries(collectionConfig)) {
335
- if (generatorName === 'convert-tslint-to-eslint') {
336
- // No longer relevant because of TSLint is being removed the conversion process must be complete
337
- delete collectionConfig[generatorName];
338
- continue;
339
- }
340
- for (const optionName of Object.keys(generatorConfig)) {
341
- if (optionName === 'linter') {
342
- // Default is eslint, so in all cases we can just remove the config altogether
343
- delete generatorConfig[optionName];
344
- }
345
- }
346
- // If removing linter leaves no other options in the config, remove the generator config as well
347
- if (Object.keys(generatorConfig).length === 0) {
348
- delete collectionConfig[generatorName];
349
- }
350
- }
351
- // If removing the generator leaves no other generators in the config, remove the config as well
352
- if (parentConfig.generators[collectionName] &&
353
- Object.keys(parentConfig.generators[collectionName]).length === 0) {
354
- delete parentConfig.generators[collectionName];
355
- }
356
- }
357
- }
358
- // If removing the linter defaults leaves absolutely no generators configuration remaining, remove it
359
- if (Object.keys(parentConfig.generators).length === 0) {
360
- delete parentConfig.generators;
361
- }
362
- }
363
- /**
364
- * If the project which is the subject of the ProjectConverter instance is an application,
365
- * figure out its associated e2e project's name.
366
- */
367
- getE2EProjectName() {
368
- if (this.projectConfig.projectType !== 'application') {
369
- return null;
370
- }
371
- let e2eProjectName = null;
372
- const projects = (0, devkit_1.getProjects)(this.host);
373
- for (const [projectName, projectConfig] of projects.entries()) {
374
- for (const [, targetConfig] of Object.entries(projectConfig.targets)) {
375
- if (targetConfig.executor === '@nrwl/cypress:cypress') {
376
- if (targetConfig.options.devServerTarget === `${this.projectName}:serve`) {
377
- e2eProjectName = projectName;
378
- devkit_1.logger.info(`Found e2e project for "${this.projectName}" called "${e2eProjectName}", converting that project as well...`);
379
- }
380
- }
381
- }
382
- }
383
- return e2eProjectName;
384
- }
385
- setDefaults(collectionName, defaults) {
386
- var _a;
387
- const nxJson = (0, devkit_1.readNxJson)(this.host);
388
- nxJson.generators || (nxJson.generators = {});
389
- (_a = nxJson.generators)[collectionName] || (_a[collectionName] = {});
390
- const prev = nxJson.generators[collectionName];
391
- nxJson.generators = Object.assign(Object.assign({}, nxJson.generators), { [collectionName]: Object.assign(Object.assign({}, prev), { 'convert-tslint-to-eslint': Object.assign(Object.assign({}, prev['convert-tslint-to-eslint']), defaults) }) });
392
- (0, devkit_1.updateNxJson)(this.host, nxJson);
393
- }
394
- }
395
- exports.ProjectConverter = ProjectConverter;
396
- //# sourceMappingURL=project-converter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"project-converter.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/utils/convert-tslint-to-eslint/project-converter.ts"],"names":[],"mappings":";;;;AAKA,yCAasB;AAEtB,oFAA2F;AAC3F,yEAAoF;AACpF,mCAIiB;AAajB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,gBAAgB;IAc3B;;;;OAIG;IACH,YAAY,EACV,IAAI,EACJ,WAAW,EACX,0BAA0B,EAC1B,iBAAiB,GASlB;QA9BgB,uBAAkB,GAAG,aAAa,CAAC;QA+BlD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,0BAA0B,GAAG,0BAA0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
1
- import type { Tree, GeneratorCallback } from '@nrwl/devkit';
2
- import type { Linter } from 'eslint';
3
- import type { TSLintRuleOptions } from 'tslint-to-eslint-config';
4
- export declare function ensureESLintPluginsAreInstalled(host: Tree, eslintPluginsToBeInstalled: string[]): GeneratorCallback;
5
- export declare function convertTSLintConfig(rawTSLintJson: any, tslintJsonPath: string, ignoreExtendsVals: string[]): Promise<{
6
- convertedESLintConfig: Linter.Config<Linter.RulesRecord, Linter.RulesRecord>;
7
- unconvertedTSLintRules: TSLintRuleOptions[];
8
- ensureESLintPlugins: string[];
9
- }>;
10
- export declare function deduplicateOverrides(overrides?: Linter.Config['overrides']): any[];
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deduplicateOverrides = exports.convertTSLintConfig = exports.ensureESLintPluginsAreInstalled = void 0;
4
- const tslib_1 = require("tslib");
5
- const devkit_1 = require("@nrwl/devkit");
6
- const convert_nx_enforce_module_boundaries_rule_1 = require("./convert-nx-enforce-module-boundaries-rule");
7
- const convert_to_eslint_config_1 = require("./convert-to-eslint-config");
8
- function ensureESLintPluginsAreInstalled(host, eslintPluginsToBeInstalled) {
9
- if (!(eslintPluginsToBeInstalled === null || eslintPluginsToBeInstalled === void 0 ? void 0 : eslintPluginsToBeInstalled.length)) {
10
- return () => undefined;
11
- }
12
- const additionalDevDependencies = {};
13
- for (const pluginName of eslintPluginsToBeInstalled) {
14
- additionalDevDependencies[pluginName] = 'latest';
15
- }
16
- devkit_1.logger.info('\nINFO: To most closely match your tslint.json, we will ensure the `latest` version of the following eslint plugin(s) are installed:');
17
- devkit_1.logger.info('\n - ' + eslintPluginsToBeInstalled.join('\n - '));
18
- devkit_1.logger.info('\nPlease note, you may later wish to pin these to a specific version number in your package.json, rather than leaving it open to `latest`.\n');
19
- return (0, devkit_1.addDependenciesToPackageJson)(host, {}, additionalDevDependencies);
20
- }
21
- exports.ensureESLintPluginsAreInstalled = ensureESLintPluginsAreInstalled;
22
- /**
23
- * We don't want the user to depend on the TSLint fallback plugin, we will instead
24
- * explicitly inform them of the rules that could not be converted automatically and
25
- * advise them on what to do next.
26
- */
27
- function warnInCaseOfUnconvertedRules(tslintConfigPath, unconvertedTSLintRules) {
28
- const unconvertedTSLintRuleNames = unconvertedTSLintRules
29
- .filter(
30
- // Ignore formatting related rules, they are handled by Nx format/prettier
31
- (unconverted) => !['import-spacing', 'whitespace', 'typedef'].includes(unconverted.ruleName))
32
- .map((unconverted) => unconverted.ruleName);
33
- if (unconvertedTSLintRuleNames.length > 0) {
34
- devkit_1.logger.warn(`\nWARNING: Within "${tslintConfigPath}", the following ${unconvertedTSLintRuleNames.length} rule(s) did not have known converters in https://github.com/typescript-eslint/tslint-to-eslint-config`);
35
- devkit_1.logger.warn('\n - ' + unconvertedTSLintRuleNames.join('\n - '));
36
- devkit_1.logger.warn('\nYou will need to decide on how to handle the above manually, but everything else has been handled for you automatically.\n');
37
- }
38
- }
39
- function convertTSLintConfig(rawTSLintJson, tslintJsonPath, ignoreExtendsVals) {
40
- var _a;
41
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
42
- const convertedProject = yield (0, convert_to_eslint_config_1.convertToESLintConfig)(tslintJsonPath, rawTSLintJson, ignoreExtendsVals);
43
- (_a = convertedProject.convertedESLintConfig).rules || (_a.rules = {});
44
- /**
45
- * Apply the custom converter for the nx-module-boundaries rule if applicable
46
- */
47
- const convertedNxRule = (0, convert_nx_enforce_module_boundaries_rule_1.convertTslintNxRuleToEslintNxRule)(rawTSLintJson);
48
- if (convertedNxRule) {
49
- convertedProject.convertedESLintConfig.rules[convertedNxRule.ruleName] =
50
- convertedNxRule.ruleConfig;
51
- }
52
- // Remove the `@typescript-eslint/tslint/config` rule
53
- if (convertedProject.convertedESLintConfig.rules['@typescript-eslint/tslint/config']) {
54
- delete convertedProject.convertedESLintConfig.rules['@typescript-eslint/tslint/config'];
55
- }
56
- warnInCaseOfUnconvertedRules(tslintJsonPath, convertedProject.unconvertedTSLintRules);
57
- return convertedProject;
58
- });
59
- }
60
- exports.convertTSLintConfig = convertTSLintConfig;
61
- function deduplicateOverrides(overrides = []) {
62
- const map = new Map();
63
- for (const o of overrides) {
64
- const mapKey = typeof o.files === 'string' ? o.files : o.files.join(',');
65
- const existing = map.get(mapKey);
66
- if (existing) {
67
- existing.add(o);
68
- map.set(mapKey, existing);
69
- continue;
70
- }
71
- const set = new Set();
72
- set.add(o);
73
- map.set(mapKey, set);
74
- }
75
- let dedupedOverrides = [];
76
- for (const [, overrides] of map.entries()) {
77
- const overridesArr = Array.from(overrides);
78
- if (overridesArr.length === 1) {
79
- dedupedOverrides = [...dedupedOverrides, ...overridesArr];
80
- continue;
81
- }
82
- let mergedOverride = {};
83
- for (const o of overridesArr) {
84
- mergedOverride = Object.assign(Object.assign({}, mergedOverride), o);
85
- }
86
- dedupedOverrides.push(mergedOverride);
87
- }
88
- return dedupedOverrides;
89
- }
90
- exports.deduplicateOverrides = deduplicateOverrides;
91
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/utils/convert-tslint-to-eslint/utils.ts"],"names":[],"mappings":";;;;AAAA,yCAAoE;AAIpE,2GAAgG;AAChG,yEAAmE;AAEnE,SAAgB,+BAA+B,CAC7C,IAAU,EACV,0BAAoC;IAEpC,IAAI,CAAC,CAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,MAAM,CAAA,EAAE;QACvC,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;KACxB;IAED,MAAM,yBAAyB,GAAG,EAAE,CAAC;IAErC,KAAK,MAAM,UAAU,IAAI,0BAA0B,EAAE;QACnD,yBAAyB,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;KAClD;IAED,eAAM,CAAC,IAAI,CACT,sIAAsI,CACvI,CAAC;IACF,eAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,0BAA0B,CAAC,IAAI,CA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C,EAAE;YAC7B,gBAAgB,GAAG,CAAC,GAAG,gBAAgB,EAAE,GAAG,YAAY,CAAC,CAAC;YAC1D,SAAS;SACV;QACD,IAAI,cAAc,GAAG,EAAE,CAAC;QACxB,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;YAC5B,cAAc,mCACT,cAAc,GACb,CAAS,CACd,CAAC;SACH;QACD,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;KACvC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AArCD,oDAqCC"}
@@ -1,3 +0,0 @@
1
- import type { Linter } from 'eslint';
2
- export declare function hasRulesRequiringTypeChecking(eslintConfig: Linter.Config): boolean;
3
- export declare function removeParserOptionsProjectIfNotRequired(json: Linter.Config): Linter.Config;