@nrwl/linter 14.8.7 → 14.9.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1 -1
- package/LICENSE +22 -22
- package/README.md +5 -26
- package/executors.json +0 -10
- package/migrations.json +12 -84
- package/package.json +4 -6
- package/src/executors/eslint/hasher.d.ts +1 -1
- package/src/executors/eslint/hasher.js +1 -1
- package/src/executors/eslint/hasher.js.map +1 -1
- package/src/executors/eslint/lint.impl.js +2 -2
- package/src/executors/eslint/lint.impl.js.map +1 -1
- package/src/executors/eslint/schema.json +12 -6
- package/src/generators/init/global-eslint-config.d.ts +36 -0
- package/src/generators/init/global-eslint-config.js +77 -0
- package/src/generators/init/global-eslint-config.js.map +1 -0
- package/src/generators/init/init-migration.d.ts +3 -0
- package/src/generators/init/init-migration.js +68 -0
- package/src/generators/init/init-migration.js.map +1 -0
- package/src/generators/init/init.d.ts +1 -0
- package/src/generators/init/init.js +12 -160
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/lint-project/lint-project.d.ts +2 -0
- package/src/generators/lint-project/lint-project.js +65 -30
- package/src/generators/lint-project/lint-project.js.map +1 -1
- package/src/generators/utils/eslint-file.d.ts +4 -2
- package/src/generators/utils/eslint-file.js +18 -5
- package/src/generators/utils/eslint-file.js.map +1 -1
- package/src/generators/utils/eslint-targets.d.ts +2 -0
- package/src/generators/utils/eslint-targets.js +13 -0
- package/src/generators/utils/eslint-targets.js.map +1 -0
- package/src/generators/utils/linter.d.ts +0 -1
- package/src/generators/utils/linter.js +0 -1
- package/src/generators/utils/linter.js.map +1 -1
- package/src/generators/workspace-rule/files/__name__.ts__tmpl__ +1 -1
- package/src/generators/workspace-rule/schema.json +2 -11
- package/src/generators/workspace-rule/workspace-rule.d.ts +1 -1
- package/src/generators/workspace-rule/workspace-rule.js +2 -2
- package/src/generators/workspace-rule/workspace-rule.js.map +1 -1
- package/src/generators/workspace-rules-project/workspace-rules-project.d.ts +1 -1
- package/src/generators/workspace-rules-project/workspace-rules-project.js +30 -9
- package/src/generators/workspace-rules-project/workspace-rules-project.js.map +1 -1
- package/src/migrations/update-13-3-0/eslint-8-updates.js +3 -2
- package/src/migrations/update-13-3-0/eslint-8-updates.js.map +1 -1
- package/src/migrations/update-15-0-0/add-eslint-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-eslint-inputs.js +33 -0
- package/src/migrations/update-15-0-0/add-eslint-inputs.js.map +1 -0
- package/src/migrations/update-15-7-1/add-eslint-ignore.d.ts +2 -0
- package/src/migrations/update-15-7-1/add-eslint-ignore.js +42 -0
- package/src/migrations/update-15-7-1/add-eslint-ignore.js.map +1 -0
- package/src/utils/convert-tslint-to-eslint/project-converter.d.ts +1 -1
- package/src/utils/convert-tslint-to-eslint/project-converter.js +9 -9
- package/src/utils/convert-tslint-to-eslint/project-converter.js.map +1 -1
- package/src/utils/convert-tslint-to-eslint/utils.d.ts +1 -1
- package/src/utils/testing.d.ts +1 -1
- package/src/utils/versions.d.ts +0 -2
- package/src/utils/versions.js +1 -3
- package/src/utils/versions.js.map +1 -1
- package/src/executors/lint/compat.d.ts +0 -2
- package/src/executors/lint/compat.js +0 -6
- package/src/executors/lint/compat.js.map +0 -1
- package/src/executors/lint/lint.impl.d.ts +0 -2
- package/src/executors/lint/lint.impl.js +0 -10
- package/src/executors/lint/lint.impl.js.map +0 -1
- package/src/executors/lint/schema.json +0 -124
- package/src/migrations/update-10-3-0/add-json-ext-to-eslintrc.d.ts +0 -1
- package/src/migrations/update-10-3-0/add-json-ext-to-eslintrc.js +0 -52
- package/src/migrations/update-10-3-0/add-json-ext-to-eslintrc.js.map +0 -1
- package/src/migrations/update-10-3-0/add-root-eslintrc-json-to-workspace-implicit-deps.d.ts +0 -1
- package/src/migrations/update-10-3-0/add-root-eslintrc-json-to-workspace-implicit-deps.js +0 -18
- package/src/migrations/update-10-3-0/add-root-eslintrc-json-to-workspace-implicit-deps.js.map +0 -1
- package/src/migrations/update-10-3-0/update-10-3-0.d.ts +0 -1
- package/src/migrations/update-10-3-0/update-10-3-0.js +0 -20
- package/src/migrations/update-10-3-0/update-10-3-0.js.map +0 -1
- package/src/migrations/update-10-3-0/update-eslint-builder-and-config.d.ts +0 -1
- package/src/migrations/update-10-3-0/update-eslint-builder-and-config.js +0 -81
- package/src/migrations/update-10-3-0/update-eslint-builder-and-config.js.map +0 -1
- package/src/migrations/update-10-3-1/revert-node-modules-files-in-eslint-builder-options.d.ts +0 -1
- package/src/migrations/update-10-3-1/revert-node-modules-files-in-eslint-builder-options.js +0 -24
- package/src/migrations/update-10-3-1/revert-node-modules-files-in-eslint-builder-options.js.map +0 -1
- package/src/migrations/update-10-4-0/update-eslint-configs-to-use-nx-presets.d.ts +0 -7
- package/src/migrations/update-10-4-0/update-eslint-configs-to-use-nx-presets.js +0 -447
- package/src/migrations/update-10-4-0/update-eslint-configs-to-use-nx-presets.js.map +0 -1
- package/src/migrations/update-10-4-0/update-root-eslint-config-to-use-overrides.d.ts +0 -1
- package/src/migrations/update-10-4-0/update-root-eslint-config-to-use-overrides.js +0 -107
- package/src/migrations/update-10-4-0/update-root-eslint-config-to-use-overrides.js.map +0 -1
- package/src/migrations/update-11-5-0/always-use-project-level-tsconfigs-with-eslint.d.ts +0 -3
- package/src/migrations/update-11-5-0/always-use-project-level-tsconfigs-with-eslint.js +0 -95
- package/src/migrations/update-11-5-0/always-use-project-level-tsconfigs-with-eslint.js.map +0 -1
@@ -3,171 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lintInitGenerator = void 0;
|
4
4
|
const devkit_1 = require("@nrwl/devkit");
|
5
5
|
const versions_1 = require("../../utils/versions");
|
6
|
-
const linter_1 = require("../utils/linter");
|
7
6
|
const eslint_file_1 = require("../utils/eslint-file");
|
8
|
-
const
|
9
|
-
rulesDirectory: ['node_modules/@nrwl/workspace/src/tslint'],
|
10
|
-
linterOptions: {
|
11
|
-
exclude: ['**/*'],
|
12
|
-
},
|
13
|
-
rules: {
|
14
|
-
'arrow-return-shorthand': true,
|
15
|
-
'callable-types': true,
|
16
|
-
'class-name': true,
|
17
|
-
deprecation: {
|
18
|
-
severity: 'warn',
|
19
|
-
},
|
20
|
-
forin: true,
|
21
|
-
'import-blacklist': [true, 'rxjs/Rx'],
|
22
|
-
'interface-over-type-literal': true,
|
23
|
-
'member-access': false,
|
24
|
-
'member-ordering': [
|
25
|
-
true,
|
26
|
-
{
|
27
|
-
order: [
|
28
|
-
'static-field',
|
29
|
-
'instance-field',
|
30
|
-
'static-method',
|
31
|
-
'instance-method',
|
32
|
-
],
|
33
|
-
},
|
34
|
-
],
|
35
|
-
'no-arg': true,
|
36
|
-
'no-bitwise': true,
|
37
|
-
'no-console': [true, 'debug', 'info', 'time', 'timeEnd', 'trace'],
|
38
|
-
'no-construct': true,
|
39
|
-
'no-debugger': true,
|
40
|
-
'no-duplicate-super': true,
|
41
|
-
'no-empty': false,
|
42
|
-
'no-empty-interface': true,
|
43
|
-
'no-eval': true,
|
44
|
-
'no-inferrable-types': [true, 'ignore-params'],
|
45
|
-
'no-misused-new': true,
|
46
|
-
'no-non-null-assertion': true,
|
47
|
-
'no-shadowed-variable': true,
|
48
|
-
'no-string-literal': false,
|
49
|
-
'no-string-throw': true,
|
50
|
-
'no-switch-case-fall-through': true,
|
51
|
-
'no-unnecessary-initializer': true,
|
52
|
-
'no-unused-expression': true,
|
53
|
-
'no-var-keyword': true,
|
54
|
-
'object-literal-sort-keys': false,
|
55
|
-
'prefer-const': true,
|
56
|
-
radix: true,
|
57
|
-
'triple-equals': [true, 'allow-null-check'],
|
58
|
-
'unified-signatures': true,
|
59
|
-
'variable-name': false,
|
60
|
-
'nx-enforce-module-boundaries': [
|
61
|
-
true,
|
62
|
-
{
|
63
|
-
enforceBuildableLibDependency: true,
|
64
|
-
allow: [],
|
65
|
-
depConstraints: [{ sourceTag: '*', onlyDependOnLibsWithTags: ['*'] }],
|
66
|
-
},
|
67
|
-
],
|
68
|
-
},
|
69
|
-
};
|
70
|
-
const getGlobalEsLintConfiguration = (unitTestRunner) => {
|
71
|
-
const config = {
|
72
|
-
root: true,
|
73
|
-
ignorePatterns: ['**/*'],
|
74
|
-
plugins: ['@nrwl/nx'],
|
75
|
-
/**
|
76
|
-
* We leverage ESLint's "overrides" capability so that we can set up a root config which will support
|
77
|
-
* all permutations of Nx workspaces across all frameworks, libraries and tools.
|
78
|
-
*
|
79
|
-
* The key point is that we need entirely different ESLint config to apply to different types of files,
|
80
|
-
* but we still want to share common config where possible.
|
81
|
-
*/
|
82
|
-
overrides: [
|
83
|
-
/**
|
84
|
-
* This configuration is intended to apply to all "source code" (but not
|
85
|
-
* markup like HTML, or other custom file types like GraphQL)
|
86
|
-
*/
|
87
|
-
{
|
88
|
-
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
|
89
|
-
rules: {
|
90
|
-
'@nrwl/nx/enforce-module-boundaries': [
|
91
|
-
'error',
|
92
|
-
{
|
93
|
-
enforceBuildableLibDependency: true,
|
94
|
-
allow: [],
|
95
|
-
depConstraints: [
|
96
|
-
{ sourceTag: '*', onlyDependOnLibsWithTags: ['*'] },
|
97
|
-
],
|
98
|
-
},
|
99
|
-
],
|
100
|
-
},
|
101
|
-
},
|
102
|
-
/**
|
103
|
-
* This configuration is intended to apply to all TypeScript source files.
|
104
|
-
* See the eslint-plugin-nx package for what is in the referenced shareable config.
|
105
|
-
*/
|
106
|
-
{
|
107
|
-
files: ['*.ts', '*.tsx'],
|
108
|
-
extends: ['plugin:@nrwl/nx/typescript'],
|
109
|
-
/**
|
110
|
-
* Having an empty rules object present makes it more obvious to the user where they would
|
111
|
-
* extend things from if they needed to
|
112
|
-
*/
|
113
|
-
rules: {},
|
114
|
-
},
|
115
|
-
/**
|
116
|
-
* This configuration is intended to apply to all JavaScript source files.
|
117
|
-
* See the eslint-plugin-nx package for what is in the referenced shareable config.
|
118
|
-
*/
|
119
|
-
{
|
120
|
-
files: ['*.js', '*.jsx'],
|
121
|
-
extends: ['plugin:@nrwl/nx/javascript'],
|
122
|
-
/**
|
123
|
-
* Having an empty rules object present makes it more obvious to the user where they would
|
124
|
-
* extend things from if they needed to
|
125
|
-
*/
|
126
|
-
rules: {},
|
127
|
-
},
|
128
|
-
],
|
129
|
-
};
|
130
|
-
if (unitTestRunner === 'jest') {
|
131
|
-
config.overrides.push({
|
132
|
-
files: ['*.spec.ts', '*.spec.tsx', '*.spec.js', '*.spec.jsx'],
|
133
|
-
env: {
|
134
|
-
jest: true,
|
135
|
-
},
|
136
|
-
rules: {},
|
137
|
-
});
|
138
|
-
}
|
139
|
-
return config;
|
140
|
-
};
|
141
|
-
function initTsLint(tree, options) {
|
142
|
-
if (tree.exists('/tslint.json')) {
|
143
|
-
return () => { };
|
144
|
-
}
|
145
|
-
(0, devkit_1.writeJson)(tree, 'tslint.json', globalTsLintConfiguration);
|
146
|
-
return !options.skipPackageJson
|
147
|
-
? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
148
|
-
tslint: versions_1.tslintVersion,
|
149
|
-
'@angular-devkit/build-angular': versions_1.buildAngularVersion,
|
150
|
-
})
|
151
|
-
: () => { };
|
152
|
-
}
|
7
|
+
const global_eslint_config_1 = require("./global-eslint-config");
|
153
8
|
function addTargetDefaults(tree) {
|
154
9
|
var _a, _b, _c, _d;
|
155
10
|
var _e, _f;
|
156
|
-
const
|
157
|
-
const productionFileSet = (_a =
|
11
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
12
|
+
const productionFileSet = (_a = nxJson.namedInputs) === null || _a === void 0 ? void 0 : _a.production;
|
158
13
|
if (productionFileSet) {
|
159
14
|
// Remove .eslintrc.json
|
160
15
|
productionFileSet.push('!{projectRoot}/.eslintrc.json');
|
161
16
|
// Dedupe and set
|
162
|
-
|
17
|
+
nxJson.namedInputs.production = Array.from(new Set(productionFileSet));
|
163
18
|
}
|
164
|
-
(_b =
|
165
|
-
(_c = (_e =
|
166
|
-
(_d = (_f =
|
19
|
+
(_b = nxJson.targetDefaults) !== null && _b !== void 0 ? _b : (nxJson.targetDefaults = {});
|
20
|
+
(_c = (_e = nxJson.targetDefaults).lint) !== null && _c !== void 0 ? _c : (_e.lint = {});
|
21
|
+
(_d = (_f = nxJson.targetDefaults.lint).inputs) !== null && _d !== void 0 ? _d : (_f.inputs = [
|
167
22
|
'default',
|
168
23
|
`{workspaceRoot}/.eslintrc.json`,
|
24
|
+
`{workspaceRoot}/.eslintignore`,
|
169
25
|
]);
|
170
|
-
(0, devkit_1.
|
26
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
171
27
|
}
|
172
28
|
function initEsLint(tree, options) {
|
173
29
|
if ((0, eslint_file_1.findEslintFile)(tree)) {
|
@@ -176,7 +32,8 @@ function initEsLint(tree, options) {
|
|
176
32
|
if (!options.skipPackageJson) {
|
177
33
|
(0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@nrwl/linter'], []);
|
178
34
|
}
|
179
|
-
(0, devkit_1.writeJson)(tree, '.eslintrc.json', getGlobalEsLintConfiguration(options.unitTestRunner));
|
35
|
+
(0, devkit_1.writeJson)(tree, '.eslintrc.json', (0, global_eslint_config_1.getGlobalEsLintConfiguration)(options.unitTestRunner, options.rootProject));
|
36
|
+
tree.write('.eslintignore', 'node_modules\n');
|
180
37
|
addTargetDefaults(tree);
|
181
38
|
if (tree.exists('.vscode/extensions.json')) {
|
182
39
|
(0, devkit_1.updateJson)(tree, '.vscode/extensions.json', (json) => {
|
@@ -200,12 +57,7 @@ function initEsLint(tree, options) {
|
|
200
57
|
: () => { };
|
201
58
|
}
|
202
59
|
function lintInitGenerator(tree, options) {
|
203
|
-
|
204
|
-
return initEsLint(tree, options);
|
205
|
-
}
|
206
|
-
else if (options.linter === linter_1.Linter.TsLint) {
|
207
|
-
return initTsLint(tree, options);
|
208
|
-
}
|
60
|
+
return initEsLint(tree, options);
|
209
61
|
}
|
210
62
|
exports.lintInitGenerator = lintInitGenerator;
|
211
63
|
//# sourceMappingURL=init.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/init/init.ts"],"names":[],"mappings":";;;AACA,yCAOsB;AACtB,
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/init/init.ts"],"names":[],"mappings":";;;AACA,yCAOsB;AACtB,mDAK8B;AAG9B,sDAAsD;AACtD,iEAAsE;AAStE,SAAS,iBAAiB,CAAC,IAAU;;;IACnC,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;IAEhC,MAAM,iBAAiB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,UAAU,CAAC;IACzD,IAAI,iBAAiB,EAAE;QACrB,wBAAwB;QACxB,iBAAiB,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QACxD,iBAAiB;QACjB,MAAM,CAAC,WAAW,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC;KACxE;IAED,MAAA,MAAM,CAAC,cAAc,oCAArB,MAAM,CAAC,cAAc,GAAK,EAAE,EAAC;IAE7B,YAAA,MAAM,CAAC,cAAc,EAAC,IAAI,uCAAJ,IAAI,GAAK,EAAE,EAAC;IAClC,YAAA,MAAM,CAAC,cAAc,CAAC,IAAI,EAAC,MAAM,uCAAN,MAAM,GAAK;QACpC,SAAS;QACT,gCAAgC;QAChC,+BAA+B;KAChC,EAAC;IACF,IAAA,qBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,UAAU,CAAC,IAAU,EAAE,OAA0B;IACxD,IAAI,IAAA,4BAAc,EAAC,IAAI,CAAC,EAAE;QACxB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;KACjB;IAED,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE;QAC5B,IAAA,0CAAiC,EAAC,IAAI,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,CAAC;KAC/D;IAED,IA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: string;
|
12
|
+
rootProject?: boolean;
|
12
13
|
}
|
14
|
+
export declare function mapLintPattern(projectRoot: string, extension: string, rootProject?: boolean): string;
|
13
15
|
export declare function lintProjectGenerator(tree: Tree, options: LintProjectOptions): Promise<import("@nrwl/devkit").GeneratorCallback>;
|
14
16
|
export {};
|
@@ -1,22 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.lintProjectGenerator = void 0;
|
3
|
+
exports.lintProjectGenerator = exports.mapLintPattern = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const devkit_1 = require("@nrwl/devkit");
|
6
|
-
const linter_1 = require("../utils/linter");
|
7
6
|
const eslint_file_1 = require("../utils/eslint-file");
|
8
7
|
const path_1 = require("path");
|
9
8
|
const init_1 = require("../init/init");
|
10
|
-
|
11
|
-
|
12
|
-
extends: `${(0, devkit_1.offsetFromRoot)(projectConfig.root)}tslint.json`,
|
13
|
-
// Include project files to be linted since the global one excludes all files.
|
14
|
-
linterOptions: {
|
15
|
-
exclude: ['!**/*'],
|
16
|
-
},
|
17
|
-
rules: {},
|
18
|
-
});
|
19
|
-
}
|
9
|
+
const init_migration_1 = require("../init/init-migration");
|
10
|
+
const project_configuration_1 = require("nx/src/generators/utils/project-configuration");
|
20
11
|
function createEsLintConfiguration(tree, projectConfig, setParserOptionsProject) {
|
21
12
|
const eslintConfig = (0, eslint_file_1.findEslintFile)(tree);
|
22
13
|
(0, devkit_1.writeJson)(tree, (0, path_1.join)(projectConfig.root, `.eslintrc.json`), {
|
@@ -63,33 +54,49 @@ function createEsLintConfiguration(tree, projectConfig, setParserOptionsProject)
|
|
63
54
|
],
|
64
55
|
});
|
65
56
|
}
|
57
|
+
function mapLintPattern(projectRoot, extension, rootProject) {
|
58
|
+
const infix = rootProject ? 'src/' : '';
|
59
|
+
return `${projectRoot}/${infix}**/*.${extension}`;
|
60
|
+
}
|
61
|
+
exports.mapLintPattern = mapLintPattern;
|
66
62
|
function lintProjectGenerator(tree, options) {
|
67
63
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
68
64
|
const installTask = (0, init_1.lintInitGenerator)(tree, {
|
69
65
|
linter: options.linter,
|
70
66
|
unitTestRunner: options.unitTestRunner,
|
71
67
|
skipPackageJson: options.skipPackageJson,
|
68
|
+
rootProject: options.rootProject,
|
72
69
|
});
|
73
70
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
+
}
|
83
94
|
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
exclude: ['**/node_modules/**', `!${projectConfig.root}/**/*`],
|
90
|
-
},
|
91
|
-
};
|
92
|
-
createTsLintConfiguration(tree, projectConfig);
|
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);
|
93
100
|
}
|
94
101
|
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
95
102
|
if (!options.skipFormat) {
|
@@ -99,4 +106,32 @@ function lintProjectGenerator(tree, options) {
|
|
99
106
|
});
|
100
107
|
}
|
101
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
|
+
}
|
102
137
|
//# sourceMappingURL=lint-project.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lint-project.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/lint-project/lint-project.ts"],"names":[],"mappings":";;;;AACA,yCAMsB;
|
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;A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'@nrwl/devkit';
|
2
|
+
export declare const eslintConfigFileWhitelist: string[];
|
3
|
+
export declare const baseEsLintConfigFile = ".eslintrc.base.json";
|
4
|
+
export declare function findEslintFile(tree: Tree, projectRoot?: string): string | null;
|
@@ -1,10 +1,23 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.findEslintFile = void 0;
|
4
|
-
const
|
5
|
-
|
6
|
-
|
7
|
-
|
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))) {
|
8
21
|
return file;
|
9
22
|
}
|
10
23
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"eslint-file.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/utils/eslint-file.ts"],"names":[],"mappings":";;;
|
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"}
|
@@ -0,0 +1,13 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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 +1 @@
|
|
1
|
-
{"version":3,"file":"linter.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/utils/linter.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
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,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* This file sets you up with
|
2
|
+
* This file sets you up with structure needed for an ESLint rule.
|
3
3
|
*
|
4
4
|
* It leverages utilities from @typescript-eslint to allow TypeScript to
|
5
5
|
* provide autocompletions etc for the configuration.
|
@@ -5,16 +5,6 @@
|
|
5
5
|
"title": "Create a new Workspace Lint Rule",
|
6
6
|
"description": "Create a new Workspace Lint Rule.",
|
7
7
|
"type": "object",
|
8
|
-
"examples": [
|
9
|
-
{
|
10
|
-
"command": "nx g @nrwl/linter:workspace-rule my-custom-rule",
|
11
|
-
"description": "Create a new workspace lint rule called my-custom-rule"
|
12
|
-
},
|
13
|
-
{
|
14
|
-
"command": "nx g @nrwl/linter:workspace-rule --name=my-custom-rule --directory=a/b/c",
|
15
|
-
"description": "Create a new workspace lint rule located at `tools/eslint-rules/a/b/c/my-custom-rule.ts`"
|
16
|
-
}
|
17
|
-
],
|
18
8
|
"properties": {
|
19
9
|
"name": {
|
20
10
|
"type": "string",
|
@@ -31,5 +21,6 @@
|
|
31
21
|
"default": "rules"
|
32
22
|
}
|
33
23
|
},
|
34
|
-
"required": ["name", "directory"]
|
24
|
+
"required": ["name", "directory"],
|
25
|
+
"examplesFile": "../../../docs/workspace-rule-examples.md"
|
35
26
|
}
|
@@ -3,5 +3,5 @@ export interface LintWorkspaceRuleGeneratorOptions {
|
|
3
3
|
name: string;
|
4
4
|
directory: string;
|
5
5
|
}
|
6
|
-
export declare function lintWorkspaceRuleGenerator(tree: Tree, options: LintWorkspaceRuleGeneratorOptions): Promise<
|
6
|
+
export declare function lintWorkspaceRuleGenerator(tree: Tree, options: LintWorkspaceRuleGeneratorOptions): Promise<any>;
|
7
7
|
export declare const lintWorkspaceRuleSchematic: (generatorOptions: LintWorkspaceRuleGeneratorOptions) => (tree: any, context: any) => Promise<any>;
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lintWorkspaceRuleSchematic = exports.lintWorkspaceRuleGenerator = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const devkit_1 = require("@nrwl/devkit");
|
6
|
-
const
|
6
|
+
const string_utils_1 = require("@nrwl/devkit/src/utils/string-utils");
|
7
7
|
const path_1 = require("path");
|
8
8
|
const ts = require("typescript");
|
9
9
|
const workspace_lint_rules_1 = require("../../utils/workspace-lint-rules");
|
@@ -19,7 +19,7 @@ function lintWorkspaceRuleGenerator(tree, options) {
|
|
19
19
|
tmpl: '',
|
20
20
|
name: options.name,
|
21
21
|
});
|
22
|
-
const nameCamelCase = (0,
|
22
|
+
const nameCamelCase = (0, string_utils_1.camelize)(options.name);
|
23
23
|
/**
|
24
24
|
* Import the new rule into the workspace plugin index.ts and
|
25
25
|
* register it ready for use in .eslintrc.json configs.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"workspace-rule.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/workspace-rule/workspace-rule.ts"],"names":[],"mappings":";;;;AAAA,yCASsB;AACtB
|
1
|
+
{"version":3,"file":"workspace-rule.js","sourceRoot":"","sources":["../../../../../../packages/linter/src/generators/workspace-rule/work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D,gEA8FC;AAEY,QAAA,0BAA0B,GAAG,IAAA,2BAAkB,EAC1D,0BAA0B,CAC3B,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Tree } from '@nrwl/devkit';
|
2
2
|
export declare const WORKSPACE_RULES_PROJECT_NAME = "eslint-rules";
|
3
3
|
export declare const WORKSPACE_PLUGIN_DIR = "tools/eslint-rules";
|
4
|
-
export declare function lintWorkspaceRulesProjectGenerator(tree: Tree): Promise<
|
4
|
+
export declare function lintWorkspaceRulesProjectGenerator(tree: Tree): Promise<any>;
|
5
5
|
export declare const lintWorkspaceRulesProjectSchematic: (generatorOptions: any) => (tree: any, context: any) => Promise<any>;
|
@@ -3,16 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lintWorkspaceRulesProjectSchematic = exports.lintWorkspaceRulesProjectGenerator = exports.WORKSPACE_PLUGIN_DIR = exports.WORKSPACE_RULES_PROJECT_NAME = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const devkit_1 = require("@nrwl/devkit");
|
6
|
-
const
|
7
|
-
const typescript_1 = require("@nrwl/workspace/src/utilities/typescript");
|
6
|
+
const js_1 = require("@nrwl/js");
|
8
7
|
const path_1 = require("path");
|
9
8
|
const workspace_lint_rules_1 = require("../../utils/workspace-lint-rules");
|
10
9
|
const versions_1 = require("nx/src/utils/versions");
|
10
|
+
const versions_2 = require("../../utils/versions");
|
11
11
|
exports.WORKSPACE_RULES_PROJECT_NAME = 'eslint-rules';
|
12
12
|
exports.WORKSPACE_PLUGIN_DIR = 'tools/eslint-rules';
|
13
13
|
function lintWorkspaceRulesProjectGenerator(tree) {
|
14
14
|
var _a, _b;
|
15
15
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
16
|
+
const { addPropertyToJestConfig, jestProjectGenerator } = (0, devkit_1.ensurePackage)('@nrwl/jest', versions_2.nxVersion);
|
16
17
|
// Noop if the workspace rules project already exists
|
17
18
|
try {
|
18
19
|
(0, devkit_1.readProjectConfiguration)(tree, exports.WORKSPACE_RULES_PROJECT_NAME);
|
@@ -29,29 +30,49 @@ function lintWorkspaceRulesProjectGenerator(tree) {
|
|
29
30
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), workspace_lint_rules_1.workspaceLintPluginDir, {
|
30
31
|
tmpl: '',
|
31
32
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(exports.WORKSPACE_PLUGIN_DIR),
|
32
|
-
rootTsConfigPath: (0,
|
33
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, exports.WORKSPACE_PLUGIN_DIR),
|
33
34
|
});
|
34
35
|
/**
|
35
36
|
* Ensure that when workspace rules are updated they cause all projects to be affected for now.
|
36
37
|
* TODO: Explore writing a ProjectGraph plugin to make this more surgical.
|
37
38
|
*/
|
38
|
-
const
|
39
|
-
if ((_b = (_a =
|
40
|
-
|
41
|
-
(0, devkit_1.
|
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);
|
42
43
|
}
|
43
44
|
// Add jest to the project and return installation task
|
44
|
-
const installTask = yield
|
45
|
+
const installTask = yield jestProjectGenerator(tree, {
|
45
46
|
project: exports.WORKSPACE_RULES_PROJECT_NAME,
|
46
47
|
supportTsx: false,
|
47
48
|
skipSerializers: true,
|
48
49
|
setupFile: 'none',
|
49
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;
|
50
71
|
});
|
51
72
|
// Add swc dependencies
|
52
73
|
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@swc-node/register': versions_1.swcNodeVersion, '@swc/core': versions_1.swcCoreVersion });
|
53
74
|
// Add extra config to the jest.config.ts file to allow ESLint 8 exports mapping to work with jest
|
54
|
-
|
75
|
+
addPropertyToJestConfig(tree, (0, devkit_1.joinPathFragments)(exports.WORKSPACE_PLUGIN_DIR, 'jest.config.ts'), 'moduleNameMapper', {
|
55
76
|
'@eslint/eslintrc': '@eslint/eslintrc/dist/eslintrc-universal.cjs',
|
56
77
|
});
|
57
78
|
yield (0, devkit_1.formatFiles)(tree);
|