@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.
- 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,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lintProjectGenerator = exports.mapLintPattern = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
-
const eslint_file_1 = require("../utils/eslint-file");
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const init_1 = require("../init/init");
|
|
9
|
-
const init_migration_1 = require("../init/init-migration");
|
|
10
|
-
const project_configuration_1 = require("nx/src/generators/utils/project-configuration");
|
|
11
|
-
function createEsLintConfiguration(tree, projectConfig, setParserOptionsProject) {
|
|
12
|
-
const eslintConfig = (0, eslint_file_1.findEslintFile)(tree);
|
|
13
|
-
(0, devkit_1.writeJson)(tree, (0, path_1.join)(projectConfig.root, `.eslintrc.json`), {
|
|
14
|
-
extends: eslintConfig
|
|
15
|
-
? [`${(0, devkit_1.offsetFromRoot)(projectConfig.root)}${eslintConfig}`]
|
|
16
|
-
: undefined,
|
|
17
|
-
// Include project files to be linted since the global one excludes all files.
|
|
18
|
-
ignorePatterns: ['!**/*'],
|
|
19
|
-
overrides: [
|
|
20
|
-
{
|
|
21
|
-
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
|
|
22
|
-
/**
|
|
23
|
-
* NOTE: We no longer set parserOptions.project by default when creating new projects.
|
|
24
|
-
*
|
|
25
|
-
* We have observed that users rarely add rules requiring type-checking to their Nx workspaces, and therefore
|
|
26
|
-
* do not actually need the capabilites which parserOptions.project provides. When specifying parserOptions.project,
|
|
27
|
-
* typescript-eslint needs to create full TypeScript Programs for you. When omitting it, it can perform a simple
|
|
28
|
-
* parse (and AST tranformation) of the source files it encounters during a lint run, which is much faster and much
|
|
29
|
-
* less memory intensive.
|
|
30
|
-
*
|
|
31
|
-
* In the rare case that users attempt to add rules requiring type-checking to their setup later on (and haven't set
|
|
32
|
-
* parserOptions.project), the executor will attempt to look for the particular error typescript-eslint gives you
|
|
33
|
-
* and provide feedback to the user.
|
|
34
|
-
*/
|
|
35
|
-
parserOptions: !setParserOptionsProject
|
|
36
|
-
? undefined
|
|
37
|
-
: {
|
|
38
|
-
project: [`${projectConfig.root}/tsconfig.*?.json`],
|
|
39
|
-
},
|
|
40
|
-
/**
|
|
41
|
-
* Having an empty rules object present makes it more obvious to the user where they would
|
|
42
|
-
* extend things from if they needed to
|
|
43
|
-
*/
|
|
44
|
-
rules: {},
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
files: ['*.ts', '*.tsx'],
|
|
48
|
-
rules: {},
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
files: ['*.js', '*.jsx'],
|
|
52
|
-
rules: {},
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
function mapLintPattern(projectRoot, extension, rootProject) {
|
|
58
|
-
const infix = rootProject ? 'src/' : '';
|
|
59
|
-
return `${projectRoot}/${infix}**/*.${extension}`;
|
|
60
|
-
}
|
|
61
|
-
exports.mapLintPattern = mapLintPattern;
|
|
62
|
-
function lintProjectGenerator(tree, options) {
|
|
63
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const installTask = (0, init_1.lintInitGenerator)(tree, {
|
|
65
|
-
linter: options.linter,
|
|
66
|
-
unitTestRunner: options.unitTestRunner,
|
|
67
|
-
skipPackageJson: options.skipPackageJson,
|
|
68
|
-
rootProject: options.rootProject,
|
|
69
|
-
});
|
|
70
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
71
|
-
projectConfig.targets['lint'] = {
|
|
72
|
-
executor: '@nrwl/linter:eslint',
|
|
73
|
-
outputs: ['{options.outputFile}'],
|
|
74
|
-
options: {
|
|
75
|
-
lintFilePatterns: options.eslintFilePatterns,
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
// we are adding new project which is not the root project or
|
|
79
|
-
// companion e2e app so we should check if migration to
|
|
80
|
-
// monorepo style is needed
|
|
81
|
-
if (!options.rootProject) {
|
|
82
|
-
const projects = {};
|
|
83
|
-
(0, project_configuration_1.getProjects)(tree).forEach((v, k) => (projects[k] = v));
|
|
84
|
-
if (isMigrationToMonorepoNeeded(projects, tree)) {
|
|
85
|
-
// we only migrate project configurations that have been created
|
|
86
|
-
const filteredProjects = [];
|
|
87
|
-
Object.entries(projects).forEach(([name, project]) => {
|
|
88
|
-
if (name !== options.project) {
|
|
89
|
-
filteredProjects.push(project);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
(0, init_migration_1.migrateConfigToMonorepoStyle)(filteredProjects, tree, options.unitTestRunner);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// our root `.eslintrc` is already the project config, so we should not override it
|
|
96
|
-
// additionally, the companion e2e app would have `rootProject: true`
|
|
97
|
-
// so we need to check for the root path as well
|
|
98
|
-
if (!options.rootProject || projectConfig.root !== '.') {
|
|
99
|
-
createEsLintConfiguration(tree, projectConfig, options.setParserOptionsProject);
|
|
100
|
-
}
|
|
101
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
|
102
|
-
if (!options.skipFormat) {
|
|
103
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
104
|
-
}
|
|
105
|
-
return installTask;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
exports.lintProjectGenerator = lintProjectGenerator;
|
|
109
|
-
/**
|
|
110
|
-
* Detect based on the state of lint target configuration of the root project
|
|
111
|
-
* if we should migrate eslint configs to monorepo style
|
|
112
|
-
*
|
|
113
|
-
* @param tree
|
|
114
|
-
* @returns
|
|
115
|
-
*/
|
|
116
|
-
function isMigrationToMonorepoNeeded(projects, tree) {
|
|
117
|
-
// the base config is already created, migration has been done
|
|
118
|
-
if (tree.exists('.eslintrc.base.json')) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
const configs = Object.values(projects);
|
|
122
|
-
if (configs.length === 1) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
// get root project
|
|
126
|
-
const rootProject = configs.find((p) => p.root === '.');
|
|
127
|
-
if (!rootProject || !rootProject.targets) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
// find if root project has lint target
|
|
131
|
-
const lintTarget = (0, init_migration_1.findLintTarget)(rootProject);
|
|
132
|
-
if (!lintTarget) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
//# sourceMappingURL=lint-project.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lint-project.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/lint-project/lint-project.ts"],"names":[],"mappings":";;;;AACA,yCAMsB;AAGtB,sDAAsD;AACtD,+BAA4B;AAC5B,uCAAiD;AACjD,2DAGgC;AAChC,yFAA4E;AAc5E,SAAS,yBAAyB,CAChC,IAAU,EACV,aAAmC,EACnC,uBAAgC;IAEhC,MAAM,YAAY,GAAG,IAAA,4BAAc,EAAC,IAAI,CAAC,CAAC;IAC1C,IAAA,kBAAS,EAAC,IAAI,EAAE,IAAA,WAAI,EAAC,aAAa,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE;QAC1D,OAAO,EAAE,YAAY;YACnB,CAAC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CAAC;QAEjE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CAAA;AA5DD,oDA4DC;AAED;;;;;;GAMG;AACH,SAAS,2BAA2B,CAClC,QAA8C,EAC9C,IAAU;IAEV,8DAA8D;IAC9D,IAAI,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,EAAE;QACtC,OAAO,KAAK,CAAC;KACd;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC;KACd;IAED,mBAAmB;IACnB,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;QACxC,OAAO,KAAK,CAAC;KACd;IACD,uCAAuC;IACvC,MAAM,UAAU,GAAG,IAAA,+BAAc,EAAC,WAAW,CAAC,CAAC;IAC/C,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findEslintFile = exports.baseEsLintConfigFile = exports.eslintConfigFileWhitelist = void 0;
|
|
4
|
-
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
-
exports.eslintConfigFileWhitelist = [
|
|
6
|
-
'.eslintrc',
|
|
7
|
-
'.eslintrc.js',
|
|
8
|
-
'.eslintrc.cjs',
|
|
9
|
-
'.eslintrc.yaml',
|
|
10
|
-
'.eslintrc.yml',
|
|
11
|
-
'.eslintrc.json',
|
|
12
|
-
'eslint.config.js', // new format that requires `ESLINT_USE_FLAT_CONFIG=true`
|
|
13
|
-
];
|
|
14
|
-
exports.baseEsLintConfigFile = '.eslintrc.base.json';
|
|
15
|
-
function findEslintFile(tree, projectRoot = '') {
|
|
16
|
-
if (projectRoot === '' && tree.exists(exports.baseEsLintConfigFile)) {
|
|
17
|
-
return exports.baseEsLintConfigFile;
|
|
18
|
-
}
|
|
19
|
-
for (const file of exports.eslintConfigFileWhitelist) {
|
|
20
|
-
if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, file))) {
|
|
21
|
-
return file;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
exports.findEslintFile = findEslintFile;
|
|
27
|
-
//# sourceMappingURL=eslint-file.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eslint-file.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/utils/eslint-file.ts"],"names":[],"mappings":";;;AAAA,yCAAuD;AAE1C,QAAA,yBAAyB,GAAG;IACvC,WAAW;IACX,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,gBAAgB;IAChB,kBAAkB,EAAE,yDAAyD;CAC9E,CAAC;AAEW,QAAA,oBAAoB,GAAG,qBAAqB,CAAC;AAE1D,SAAgB,cAAc,CAAC,IAAU,EAAE,WAAW,GAAG,EAAE;IACzD,IAAI,WAAW,KAAK,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,4BAAoB,CAAC,EAAE;QAC3D,OAAO,4BAAoB,CAAC;KAC7B;IACD,KAAK,MAAM,IAAI,IAAI,iCAAyB,EAAE;QAC5C,IAAI,IAAI,CAAC,MAAM,CAAC,IAAA,0BAAiB,EAAC,WAAW,EAAE,IAAI,CAAC,CAAC,EAAE;YACrD,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAXD,wCAWC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEslintTargets = void 0;
|
|
4
|
-
const executor_options_utils_1 = require("@nrwl/devkit/src/generators/executor-options-utils");
|
|
5
|
-
function getEslintTargets(tree) {
|
|
6
|
-
const eslintTargetNames = new Set();
|
|
7
|
-
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/linter:eslint', (_, __, target) => {
|
|
8
|
-
eslintTargetNames.add(target);
|
|
9
|
-
});
|
|
10
|
-
return eslintTargetNames;
|
|
11
|
-
}
|
|
12
|
-
exports.getEslintTargets = getEslintTargets;
|
|
13
|
-
//# sourceMappingURL=eslint-targets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eslint-targets.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/utils/eslint-targets.ts"],"names":[],"mappings":";;;AACA,+FAA4F;AAE5F,SAAgB,gBAAgB,CAAC,IAAU;IACzC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC5C,IAAA,+CAAsB,EAAC,IAAI,EAAE,qBAAqB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;QACpE,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAND,4CAMC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Linter = void 0;
|
|
4
|
-
var Linter;
|
|
5
|
-
(function (Linter) {
|
|
6
|
-
Linter["EsLint"] = "eslint";
|
|
7
|
-
Linter["None"] = "none";
|
|
8
|
-
})(Linter = exports.Linter || (exports.Linter = {}));
|
|
9
|
-
//# sourceMappingURL=linter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"linter.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/utils/linter.ts"],"names":[],"mappings":";;;AAAA,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,GAAN,cAAM,KAAN,cAAM,QAGjB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
-
import { rule, RULE_NAME } from './<%= name %>';
|
|
3
|
-
|
|
4
|
-
const ruleTester = new TSESLint.RuleTester({
|
|
5
|
-
parser: require.resolve('@typescript-eslint/parser'),
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
ruleTester.run(RULE_NAME, rule, {
|
|
9
|
-
valid: [`const example = true;`],
|
|
10
|
-
invalid: [],
|
|
11
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file sets you up with structure needed for an ESLint rule.
|
|
3
|
-
*
|
|
4
|
-
* It leverages utilities from @typescript-eslint to allow TypeScript to
|
|
5
|
-
* provide autocompletions etc for the configuration.
|
|
6
|
-
*
|
|
7
|
-
* Your rule's custom logic will live within the create() method below
|
|
8
|
-
* and you can learn more about writing ESLint rules on the official guide:
|
|
9
|
-
*
|
|
10
|
-
* https://eslint.org/docs/developer-guide/working-with-rules
|
|
11
|
-
*
|
|
12
|
-
* You can also view many examples of existing rules here:
|
|
13
|
-
*
|
|
14
|
-
* https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/rules
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
18
|
-
|
|
19
|
-
// NOTE: The rule will be available in ESLint configs as "@nrwl/nx/workspace/<%= name %>"
|
|
20
|
-
export const RULE_NAME = '<%= name %>';
|
|
21
|
-
|
|
22
|
-
export const rule = ESLintUtils.RuleCreator(() => __filename)({
|
|
23
|
-
name: RULE_NAME,
|
|
24
|
-
meta: {
|
|
25
|
-
type: 'problem',
|
|
26
|
-
docs: {
|
|
27
|
-
description: ``,
|
|
28
|
-
recommended: 'error',
|
|
29
|
-
},
|
|
30
|
-
schema: [],
|
|
31
|
-
messages: {},
|
|
32
|
-
},
|
|
33
|
-
defaultOptions: [],
|
|
34
|
-
create(context) {
|
|
35
|
-
return {};
|
|
36
|
-
},
|
|
37
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "NxWorkspaceRule",
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"title": "Create a new Workspace Lint Rule",
|
|
6
|
-
"description": "Create a new Workspace Lint Rule.",
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"name": {
|
|
10
|
-
"type": "string",
|
|
11
|
-
"description": "The name of the new rule.",
|
|
12
|
-
"$default": {
|
|
13
|
-
"$source": "argv",
|
|
14
|
-
"index": 0
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"directory": {
|
|
18
|
-
"type": "string",
|
|
19
|
-
"description": "Create the rule under this directory within `tools/eslint-rules/` (can be nested).",
|
|
20
|
-
"alias": "dir",
|
|
21
|
-
"default": "rules"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"required": ["name", "directory"],
|
|
25
|
-
"examplesFile": "../../../docs/workspace-rule-examples.md"
|
|
26
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Tree } from '@nrwl/devkit';
|
|
2
|
-
export interface LintWorkspaceRuleGeneratorOptions {
|
|
3
|
-
name: string;
|
|
4
|
-
directory: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function lintWorkspaceRuleGenerator(tree: Tree, options: LintWorkspaceRuleGeneratorOptions): Promise<any>;
|
|
7
|
-
export declare const lintWorkspaceRuleSchematic: (generatorOptions: LintWorkspaceRuleGeneratorOptions) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lintWorkspaceRuleSchematic = exports.lintWorkspaceRuleGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
-
const string_utils_1 = require("@nrwl/devkit/src/utils/string-utils");
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const ts = require("typescript");
|
|
9
|
-
const workspace_lint_rules_1 = require("../../utils/workspace-lint-rules");
|
|
10
|
-
const workspace_rules_project_1 = require("../workspace-rules-project/workspace-rules-project");
|
|
11
|
-
function lintWorkspaceRuleGenerator(tree, options) {
|
|
12
|
-
var _a;
|
|
13
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
// Ensure that the workspace rules project has been created
|
|
15
|
-
const projectGeneratorCallback = yield (0, workspace_rules_project_1.lintWorkspaceRulesProjectGenerator)(tree, { skipFormat: true });
|
|
16
|
-
const ruleDir = (0, devkit_1.joinPathFragments)(workspace_lint_rules_1.workspaceLintPluginDir, (_a = options.directory) !== null && _a !== void 0 ? _a : '');
|
|
17
|
-
// Generate the required files for the new rule
|
|
18
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), ruleDir, {
|
|
19
|
-
tmpl: '',
|
|
20
|
-
name: options.name,
|
|
21
|
-
});
|
|
22
|
-
const nameCamelCase = (0, string_utils_1.camelize)(options.name);
|
|
23
|
-
/**
|
|
24
|
-
* Import the new rule into the workspace plugin index.ts and
|
|
25
|
-
* register it ready for use in .eslintrc.json configs.
|
|
26
|
-
*/
|
|
27
|
-
const pluginIndexPath = (0, devkit_1.joinPathFragments)(workspace_lint_rules_1.workspaceLintPluginDir, 'index.ts');
|
|
28
|
-
const existingPluginIndexContents = tree.read(pluginIndexPath, 'utf-8');
|
|
29
|
-
const pluginIndexSourceFile = ts.createSourceFile(pluginIndexPath, existingPluginIndexContents, ts.ScriptTarget.Latest, true);
|
|
30
|
-
function findRulesObject(node) {
|
|
31
|
-
if (ts.isPropertyAssignment(node) &&
|
|
32
|
-
ts.isIdentifier(node.name) &&
|
|
33
|
-
node.name.text === 'rules' &&
|
|
34
|
-
ts.isObjectLiteralExpression(node.initializer)) {
|
|
35
|
-
return node.initializer;
|
|
36
|
-
}
|
|
37
|
-
return node.forEachChild(findRulesObject);
|
|
38
|
-
}
|
|
39
|
-
const rulesObject = pluginIndexSourceFile.forEachChild((node) => findRulesObject(node));
|
|
40
|
-
if (rulesObject) {
|
|
41
|
-
const ruleNameSymbol = `${nameCamelCase}Name`;
|
|
42
|
-
const ruleConfigSymbol = nameCamelCase;
|
|
43
|
-
/**
|
|
44
|
-
* If the rules object already has entries, we need to make sure our insertion
|
|
45
|
-
* takes commas into account.
|
|
46
|
-
*/
|
|
47
|
-
let leadingComma = '';
|
|
48
|
-
if (rulesObject.properties.length > 0) {
|
|
49
|
-
if (!rulesObject.properties.hasTrailingComma) {
|
|
50
|
-
leadingComma = ',';
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const newContents = (0, devkit_1.applyChangesToString)(existingPluginIndexContents, [
|
|
54
|
-
{
|
|
55
|
-
type: devkit_1.ChangeType.Insert,
|
|
56
|
-
index: 0,
|
|
57
|
-
text: `import { RULE_NAME as ${ruleNameSymbol}, rule as ${ruleConfigSymbol} } from './${options.directory ? `${options.directory}/` : ''}${options.name}';\n`,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
type: devkit_1.ChangeType.Insert,
|
|
61
|
-
index: rulesObject.getEnd() - 1,
|
|
62
|
-
text: `${leadingComma}[${ruleNameSymbol}]: ${ruleConfigSymbol}\n`,
|
|
63
|
-
},
|
|
64
|
-
]);
|
|
65
|
-
tree.write(pluginIndexPath, newContents);
|
|
66
|
-
}
|
|
67
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
68
|
-
devkit_1.logger.info(`NX Reminder: Once you have finished writing your rule logic, you need to actually enable the rule within an appropriate .eslintrc.json in your workspace, for example:
|
|
69
|
-
|
|
70
|
-
"rules": {
|
|
71
|
-
"@nrwl/nx/workspace/${options.name}": "error"
|
|
72
|
-
}
|
|
73
|
-
`);
|
|
74
|
-
return projectGeneratorCallback;
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
exports.lintWorkspaceRuleGenerator = lintWorkspaceRuleGenerator;
|
|
78
|
-
exports.lintWorkspaceRuleSchematic = (0, devkit_1.convertNxGenerator)(lintWorkspaceRuleGenerator);
|
|
79
|
-
//# sourceMappingURL=workspace-rule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-rule.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/workspace-rule/workspace-rule.ts"],"names":[],"mappings":";;;;AAAA,yCASsB;AACtB,sEAA+D;AAC/D,+BAA4B;AAC5B,iCAAiC;AACjC,2EAA0E;AAC1E,gGAAwG;AAOxG,SAAsB,0BAA0B,CAC9C,IAAU,EACV,OAA0C;;;QAE1C,2DAA2D;QAC3D,MAAM,wBAAwB,GAAG,MAAM,IAAA,4DAAkC,EACvE,IAAI,EACJ,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAC;QAEF,MAAM,OAAO,GAAG,IAAA,0BAAiB,EAC/B,6CAAsB,EACtB,MAAA,OAAO,CAAC,SAAS,mCAAI,EAAE,CACxB,CAAC;QAEF,+CAA+C;QAC/C,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE;YACrD,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,IAAA,uBAAQ,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE7C;;;WAGG;QACH,MAAM,eAAe,GAA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AAa,gBAAgB,cACxE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EAChD,GAAG,OAAO,CAAC,IAAI,MAAM;iBACtB;gBACD;oBACE,IAAI,EAAE,mBAAU,CAAC,MAAM;oBACvB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC;oBAC/B,IAAI,EAAE,GAAG,YAAY,IAAI,cAAc,MAAM,gBAAgB,IAAI;iBAClE;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;SAC1C;QAED,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAExB,eAAM,CAAC,IAAI,CAAC;;;+BAGiB,OAAO,CAAC,IAAI;;CAE1C,CAAC,CAAC;QAED,OAAO,wBAAwB,CAAC;;CACjC;AA/FD,gEA+FC;AAEY,QAAA,0BAA0B,GAAG,IAAA,2BAAkB,EAC1D,0BAA0B,CAC3B,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Import your custom workspace rules at the top of this file.
|
|
3
|
-
*
|
|
4
|
-
* For example:
|
|
5
|
-
*
|
|
6
|
-
* import { RULE_NAME as myCustomRuleName, rule as myCustomRule } from './rules/my-custom-rule';
|
|
7
|
-
*
|
|
8
|
-
* In order to quickly get started with writing rules you can use the
|
|
9
|
-
* following generator command and provide your desired rule name:
|
|
10
|
-
*
|
|
11
|
-
* ```sh
|
|
12
|
-
* npx nx g @nrwl/linter:workspace-rule {{ NEW_RULE_NAME }}
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
module.exports = {
|
|
17
|
-
/**
|
|
18
|
-
* Apply the imported custom rules here.
|
|
19
|
-
*
|
|
20
|
-
* For example (using the example import above):
|
|
21
|
-
*
|
|
22
|
-
* rules: {
|
|
23
|
-
* [myCustomRuleName]: myCustomRule
|
|
24
|
-
* }
|
|
25
|
-
*/
|
|
26
|
-
rules: {}
|
|
27
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "NxWorkspaceRulesProject",
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"title": "Create the Workspace Lint Rules Project",
|
|
6
|
-
"description": "Create the Workspace Lint Rules Project.",
|
|
7
|
-
"type": "object",
|
|
8
|
-
"examples": [
|
|
9
|
-
{
|
|
10
|
-
"command": "nx g @nrwl/linter:workspace-rules-project",
|
|
11
|
-
"description": "Create the Workspace Lint Rules Project"
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
"properties": {
|
|
15
|
-
"skipFormat": {
|
|
16
|
-
"description": "Skip formatting files.",
|
|
17
|
-
"type": "boolean",
|
|
18
|
-
"default": false,
|
|
19
|
-
"x-priority": "internal"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"required": []
|
|
23
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Tree } from '@nrwl/devkit';
|
|
2
|
-
export declare const WORKSPACE_RULES_PROJECT_NAME = "eslint-rules";
|
|
3
|
-
export declare const WORKSPACE_PLUGIN_DIR = "tools/eslint-rules";
|
|
4
|
-
export interface LintWorkspaceRulesProjectGeneratorOptions {
|
|
5
|
-
skipFormat?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function lintWorkspaceRulesProjectGenerator(tree: Tree, options?: LintWorkspaceRulesProjectGeneratorOptions): Promise<any>;
|
|
8
|
-
export declare const lintWorkspaceRulesProjectSchematic: (generatorOptions: LintWorkspaceRulesProjectGeneratorOptions) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lintWorkspaceRulesProjectSchematic = exports.lintWorkspaceRulesProjectGenerator = exports.WORKSPACE_PLUGIN_DIR = exports.WORKSPACE_RULES_PROJECT_NAME = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
-
const js_1 = require("@nrwl/js");
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const workspace_lint_rules_1 = require("../../utils/workspace-lint-rules");
|
|
9
|
-
const versions_1 = require("nx/src/utils/versions");
|
|
10
|
-
const versions_2 = require("../../utils/versions");
|
|
11
|
-
exports.WORKSPACE_RULES_PROJECT_NAME = 'eslint-rules';
|
|
12
|
-
exports.WORKSPACE_PLUGIN_DIR = 'tools/eslint-rules';
|
|
13
|
-
function lintWorkspaceRulesProjectGenerator(tree, options = {}) {
|
|
14
|
-
var _a, _b;
|
|
15
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const { addPropertyToJestConfig, jestProjectGenerator } = (0, devkit_1.ensurePackage)('@nrwl/jest', versions_2.nxVersion);
|
|
17
|
-
// Noop if the workspace rules project already exists
|
|
18
|
-
try {
|
|
19
|
-
(0, devkit_1.readProjectConfiguration)(tree, exports.WORKSPACE_RULES_PROJECT_NAME);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
catch (_c) { }
|
|
23
|
-
// Create the project, the test target is added below by the jest generator
|
|
24
|
-
(0, devkit_1.addProjectConfiguration)(tree, exports.WORKSPACE_RULES_PROJECT_NAME, {
|
|
25
|
-
root: exports.WORKSPACE_PLUGIN_DIR,
|
|
26
|
-
sourceRoot: exports.WORKSPACE_PLUGIN_DIR,
|
|
27
|
-
targets: {},
|
|
28
|
-
});
|
|
29
|
-
// Generate the required files
|
|
30
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), workspace_lint_rules_1.workspaceLintPluginDir, {
|
|
31
|
-
tmpl: '',
|
|
32
|
-
offsetFromRoot: (0, devkit_1.offsetFromRoot)(exports.WORKSPACE_PLUGIN_DIR),
|
|
33
|
-
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, exports.WORKSPACE_PLUGIN_DIR),
|
|
34
|
-
});
|
|
35
|
-
/**
|
|
36
|
-
* Ensure that when workspace rules are updated they cause all projects to be affected for now.
|
|
37
|
-
* TODO: Explore writing a ProjectGraph plugin to make this more surgical.
|
|
38
|
-
*/
|
|
39
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
40
|
-
if ((_b = (_a = nxJson.targetDefaults) === null || _a === void 0 ? void 0 : _a.lint) === null || _b === void 0 ? void 0 : _b.inputs) {
|
|
41
|
-
nxJson.targetDefaults.lint.inputs.push(`{workspaceRoot}/${exports.WORKSPACE_PLUGIN_DIR}/**/*`);
|
|
42
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
43
|
-
}
|
|
44
|
-
// Add jest to the project and return installation task
|
|
45
|
-
const installTask = yield jestProjectGenerator(tree, {
|
|
46
|
-
project: exports.WORKSPACE_RULES_PROJECT_NAME,
|
|
47
|
-
supportTsx: false,
|
|
48
|
-
skipSerializers: true,
|
|
49
|
-
setupFile: 'none',
|
|
50
|
-
compiler: 'tsc',
|
|
51
|
-
skipFormat: true,
|
|
52
|
-
});
|
|
53
|
-
(0, devkit_1.updateJson)(tree, (0, path_1.join)(workspace_lint_rules_1.workspaceLintPluginDir, 'tsconfig.spec.json'), (json) => {
|
|
54
|
-
if (json.include) {
|
|
55
|
-
json.include = json.include.map((v) => {
|
|
56
|
-
if (v.startsWith('src/**')) {
|
|
57
|
-
return v.replace('src/', '');
|
|
58
|
-
}
|
|
59
|
-
return v;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
if (json.exclude) {
|
|
63
|
-
json.exclude = json.exclude.map((v) => {
|
|
64
|
-
if (v.startsWith('src/**')) {
|
|
65
|
-
return v.replace('src/', '');
|
|
66
|
-
}
|
|
67
|
-
return v;
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return json;
|
|
71
|
-
});
|
|
72
|
-
// Add swc dependencies
|
|
73
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@swc-node/register': versions_1.swcNodeVersion, '@swc/core': versions_1.swcCoreVersion });
|
|
74
|
-
// Add extra config to the jest.config.ts file to allow ESLint 8 exports mapping to work with jest
|
|
75
|
-
addPropertyToJestConfig(tree, (0, devkit_1.joinPathFragments)(exports.WORKSPACE_PLUGIN_DIR, 'jest.config.ts'), 'moduleNameMapper', {
|
|
76
|
-
'@eslint/eslintrc': '@eslint/eslintrc/dist/eslintrc-universal.cjs',
|
|
77
|
-
});
|
|
78
|
-
if (!options.skipFormat) {
|
|
79
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
80
|
-
}
|
|
81
|
-
return installTask;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
exports.lintWorkspaceRulesProjectGenerator = lintWorkspaceRulesProjectGenerator;
|
|
85
|
-
exports.lintWorkspaceRulesProjectSchematic = (0, devkit_1.convertNxGenerator)(lintWorkspaceRulesProjectGenerator);
|
|
86
|
-
//# sourceMappingURL=workspace-rules-project.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-rules-project.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/workspace-rules-project/workspace-rules-project.ts"],"names":[],"mappings":";;;;AAAA,yCAcsB;AACtB,iCAAyD;AACzD,+BAA4B;AAC5B,2EAA0E;AAC1E,oDAAuE;AACvE,mDAAiD;AAEpC,QAAA,4BAA4B,GAAG,cAAc,CAAC;AAE9C,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AAMzD,SAAsB,kCAAkC,CACtD,IAAU,EACV,UAAqD,EAAE;;;QAEvD,MAAM,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,GAAG,IAAA,sBAAa,EACrE,YAAY,EACZ,oBAAS,CACV,CAAC;QAEF,qDAAqD;QACrD,IAAI;YACF,IAAA,iCAAwB,EAAC,IAAI,EAAE,oCAA4B,CAAC,CA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AC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBACpC,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;wBAC1B,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;qBAC9B;oBACD,OAAO,CAAC,CAAC;gBACX,CAAC,CAAC,CAAC;aACJ;YACD,IAAI,IAAI,CAAC,OAAO,EAAE;gBAChB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBACpC,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;wBAC1B,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;qBAC9B;oBACD,OAAO,CAAC,CAAC;gBACX,CAAC,CAAC,CAAC;aACJ;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CACF,CAAC;QAEF,uBAAuB;QACvB,IAAA,qCAA4B,EAC1B,IAAI,EACJ,EAAE,EACF,EAAE,oBAAoB,EAAE,yBAAc,EAAE,WAAW,EAAE,yBAAc,EAAE,CACtE,CAAC;QAEF,kGAAkG;QAClG,uBAAuB,CACrB,IAAI,EACJ,IAAA,0BAAiB,EAAC,4BAAoB,EAAE,gBAAgB,CAAC,EACzD,kBAAkB,EAClB;YACE,kBAAkB,EAAE,8CAA8C;SACnE,CACF,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,WAAW,CAAC;;CACpB;AAnGD,gFAmGC;AAEY,QAAA,kCAAkC,GAAG,IAAA,2BAAkB,EAClE,kCAAkC,CACnC,CAAC"}
|
package/src/migrations/update-12-4-0/remove-eslint-project-config-if-no-type-checking-rules.js
DELETED
|
@@ -1,32 +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 path_1 = require("path");
|
|
6
|
-
const rules_requiring_type_checking_1 = require("../../utils/rules-requiring-type-checking");
|
|
7
|
-
function updateProjectESLintConfigs(host) {
|
|
8
|
-
const projects = (0, devkit_1.getProjects)(host);
|
|
9
|
-
projects.forEach((p) => {
|
|
10
|
-
const eslintConfigPath = (0, path_1.join)(p.root, '.eslintrc.json');
|
|
11
|
-
if (!host.exists(eslintConfigPath)) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
return (0, devkit_1.updateJson)(host, eslintConfigPath, rules_requiring_type_checking_1.removeParserOptionsProjectIfNotRequired);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
function removeESLintProjectConfigIfNoTypeCheckingRules(host) {
|
|
18
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
if (!host.exists('.eslintrc.json')) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
// If the root level config uses at least one rule requiring type-checking, do not migrate any project configs
|
|
23
|
-
const rootESLintConfig = (0, devkit_1.readJson)(host, '.eslintrc.json');
|
|
24
|
-
if ((0, rules_requiring_type_checking_1.hasRulesRequiringTypeChecking)(rootESLintConfig)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
updateProjectESLintConfigs(host);
|
|
28
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
exports.default = removeESLintProjectConfigIfNoTypeCheckingRules;
|
|
32
|
-
//# sourceMappingURL=remove-eslint-project-config-if-no-type-checking-rules.js.map
|
package/src/migrations/update-12-4-0/remove-eslint-project-config-if-no-type-checking-rules.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-eslint-project-config-if-no-type-checking-rules.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/migrations/update-12-4-0/remove-eslint-project-config-if-no-type-checking-rules.ts"],"names":[],"mappings":";;;AAAA,yCAA8E;AAE9E,+BAA4B;AAC5B,6FAGmD;AAEnD,SAAS,0BAA0B,CAAC,IAAU;IAC5C,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACrB,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAAC,CAAC,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE;YAClC,OAAO;SACR;QACD,OAAO,IAAA,mBAAU,EACf,IAAI,EACJ,gBAAgB,EAChB,uEAAuC,CACxC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAA8B,8CAA8C,CAC1E,IAAU;;QAEV,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE;YAClC,OAAO;SACR;QAED,8GAA8G;QAC9G,MAAM,gBAAgB,GAAG,IAAA,iBAAQ,EAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QAC1D,IAAI,IAAA,6DAA6B,EAAC,gBAAgB,CAAC,EAAE;YACnD,OAAO;SACR;QACD,0BAA0B,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAdD,iEAcC"}
|