@nrwl/linter 16.0.0-beta.0 → 16.0.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/executors.json +5 -5
- package/generators.json +2 -28
- package/index.d.ts +1 -5
- package/index.js +1 -13
- package/index.js.map +1 -1
- package/package.json +7 -20
- package/README.md +0 -61
- package/migrations.json +0 -226
- package/src/executors/eslint/compat.d.ts +0 -2
- package/src/executors/eslint/compat.js +0 -6
- package/src/executors/eslint/compat.js.map +0 -1
- package/src/executors/eslint/hasher.d.ts +0 -7
- package/src/executors/eslint/hasher.js +0 -47
- package/src/executors/eslint/hasher.js.map +0 -1
- package/src/executors/eslint/lint.impl.d.ts +0 -5
- package/src/executors/eslint/lint.impl.js +0 -116
- package/src/executors/eslint/lint.impl.js.map +0 -1
- package/src/executors/eslint/schema.d.ts +0 -38
- package/src/executors/eslint/schema.json +0 -139
- package/src/executors/eslint/utility/eslint-utils.d.ts +0 -4
- package/src/executors/eslint/utility/eslint-utils.js +0 -52
- package/src/executors/eslint/utility/eslint-utils.js.map +0 -1
- package/src/generators/init/global-eslint-config.d.ts +0 -36
- package/src/generators/init/global-eslint-config.js +0 -77
- package/src/generators/init/global-eslint-config.js.map +0 -1
- package/src/generators/init/init-migration.d.ts +0 -3
- package/src/generators/init/init-migration.js +0 -68
- package/src/generators/init/init-migration.js.map +0 -1
- package/src/generators/init/init.d.ts +0 -9
- package/src/generators/init/init.js +0 -63
- package/src/generators/init/init.js.map +0 -1
- package/src/generators/lint-project/lint-project.d.ts +0 -16
- package/src/generators/lint-project/lint-project.js +0 -137
- package/src/generators/lint-project/lint-project.js.map +0 -1
- package/src/generators/utils/eslint-file.d.ts +0 -4
- package/src/generators/utils/eslint-file.js +0 -27
- package/src/generators/utils/eslint-file.js.map +0 -1
- package/src/generators/utils/eslint-targets.d.ts +0 -2
- package/src/generators/utils/eslint-targets.js +0 -13
- package/src/generators/utils/eslint-targets.js.map +0 -1
- package/src/generators/utils/linter.d.ts +0 -4
- package/src/generators/utils/linter.js +0 -9
- package/src/generators/utils/linter.js.map +0 -1
- package/src/generators/workspace-rule/files/__name__.spec.ts__tmpl__ +0 -11
- package/src/generators/workspace-rule/files/__name__.ts__tmpl__ +0 -37
- package/src/generators/workspace-rule/schema.json +0 -26
- package/src/generators/workspace-rule/workspace-rule.d.ts +0 -7
- package/src/generators/workspace-rule/workspace-rule.js +0 -79
- package/src/generators/workspace-rule/workspace-rule.js.map +0 -1
- package/src/generators/workspace-rules-project/files/index.ts__tmpl__ +0 -27
- package/src/generators/workspace-rules-project/files/tsconfig.json__tmpl__ +0 -13
- package/src/generators/workspace-rules-project/files/tsconfig.lint.json__tmpl__ +0 -9
- package/src/generators/workspace-rules-project/schema.json +0 -23
- package/src/generators/workspace-rules-project/workspace-rules-project.d.ts +0 -8
- package/src/generators/workspace-rules-project/workspace-rules-project.js +0 -86
- package/src/generators/workspace-rules-project/workspace-rules-project.js.map +0 -1
- package/src/migrations/update-12-4-0/remove-eslint-project-config-if-no-type-checking-rules.d.ts +0 -2
- package/src/migrations/update-12-4-0/remove-eslint-project-config-if-no-type-checking-rules.js +0 -32
- package/src/migrations/update-12-4-0/remove-eslint-project-config-if-no-type-checking-rules.js.map +0 -1
- package/src/migrations/update-12-9-0/add-outputs.d.ts +0 -2
- package/src/migrations/update-12-9-0/add-outputs.js +0 -23
- package/src/migrations/update-12-9-0/add-outputs.js.map +0 -1
- package/src/migrations/update-13-3-0/eslint-8-updates.d.ts +0 -2
- package/src/migrations/update-13-3-0/eslint-8-updates.js +0 -44
- package/src/migrations/update-13-3-0/eslint-8-updates.js.map +0 -1
- package/src/migrations/update-14-1-9/add-swc-deps-if-needed.d.ts +0 -2
- package/src/migrations/update-14-1-9/add-swc-deps-if-needed.js +0 -20
- package/src/migrations/update-14-1-9/add-swc-deps-if-needed.js.map +0 -1
- package/src/migrations/update-14-4-4/experimental-to-utils-deps.d.ts +0 -2
- package/src/migrations/update-14-4-4/experimental-to-utils-deps.js +0 -30
- package/src/migrations/update-14-4-4/experimental-to-utils-deps.js.map +0 -1
- package/src/migrations/update-14-4-4/experimental-to-utils-rules.d.ts +0 -2
- package/src/migrations/update-14-4-4/experimental-to-utils-rules.js +0 -38
- package/src/migrations/update-14-4-4/experimental-to-utils-rules.js.map +0 -1
- package/src/migrations/update-15-0-0/add-eslint-inputs.d.ts +0 -2
- package/src/migrations/update-15-0-0/add-eslint-inputs.js +0 -33
- package/src/migrations/update-15-0-0/add-eslint-inputs.js.map +0 -1
- package/src/migrations/update-15-7-1/add-eslint-ignore.d.ts +0 -2
- package/src/migrations/update-15-7-1/add-eslint-ignore.js +0 -42
- package/src/migrations/update-15-7-1/add-eslint-ignore.js.map +0 -1
- package/src/utils/convert-tslint-to-eslint/convert-nx-enforce-module-boundaries-rule.d.ts +0 -5
- package/src/utils/convert-tslint-to-eslint/convert-nx-enforce-module-boundaries-rule.js +0 -57
- package/src/utils/convert-tslint-to-eslint/convert-nx-enforce-module-boundaries-rule.js.map +0 -1
- package/src/utils/convert-tslint-to-eslint/convert-to-eslint-config.d.ts +0 -9
- package/src/utils/convert-tslint-to-eslint/convert-to-eslint-config.js +0 -152
- package/src/utils/convert-tslint-to-eslint/convert-to-eslint-config.js.map +0 -1
- package/src/utils/convert-tslint-to-eslint/example-tslint-configs.d.ts +0 -326
- package/src/utils/convert-tslint-to-eslint/example-tslint-configs.js +0 -325
- package/src/utils/convert-tslint-to-eslint/example-tslint-configs.js.map +0 -1
- package/src/utils/convert-tslint-to-eslint/index.d.ts +0 -2
- package/src/utils/convert-tslint-to-eslint/index.js +0 -9
- package/src/utils/convert-tslint-to-eslint/index.js.map +0 -1
- package/src/utils/convert-tslint-to-eslint/project-converter.d.ts +0 -72
- package/src/utils/convert-tslint-to-eslint/project-converter.js +0 -396
- package/src/utils/convert-tslint-to-eslint/project-converter.js.map +0 -1
- package/src/utils/convert-tslint-to-eslint/utils.d.ts +0 -10
- package/src/utils/convert-tslint-to-eslint/utils.js +0 -91
- package/src/utils/convert-tslint-to-eslint/utils.js.map +0 -1
- package/src/utils/rules-requiring-type-checking.d.ts +0 -3
- package/src/utils/rules-requiring-type-checking.js +0 -88
- package/src/utils/rules-requiring-type-checking.js.map +0 -1
- package/src/utils/testing.d.ts +0 -2
- package/src/utils/testing.js +0 -13
- package/src/utils/testing.js.map +0 -1
- package/src/utils/versions.d.ts +0 -5
- package/src/utils/versions.js +0 -9
- package/src/utils/versions.js.map +0 -1
- package/src/utils/workspace-lint-rules.d.ts +0 -1
- package/src/utils/workspace-lint-rules.js +0 -6
- package/src/utils/workspace-lint-rules.js.map +0 -1
@@ -1,23 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const tslib_1 = require("tslib");
|
4
|
-
const devkit_1 = require("@nrwl/devkit");
|
5
|
-
function addOutputs(tree) {
|
6
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
7
|
-
for (const [projectName, project] of (0, devkit_1.getProjects)(tree)) {
|
8
|
-
if (!project.targets) {
|
9
|
-
continue;
|
10
|
-
}
|
11
|
-
for (const target of Object.values(project.targets)) {
|
12
|
-
if (target.executor !== '@nrwl/linter:eslint' || target.outputs) {
|
13
|
-
continue;
|
14
|
-
}
|
15
|
-
target.outputs = ['{options.outputFile}'];
|
16
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
17
|
-
}
|
18
|
-
}
|
19
|
-
yield (0, devkit_1.formatFiles)(tree);
|
20
|
-
});
|
21
|
-
}
|
22
|
-
exports.default = addOutputs;
|
23
|
-
//# sourceMappingURL=add-outputs.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"add-outputs.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/migrations/update-12-9-0/add-outputs.ts"],"names":[],"mappings":";;;AAAA,yCAKsB;AAEtB,SAA8B,UAAU,CAAC,IAAU;;QACjD,KAAK,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,IAAA,oBAAW,EAAC,IAAI,CAAC,EAAE;YACtD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;gBACpB,SAAS;aACV;YAED,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;gBACnD,IAAI,MAAM,CAAC,QAAQ,KAAK,qBAAqB,IAAI,MAAM,CAAC,OAAO,EAAE;oBAC/D,SAAS;iBACV;gBAED,MAAM,CAAC,OAAO,GAAG,CAAC,sBAAsB,CAAC,CAAC;gBAE1C,IAAA,mCAA0B,EAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;aACxD;SACF;QAED,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAlBD,6BAkBC"}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const tslib_1 = require("tslib");
|
4
|
-
const devkit_1 = require("@nrwl/devkit");
|
5
|
-
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
6
|
-
const versions_1 = require("../../utils/versions");
|
7
|
-
function eslint8Updates(tree) {
|
8
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
9
|
-
try {
|
10
|
-
const { addPropertyToJestConfig } = (0, devkit_1.ensurePackage)('@nrwl/jest', versions_1.nxVersion);
|
11
|
-
const existingJestConfigPath = (0, devkit_1.normalizePath)('tools/eslint-rules/jest.config.js');
|
12
|
-
// Add extra config to the jest.config.js file to allow ESLint 8 exports mapping to work with jest
|
13
|
-
addPropertyToJestConfig(tree, existingJestConfigPath, 'moduleNameMapper', {
|
14
|
-
'@eslint/eslintrc': '@eslint/eslintrc/dist/eslintrc-universal.cjs',
|
15
|
-
});
|
16
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree, 'tools/eslint-rules', (path) => {
|
17
|
-
if (!path.endsWith('.ts')) {
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
const fileContents = tree.read(path).toString('utf-8');
|
21
|
-
const fileAst = tsquery_1.tsquery.ast(fileContents);
|
22
|
-
const isESLintRuleFile = (0, tsquery_1.tsquery)(fileAst, 'PropertyAccessExpression[expression.escapedText=ESLintUtils][name.escapedText=RuleCreator]').length > 0;
|
23
|
-
if (!isESLintRuleFile) {
|
24
|
-
return;
|
25
|
-
}
|
26
|
-
const categoryPropertyAssignmentNode = (0, tsquery_1.tsquery)(fileAst, 'PropertyAssignment[name.escapedText=meta] PropertyAssignment[name.escapedText=docs] PropertyAssignment[name.escapedText=category]')[0];
|
27
|
-
if (!categoryPropertyAssignmentNode) {
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
let end = categoryPropertyAssignmentNode.getEnd();
|
31
|
-
if (fileContents.substring(end, end + 1) === ',') {
|
32
|
-
end++;
|
33
|
-
}
|
34
|
-
const updatedContents = fileContents.slice(0, categoryPropertyAssignmentNode.getFullStart()) +
|
35
|
-
fileContents.slice(end);
|
36
|
-
tree.write(path, updatedContents);
|
37
|
-
});
|
38
|
-
yield (0, devkit_1.formatFiles)(tree);
|
39
|
-
}
|
40
|
-
catch (_a) { }
|
41
|
-
});
|
42
|
-
}
|
43
|
-
exports.default = eslint8Updates;
|
44
|
-
//# sourceMappingURL=eslint-8-updates.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"eslint-8-updates.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/migrations/update-13-3-0/eslint-8-updates.ts"],"names":[],"mappings":";;;AAAA,yCAMsB;AACtB,uDAAoD;AACpD,mDAAiD;AAEjD,SAA8B,cAAc,CAAC,IAAU;;QACrD,IAAI;YACF,MAAM,EAAE,uBAAuB,EAAE,GAAG,IAAA,sBAAa,EAAC,YAAY,EAAE,oBAAS,CAAC,CAAC;YAC3E,MAAM,sBAAsB,GAAG,IAAA,sBAAa,EAC1C,mCAAmC,CACpC,CAAC;YAEF,kGAAkG;YAClG,uBAAuB,CAAC,IAAI,EAAE,sBAAsB,EAAE,kBAAkB,EAAE;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";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const tslib_1 = require("tslib");
|
4
|
-
const devkit_1 = require("@nrwl/devkit");
|
5
|
-
const versions_1 = require("nx/src/utils/versions");
|
6
|
-
const workspace_rules_project_1 = require("../../generators/workspace-rules-project/workspace-rules-project");
|
7
|
-
function addSwcNodeIfNeeded(tree) {
|
8
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
9
|
-
try {
|
10
|
-
if (tree.exists(workspace_rules_project_1.WORKSPACE_PLUGIN_DIR)) {
|
11
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@swc-node/register': versions_1.swcNodeVersion, '@swc/core': versions_1.swcCoreVersion });
|
12
|
-
yield (0, devkit_1.formatFiles)(tree);
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
}
|
16
|
-
catch (_a) { }
|
17
|
-
});
|
18
|
-
}
|
19
|
-
exports.default = addSwcNodeIfNeeded;
|
20
|
-
//# sourceMappingURL=add-swc-deps-if-needed.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"add-swc-deps-if-needed.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/migrations/update-14-1-9/add-swc-deps-if-needed.ts"],"names":[],"mappings":";;;AAAA,yCAA+E;AAC/E,oDAAuE;AACvE,8GAAwG;AAExG,SAA8B,kBAAkB,CAAC,IAAU;;QACzD,IAAI;YACF,IAAI,IAAI,CAAC,MAAM,CAAC,8CAAoB,CAAC,EAAE;gBACrC,IAAA,qCAA4B,EAC1B,IAAI,EACJ,EAAE,EACF,EAAE,oBAAoB,EAAE,yBAAc,EAAE,WAAW,EAAE,yBAAc,EAAE,CACtE,CAAC;gBACF,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;gBACxB,OAAO;aACR;SACF;QAAC,WAAM,GAAE;IACZ,CAAC;CAAA;AAZD,qCAYC"}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const tslib_1 = require("tslib");
|
4
|
-
const devkit_1 = require("@nrwl/devkit");
|
5
|
-
const workspace_rules_project_1 = require("../../generators/workspace-rules-project/workspace-rules-project");
|
6
|
-
const versions_1 = require("../../utils/versions");
|
7
|
-
function addTypescriptEslintUtilsIfNeeded(tree) {
|
8
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
9
|
-
try {
|
10
|
-
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
11
|
-
let removed = false;
|
12
|
-
if (packageJson.devDependencies['@typescript-eslint/experimental-utils']) {
|
13
|
-
yield (0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['@typescript-eslint/experimental-utils']);
|
14
|
-
removed = true;
|
15
|
-
}
|
16
|
-
if (packageJson.dependencies['@typescript-eslint/experimental-utils']) {
|
17
|
-
yield (0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@typescript-eslint/experimental-utils'], []);
|
18
|
-
removed = true;
|
19
|
-
}
|
20
|
-
if (removed || tree.exists(workspace_rules_project_1.WORKSPACE_PLUGIN_DIR)) {
|
21
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@typescript-eslint/utils': versions_1.typescriptESLintVersion });
|
22
|
-
yield (0, devkit_1.formatFiles)(tree);
|
23
|
-
}
|
24
|
-
return;
|
25
|
-
}
|
26
|
-
catch (_a) { }
|
27
|
-
});
|
28
|
-
}
|
29
|
-
exports.default = addTypescriptEslintUtilsIfNeeded;
|
30
|
-
//# sourceMappingURL=experimental-to-utils-deps.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"experimental-to-utils-deps.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/migrations/update-14-4-4/experimental-to-utils-deps.ts"],"names":[],"mappings":";;;AAAA,yCAMsB;AACtB,8GAAwG;AACxG,mDAA+D;AAE/D,SAA8B,gCAAgC,CAAC,IAAU;;QACvE,IAAI;YACF,MAAM,WAAW,GAAG,IAAA,iBAAQ,EAAC,IAAI,EAAE,cAAc,CAAC,CAAC;YACnD,IAAI,OAAO,GAAG,KAAK,CAAC;YAEpB,IAAI,WAAW,CAAC,eAAe,CAAC,uCAAuC,CAAC,EAAE;gBACxE,MAAM,IAAA,0CAAiC,EACrC,IAAI,EACJ,EAAE,EACF,CAAC,uCAAuC,CAAC,CAC1C,CAAC;gBACF,OAAO,GAAG,IAAI,CAAC;aAChB;YAED,IAAI,WAAW,CAAC,YAAY,CAAC,uCAAuC,CAAC,EAAE;gBACrE,MAAM,IAAA,0CAAiC,EACrC,IAAI,EACJ,CAAC,uCAAuC,CAAC,EACzC,EAAE,CACH,CAAC;gBACF,OAAO,GAAG,IAAI,CAAC;aAChB;YAED,IAAI,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,8CAAoB,CAAC,EAAE;gBAChD,IAAA,qCAA4B,EAC1B,IAAI,EACJ,EAAE,EACF,EAAE,0BAA0B,EAAE,kCAAuB,EAAE,CACxD,CAAC;gBAEF,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;aACzB;YACD,OAAO;SACR;QAAC,WAAM,GAAE;IACZ,CAAC;CAAA;AAlCD,mDAkCC"}
|
@@ -1,38 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const tslib_1 = require("tslib");
|
4
|
-
const devkit_1 = require("@nrwl/devkit");
|
5
|
-
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
6
|
-
function updateFile(fileAst, fileContents) {
|
7
|
-
const importStatement = (0, tsquery_1.tsquery)(fileAst, 'ImportDeclaration StringLiteral[value=@typescript-eslint/experimental-utils]');
|
8
|
-
if (importStatement.length === 0) {
|
9
|
-
return;
|
10
|
-
}
|
11
|
-
const contentSlices = fileContents.split('@typescript-eslint/experimental-utils');
|
12
|
-
let updatedFileContents = '';
|
13
|
-
for (let i = 0; i < contentSlices.length / 2; i++) {
|
14
|
-
updatedFileContents += `${contentSlices[i]}@typescript-eslint/utils`;
|
15
|
-
}
|
16
|
-
updatedFileContents += contentSlices[contentSlices.length - 1];
|
17
|
-
return updatedFileContents;
|
18
|
-
}
|
19
|
-
function experimentalToUtilsUpdate(tree) {
|
20
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
21
|
-
try {
|
22
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree, 'tools/eslint-rules', (path) => {
|
23
|
-
if (path.endsWith('.ts')) {
|
24
|
-
const fileContents = tree.read(path).toString('utf-8');
|
25
|
-
const fileAst = tsquery_1.tsquery.ast(fileContents);
|
26
|
-
const updatedContents = updateFile(fileAst, fileContents);
|
27
|
-
if (updatedContents) {
|
28
|
-
tree.write(path, updatedContents);
|
29
|
-
}
|
30
|
-
}
|
31
|
-
});
|
32
|
-
yield (0, devkit_1.formatFiles)(tree);
|
33
|
-
}
|
34
|
-
catch (_a) { }
|
35
|
-
});
|
36
|
-
}
|
37
|
-
exports.default = experimentalToUtilsUpdate;
|
38
|
-
//# sourceMappingURL=experimental-to-utils-rules.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"experimental-to-utils-rules.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/migrations/update-14-4-4/experimental-to-utils-rules.ts"],"names":[],"mappings":";;;AAAA,yCAAuE;AACvE,uDAAoD;AAEpD,SAAS,UAAU,CAAC,OAAY,EAAE,YAAoB;IACpD,MAAM,eAAe,GAAU,IAAA,iBAAO,EACpC,OAAO,EACP,8EAA8E,CAC/E,CAAC;IACF,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;QAChC,OAAO;KACR;IACD,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,CACtC,uCAAuC,CACxC,CAAC;IACF,IAAI,mBAAmB,GAAG,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACjD,mBAAmB,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,0BAA0B,CAAC;KACtE;IACD,mBAAmB,IAAI,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/D,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED,SAA8B,yBAAyB,CAAC,IAAU;;QAChE,IAAI;YACF,IAAA,6BAAoB,EAAC,IAAI,EAAE,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE;gBACxD,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;oBACxB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;oBACvD,MAAM,OAAO,GAAG,iBAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;oBAE1C,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;oBAC1D,IAAI,eAAe,EAAE;wBACnB,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;qBACnC;iBACF;YACH,CAAC,CAAC,CAAC;YAEH,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAAC,WAAM,GAAE;IACZ,CAAC;CAAA;AAhBD,4CAgBC"}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const tslib_1 = require("tslib");
|
4
|
-
const devkit_1 = require("@nrwl/devkit");
|
5
|
-
const eslint_file_1 = require("../../generators/utils/eslint-file");
|
6
|
-
const eslint_targets_1 = require("../../generators/utils/eslint-targets");
|
7
|
-
function addEslintInputs(tree) {
|
8
|
-
var _a, _b, _c, _d;
|
9
|
-
var _e;
|
10
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
11
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
12
|
-
const globalEslintFile = eslint_file_1.eslintConfigFileWhitelist.find((file) => tree.exists(file));
|
13
|
-
if (globalEslintFile && ((_a = nxJson.namedInputs) === null || _a === void 0 ? void 0 : _a.production)) {
|
14
|
-
const productionFileset = new Set(nxJson.namedInputs.production);
|
15
|
-
productionFileset.add(`!{projectRoot}/${globalEslintFile}`);
|
16
|
-
nxJson.namedInputs.production = Array.from(productionFileset);
|
17
|
-
}
|
18
|
-
for (const targetName of (0, eslint_targets_1.getEslintTargets)(tree)) {
|
19
|
-
(_b = nxJson.targetDefaults) !== null && _b !== void 0 ? _b : (nxJson.targetDefaults = {});
|
20
|
-
const lintTargetDefaults = ((_c = (_e = nxJson.targetDefaults)[targetName]) !== null && _c !== void 0 ? _c : (_e[targetName] = {}));
|
21
|
-
(_d = lintTargetDefaults.inputs) !== null && _d !== void 0 ? _d : (lintTargetDefaults.inputs = [
|
22
|
-
'default',
|
23
|
-
...(globalEslintFile
|
24
|
-
? [(0, devkit_1.joinPathFragments)('{workspaceRoot}', globalEslintFile)]
|
25
|
-
: []),
|
26
|
-
]);
|
27
|
-
}
|
28
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
29
|
-
yield (0, devkit_1.formatFiles)(tree);
|
30
|
-
});
|
31
|
-
}
|
32
|
-
exports.default = addEslintInputs;
|
33
|
-
//# sourceMappingURL=add-eslint-inputs.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"add-eslint-inputs.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/migrations/update-15-0-0/add-eslint-inputs.ts"],"names":[],"mappings":";;;AAAA,yCAMsB;AACtB,oEAA+E;AAC/E,0EAAyE;AAEzE,SAA8B,eAAe,CAAC,IAAU;;;;QACtD,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;QAEhC,MAAM,gBAAgB,GAAG,uCAAyB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAC/D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAClB,CAAC;QAEF,IAAI,gBAAgB,KAAI,MAAA,MAAM,CAAC,WAAW,0CAAE,UAAU,CAAA,EAAE;YACtD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;YAEjE,iBAAiB,CAAC,GAAG,CAAC,kBAAkB,gBAAgB,EAAE,CAAC,CAAC;YAE5D,MAAM,CAAC,WAAW,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;SAC/D;QAED,KAAK,MAAM,UAAU,IAAI,IAAA,iCAAgB,EAAC,IAAI,CAAC,EAAE;YAC/C,MAAA,MAAM,CAAC,cAAc,oCAArB,MAAM,CAAC,cAAc,GAAK,EAAE,EAAC;YAE7B,MAAM,kBAAkB,GAAG,aAAC,MAAM,CAAC,cAAc,EAAC,UAAU,wCAAV,UAAU,IAAM,EAAE,EAAC,CAAC;YAEtE,MAAA,kBAAkB,CAAC,MAAM,oCAAzB,kBAAkB,CAAC,MAAM,GAAK;gBAC5B,SAAS;gBACT,GAAG,CAAC,gBAAgB;oBAClB,CAAC,CAAC,CAAC,IAAA,0BAAiB,EAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;oBAC1D,CAAC,CAAC,EAAE,CAAC;aACR,EAAC;SACH;QAED,IAAA,qBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE3B,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;;CACzB;AA/BD,kCA+BC"}
|
@@ -1,42 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const tslib_1 = require("tslib");
|
4
|
-
const devkit_1 = require("@nrwl/devkit");
|
5
|
-
const eslint_file_1 = require("../../generators/utils/eslint-file");
|
6
|
-
const eslint_targets_1 = require("../../generators/utils/eslint-targets");
|
7
|
-
function addEslintIgnore(tree) {
|
8
|
-
var _a, _b;
|
9
|
-
var _c;
|
10
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
11
|
-
const nxJson = (0, devkit_1.readJson)(tree, 'nx.json');
|
12
|
-
const globalEslintFile = eslint_file_1.eslintConfigFileWhitelist.find((file) => tree.exists(file));
|
13
|
-
if (globalEslintFile) {
|
14
|
-
if (tree.exists('.eslintignore')) {
|
15
|
-
const content = tree.read('.eslintignore', 'utf-8');
|
16
|
-
if (!content.includes('node_modules')) {
|
17
|
-
tree.write('.eslintignore', `node_modules\n${content}`);
|
18
|
-
}
|
19
|
-
}
|
20
|
-
else {
|
21
|
-
tree.write('.eslintignore', 'node_modules\n');
|
22
|
-
}
|
23
|
-
for (const targetName of (0, eslint_targets_1.getEslintTargets)(tree)) {
|
24
|
-
(_a = nxJson.targetDefaults) !== null && _a !== void 0 ? _a : (nxJson.targetDefaults = {});
|
25
|
-
const lintTargetDefaults = ((_b = (_c = nxJson.targetDefaults)[targetName]) !== null && _b !== void 0 ? _b : (_c[targetName] = {}));
|
26
|
-
const lintIgnorePath = (0, devkit_1.joinPathFragments)('{workspaceRoot}', globalEslintFile);
|
27
|
-
if (lintTargetDefaults.inputs) {
|
28
|
-
if (!lintTargetDefaults.inputs.includes(lintIgnorePath)) {
|
29
|
-
lintTargetDefaults.inputs.push(lintIgnorePath);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
else {
|
33
|
-
lintTargetDefaults.inputs = ['default', lintIgnorePath];
|
34
|
-
}
|
35
|
-
}
|
36
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
37
|
-
yield (0, devkit_1.formatFiles)(tree);
|
38
|
-
}
|
39
|
-
});
|
40
|
-
}
|
41
|
-
exports.default = addEslintIgnore;
|
42
|
-
//# sourceMappingURL=add-eslint-ignore.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"add-eslint-ignore.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/migrations/update-15-7-1/add-eslint-ignore.ts"],"names":[],"mappings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AAM,GAAG,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;iBACzD;aACF;YAED,IAAA,qBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC3B,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;;CACF;AAtCD,kCAsCC"}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.convertTslintNxRuleToEslintNxRule = void 0;
|
4
|
-
function convertTSLintRuleSeverity(tslintConfig, tslintSeverity) {
|
5
|
-
if (tslintSeverity === true) {
|
6
|
-
tslintSeverity = 'default';
|
7
|
-
}
|
8
|
-
if (tslintSeverity === false) {
|
9
|
-
tslintSeverity = 'off';
|
10
|
-
}
|
11
|
-
if (tslintSeverity === 'default') {
|
12
|
-
tslintSeverity = tslintConfig.defaultSeverity || 'error';
|
13
|
-
}
|
14
|
-
const narrowedTslintSeverity = tslintSeverity;
|
15
|
-
return narrowedTslintSeverity === 'warning' ? 'warn' : narrowedTslintSeverity;
|
16
|
-
}
|
17
|
-
const NX_TSLINT_RULE_NAME = 'nx-enforce-module-boundaries';
|
18
|
-
function convertTslintNxRuleToEslintNxRule(tslintJson) {
|
19
|
-
var _a;
|
20
|
-
/**
|
21
|
-
* TSLint supports a number of different formats for rule configuration
|
22
|
-
*/
|
23
|
-
const existingRuleDefinition = (_a = tslintJson === null || tslintJson === void 0 ? void 0 : tslintJson.rules) === null || _a === void 0 ? void 0 : _a[NX_TSLINT_RULE_NAME];
|
24
|
-
if (!existingRuleDefinition) {
|
25
|
-
return null;
|
26
|
-
}
|
27
|
-
let existingRuleSeverity = 'error';
|
28
|
-
let existingRuleConfig = {
|
29
|
-
enforceBuildableLibDependency: true,
|
30
|
-
allow: [],
|
31
|
-
depConstraints: [
|
32
|
-
{
|
33
|
-
sourceTag: '*',
|
34
|
-
onlyDependOnLibsWithTags: ['*'],
|
35
|
-
},
|
36
|
-
],
|
37
|
-
};
|
38
|
-
if (Array.isArray(existingRuleDefinition)) {
|
39
|
-
existingRuleSeverity = existingRuleDefinition[0];
|
40
|
-
existingRuleConfig = existingRuleDefinition[1];
|
41
|
-
}
|
42
|
-
else if (typeof existingRuleDefinition === 'object' &&
|
43
|
-
existingRuleDefinition.severity) {
|
44
|
-
existingRuleSeverity = existingRuleDefinition.severity;
|
45
|
-
if (Array.isArray(existingRuleDefinition.options) &&
|
46
|
-
existingRuleDefinition.options[0]) {
|
47
|
-
existingRuleConfig = existingRuleDefinition.options[0];
|
48
|
-
}
|
49
|
-
}
|
50
|
-
const ruleSeverity = convertTSLintRuleSeverity(tslintJson, existingRuleSeverity);
|
51
|
-
return {
|
52
|
-
ruleName: '@nrwl/nx/enforce-module-boundaries',
|
53
|
-
ruleConfig: [ruleSeverity, existingRuleConfig],
|
54
|
-
};
|
55
|
-
}
|
56
|
-
exports.convertTslintNxRuleToEslintNxRule = convertTslintNxRuleToEslintNxRule;
|
57
|
-
//# sourceMappingURL=convert-nx-enforce-module-boundaries-rule.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"convert-nx-enforce-module-boundaries-rule.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/utils/convert-tslint-to-eslint/convert-nx-enforce-module-boundaries-rule.ts"],"names":[],"mappings":";;;AAQA,SAAS,yBAAyB,CAChC,YAAiB,EACjB,cAAkC;IAElC,IAAI,cAAc,KAAK,IAAI,EAAE;QAC3B,cAAc,GAAG,SAAS,CAAC;KAC5B;IACD,IAAI,cAAc,KAAK,KAAK,EAAE;QAC5B,cAAc,GAAG,KAAK,CAAC;KACxB;IACD,IAAI,cAAc,KAAK,SAAS,EAAE;QAChC,cAAc,GAAG,YAAY,CAAC,eAAe,IAAI,OAAO,CAAC;KAC1D;IACD,MAAM,sBAAsB,GAC1B,cAAoD,CAAC;IACvD,OAAO,sBAAsB,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAs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devkit';
|
2
|
-
import type { Linter as ESLintLinter } from 'eslint';
|
3
|
-
import type { TSLintRuleOptions } from 'tslint-to-eslint-config';
|
4
|
-
export declare function convertToESLintConfig(pathToTslintJson: string, tslintJson: Record<string, unknown>, ignoreExtendsVals: string[]): Promise<{
|
5
|
-
convertedESLintConfig: ESLintLinter.Config;
|
6
|
-
unconvertedTSLintRules: TSLintRuleOptions[];
|
7
|
-
ensureESLintPlugins: string[];
|
8
|
-
}>;
|
9
|
-
export declare function convertTSLintDisableCommentsForProject(tree: Tree, projectName: string): void;
|
@@ -1,152 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.convertTSLintDisableCommentsForProject = exports.convertToESLintConfig = void 0;
|
4
|
-
const tslib_1 = require("tslib");
|
5
|
-
const devkit_1 = require("@nrwl/devkit");
|
6
|
-
const child_process_1 = require("child_process");
|
7
|
-
const tmp_1 = require("tmp");
|
8
|
-
const versions_1 = require("../versions");
|
9
|
-
let tslintToEslint;
|
10
|
-
function getConvertToEslintConfig() {
|
11
|
-
if (tslintToEslint) {
|
12
|
-
return tslintToEslint;
|
13
|
-
}
|
14
|
-
try {
|
15
|
-
// This is usually not possible during runtime but makes it easy to mock in tests
|
16
|
-
return require('tslint-to-eslint-config');
|
17
|
-
}
|
18
|
-
catch (_a) { }
|
19
|
-
/**
|
20
|
-
* In order to avoid all users of Nx needing to have tslint-to-eslint-config (and therefore tslint)
|
21
|
-
* in their node_modules, we dynamically install and uninstall the library as part of the conversion
|
22
|
-
* process.
|
23
|
-
*
|
24
|
-
* NOTE: By taking this approach we have to sacrifice dry-run capabilities for this generator.
|
25
|
-
*/
|
26
|
-
const tempDir = (0, tmp_1.dirSync)().name;
|
27
|
-
(0, child_process_1.execSync)(`${(0, devkit_1.getPackageManagerCommand)().addDev} tslint-to-eslint-config@${versions_1.tslintToEslintConfigVersion}`, {
|
28
|
-
cwd: tempDir,
|
29
|
-
stdio: [0, 1, 2],
|
30
|
-
});
|
31
|
-
tslintToEslint = require(require.resolve('tslint-to-eslint-config', {
|
32
|
-
paths: [tempDir],
|
33
|
-
}));
|
34
|
-
return tslintToEslint;
|
35
|
-
}
|
36
|
-
function convertToESLintConfig(pathToTslintJson, tslintJson, ignoreExtendsVals) {
|
37
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
38
|
-
/**
|
39
|
-
* We need to avoid a direct dependency on tslint-to-eslint-config
|
40
|
-
* and ensure we are only resolving the dependency from the user's
|
41
|
-
* node_modules on demand (it will be installed as part of the
|
42
|
-
* conversion generator).
|
43
|
-
*/
|
44
|
-
const { createESLintConfiguration, findReportedConfiguration, joinConfigConversionResults, } = getConvertToEslintConfig();
|
45
|
-
const updatedTSLintJson = tslintJson;
|
46
|
-
/**
|
47
|
-
* If ignoreExtendsVals are provided, strip them from the config
|
48
|
-
* and commit the result to disk per the notes below.
|
49
|
-
*/
|
50
|
-
if (ignoreExtendsVals.length && updatedTSLintJson.extends) {
|
51
|
-
if (typeof updatedTSLintJson.extends === 'string' &&
|
52
|
-
ignoreExtendsVals.includes(updatedTSLintJson.extends)) {
|
53
|
-
delete updatedTSLintJson.extends;
|
54
|
-
}
|
55
|
-
if (Array.isArray(updatedTSLintJson.extends)) {
|
56
|
-
updatedTSLintJson.extends = updatedTSLintJson.extends.filter((ext) => !ignoreExtendsVals.includes(ext));
|
57
|
-
}
|
58
|
-
/**
|
59
|
-
* The reasons we need to interact with the filesystem here:
|
60
|
-
*
|
61
|
-
* 1) The result of the tslint CLI flag `--print-config` is needed for the
|
62
|
-
* conversion process, and unfortunately no equivalent Node API was ever
|
63
|
-
* added to tslint, so the tslint CLI needs to always read from disk.
|
64
|
-
*
|
65
|
-
* 2) When converting project configs, we need to strip the extends path
|
66
|
-
* which corresponds to the workspace's root config, otherwise all of the
|
67
|
-
* root config's rules will be included in the resultant eslint config for
|
68
|
-
* the project. The interaction with the filesystem is needed because of
|
69
|
-
* point (1) above - we need to strip the relevant extends and commit that
|
70
|
-
* change to disk before the tslint CLI reads the config file.
|
71
|
-
*/
|
72
|
-
(0, devkit_1.writeJsonFile)(pathToTslintJson, updatedTSLintJson);
|
73
|
-
}
|
74
|
-
const reportedConfiguration = yield findReportedConfiguration('npx tslint --print-config', pathToTslintJson);
|
75
|
-
if (reportedConfiguration instanceof Error) {
|
76
|
-
if (reportedConfiguration.message.includes('unknown option `--print-config')) {
|
77
|
-
throw new Error('\nError: TSLint v5.18 required in order to run this schematic. Please update your version and try again.\n');
|
78
|
-
}
|
79
|
-
/**
|
80
|
-
* Make a print-config issue easier to understand for the end user.
|
81
|
-
* This error could occur if, for example, the user does not have a TSLint plugin installed correctly that they
|
82
|
-
* reference in their config.
|
83
|
-
*/
|
84
|
-
const printConfigFailureMessageStart = 'Command failed: npx tslint --print-config "tslint.json"';
|
85
|
-
if (reportedConfiguration.message.startsWith(printConfigFailureMessageStart)) {
|
86
|
-
throw new Error(`\nThere was a critical error when trying to inspect your tslint.json: \n${reportedConfiguration.message.replace(printConfigFailureMessageStart, '')}`);
|
87
|
-
}
|
88
|
-
throw new Error(`Unexpected error: ${reportedConfiguration.message}`);
|
89
|
-
}
|
90
|
-
const originalConfigurations = {
|
91
|
-
tslint: {
|
92
|
-
full: reportedConfiguration,
|
93
|
-
raw: updatedTSLintJson,
|
94
|
-
},
|
95
|
-
};
|
96
|
-
const summarizedConfiguration = yield createESLintConfiguration(originalConfigurations);
|
97
|
-
/**
|
98
|
-
* We are expecting it to not find a converter for nx-enforce-module-boundaries
|
99
|
-
* and we will explicitly replace it with the ESLint equivalent ourselves.
|
100
|
-
*/
|
101
|
-
if (summarizedConfiguration.missing) {
|
102
|
-
summarizedConfiguration.missing = summarizedConfiguration.missing.filter((missingRuleData) => missingRuleData.ruleName !== 'nx-enforce-module-boundaries');
|
103
|
-
}
|
104
|
-
// These are already covered by our extraEslintDependencies which get installed by the schematic
|
105
|
-
const expectedESLintPlugins = [
|
106
|
-
'@angular-eslint/eslint-plugin',
|
107
|
-
'@angular-eslint/eslint-plugin-template',
|
108
|
-
];
|
109
|
-
const convertedESLintConfig = joinConfigConversionResults(summarizedConfiguration, originalConfigurations);
|
110
|
-
if (Array.isArray(convertedESLintConfig.extends) &&
|
111
|
-
convertedESLintConfig.extends.length) {
|
112
|
-
// Ignore any tslint-to-eslint-config default extends that do not apply to Nx
|
113
|
-
convertedESLintConfig.extends = convertedESLintConfig.extends.filter((ext) => !ext.startsWith('prettier'));
|
114
|
-
if (convertedESLintConfig.extends.length === 0) {
|
115
|
-
delete convertedESLintConfig.extends;
|
116
|
-
}
|
117
|
-
}
|
118
|
-
return {
|
119
|
-
convertedESLintConfig,
|
120
|
-
unconvertedTSLintRules: summarizedConfiguration.missing,
|
121
|
-
ensureESLintPlugins: Array.from(summarizedConfiguration.plugins).filter((pluginName) => !expectedESLintPlugins.includes(pluginName)),
|
122
|
-
};
|
123
|
-
});
|
124
|
-
}
|
125
|
-
exports.convertToESLintConfig = convertToESLintConfig;
|
126
|
-
function likelyContainsTSLintComment(fileContent) {
|
127
|
-
return fileContent.includes('tslint:');
|
128
|
-
}
|
129
|
-
function convertTSLintDisableCommentsForProject(tree, projectName) {
|
130
|
-
/**
|
131
|
-
* We need to avoid a direct dependency on tslint-to-eslint-config
|
132
|
-
* and ensure we are only resolving the dependency from the user's
|
133
|
-
* node_modules on demand (it will be installed as part of the
|
134
|
-
* conversion generator).
|
135
|
-
*/
|
136
|
-
const { convertFileComments } = getConvertToEslintConfig();
|
137
|
-
const { root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
138
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree, root, (filePath) => {
|
139
|
-
if (!filePath.endsWith('.ts')) {
|
140
|
-
return;
|
141
|
-
}
|
142
|
-
const fileContent = tree.read(filePath, 'utf-8');
|
143
|
-
// Avoid updating files if we don't have to
|
144
|
-
if (!fileContent || !likelyContainsTSLintComment(fileContent)) {
|
145
|
-
return;
|
146
|
-
}
|
147
|
-
const updatedFileContent = convertFileComments({ fileContent, filePath });
|
148
|
-
tree.write(filePath, updatedFileContent);
|
149
|
-
});
|
150
|
-
}
|
151
|
-
exports.convertTSLintDisableCommentsForProject = convertTSLintDisableCommentsForProject;
|
152
|
-
//# sourceMappingURL=convert-to-eslint-config.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"convert-to-eslint-config.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/utils/convert-tslint-to-eslint/convert-to-eslint-config.ts"],"names":[],"mappings":";;;;AAAA,yCAKsB;AAEtB,iDAAyC;AAEzC,6BAA8B;AAK9B,0CAA0D;AAE1D,IAAI,cAAc,CAAC;AACnB,SAAS,wBAAwB;IAC/B,IAAI,cAAc,EAAE;QAClB,OAAO,cAAc,CAAC;KACvB;IAED,IAAI;QACF,iFAAiF;QACjF,OAAO,OAAO,CAAC,yBAAyB,CAAC,CAAC;KAC3C;IAAC,WAAM,GAAE;IAEV;;;;;;OAMG;IACH,MAAM,OAAO,GAAG,IAAA,aAAO,GAAE,CAAC,IAAI,CAAC;IAC/B,IAAA,wBAAQ,EACN,GACE,IAAA,iCAAwB,GAAE,CAAC,MAC7B,4BAA4B,sCAA2B,EAAE,EACzD;QACE,GAAG,EAAE,OAAO;QACZ,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACjB,CACF,CAAC;IAEF,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,yBAAyB,EAAE;QAClE,KAAK,EAAE,CAAC,OAAO,CAAC;KACjB,CAAC,CAAC,CAAC;IACJ,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,SAAsB,qBAAqB,CACzC,gBAAwB,EACxB,UAAmC,EACnC,iBAA2B;;QAM3B;;;;;WAKG;QACH,MAAM,EACJ,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,GAC5B,GAAG,wBAAwB,EAAE,CAAC;QAE/B,MAAM,iBAAiB,GAAG,UAAU,CAAC;QACrC;;;W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