@nx/eslint 0.0.0-pr-22179-271588f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +66 -0
- package/executors.json +10 -0
- package/generators.json +28 -0
- package/index.d.ts +4 -0
- package/index.js +14 -0
- package/migrations.json +138 -0
- package/package.json +52 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +5 -0
- package/src/executors/lint/hasher.d.ts +9 -0
- package/src/executors/lint/hasher.js +43 -0
- package/src/executors/lint/lint.impl.d.ts +5 -0
- package/src/executors/lint/lint.impl.js +174 -0
- package/src/executors/lint/schema.d.ts +40 -0
- package/src/executors/lint/schema.json +148 -0
- package/src/executors/lint/utility/eslint-utils.d.ts +6 -0
- package/src/executors/lint/utility/eslint-utils.js +75 -0
- package/src/generators/convert-to-flat-config/converters/json-converter.d.ts +11 -0
- package/src/generators/convert-to-flat-config/converters/json-converter.js +175 -0
- package/src/generators/convert-to-flat-config/generator.d.ts +4 -0
- package/src/generators/convert-to-flat-config/generator.js +139 -0
- package/src/generators/convert-to-flat-config/schema.d.ts +3 -0
- package/src/generators/convert-to-flat-config/schema.json +17 -0
- package/src/generators/init/global-eslint-config.d.ts +29 -0
- package/src/generators/init/global-eslint-config.js +102 -0
- package/src/generators/init/init-migration.d.ts +3 -0
- package/src/generators/init/init-migration.js +137 -0
- package/src/generators/init/init.d.ts +9 -0
- package/src/generators/init/init.js +93 -0
- package/src/generators/init/schema.json +28 -0
- package/src/generators/lint-project/lint-project.d.ts +22 -0
- package/src/generators/lint-project/lint-project.js +227 -0
- package/src/generators/lint-project/setup-root-eslint.d.ts +7 -0
- package/src/generators/lint-project/setup-root-eslint.js +33 -0
- package/src/generators/utils/eslint-file.d.ts +16 -0
- package/src/generators/utils/eslint-file.js +287 -0
- package/src/generators/utils/eslint-targets.d.ts +2 -0
- package/src/generators/utils/eslint-targets.js +18 -0
- package/src/generators/utils/flat-config/ast-utils.d.ts +60 -0
- package/src/generators/utils/flat-config/ast-utils.js +573 -0
- package/src/generators/utils/flat-config/path-utils.d.ts +3 -0
- package/src/generators/utils/flat-config/path-utils.js +28 -0
- package/src/generators/utils/linter.d.ts +4 -0
- package/src/generators/utils/linter.js +8 -0
- package/src/generators/utils/plugin.d.ts +2 -0
- package/src/generators/utils/plugin.js +11 -0
- package/src/generators/workspace-rule/files/__name__.spec.ts__tmpl__ +11 -0
- package/src/generators/workspace-rule/files/__name__.ts__tmpl__ +37 -0
- package/src/generators/workspace-rule/schema.json +26 -0
- package/src/generators/workspace-rule/workspace-rule.d.ts +6 -0
- package/src/generators/workspace-rule/workspace-rule.js +78 -0
- package/src/generators/workspace-rules-project/files/index.ts__tmpl__ +27 -0
- package/src/generators/workspace-rules-project/files/tsconfig.json__tmpl__ +14 -0
- package/src/generators/workspace-rules-project/files/tsconfig.lint.json__tmpl__ +9 -0
- package/src/generators/workspace-rules-project/schema.json +23 -0
- package/src/generators/workspace-rules-project/workspace-rules-project.d.ts +8 -0
- package/src/generators/workspace-rules-project/workspace-rules-project.js +82 -0
- 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 +27 -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 +36 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files.d.ts +2 -0
- package/src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files.js +44 -0
- package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.d.ts +2 -0
- package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.js +47 -0
- package/src/migrations/update-17-1-0/update-typescript-eslint.d.ts +2 -0
- package/src/migrations/update-17-1-0/update-typescript-eslint.js +74 -0
- package/src/migrations/update-17-2-0/simplify-eslint-patterns.d.ts +2 -0
- package/src/migrations/update-17-2-0/simplify-eslint-patterns.js +46 -0
- package/src/migrations/update-17-2-9/move-options-to-target-defaults.d.ts +2 -0
- package/src/migrations/update-17-2-9/move-options-to-target-defaults.js +107 -0
- package/src/plugins/plugin.d.ts +5 -0
- package/src/plugins/plugin.js +92 -0
- package/src/utils/config-file.d.ts +5 -0
- package/src/utils/config-file.js +35 -0
- package/src/utils/flat-config.d.ts +2 -0
- package/src/utils/flat-config.js +7 -0
- package/src/utils/rules-requiring-type-checking.d.ts +3 -0
- package/src/utils/rules-requiring-type-checking.js +84 -0
- package/src/utils/versions.d.ts +5 -0
- package/src/utils/versions.js +8 -0
- package/src/utils/workspace-lint-rules.d.ts +1 -0
- package/src/utils/workspace-lint-rules.js +5 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
5
|
+
const eslint_file_1 = require("../../generators/utils/eslint-file");
|
|
6
|
+
const project_configuration_utils_1 = require("nx/src/project-graph/utils/project-configuration-utils");
|
|
7
|
+
async function update(tree) {
|
|
8
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
9
|
+
// Don't override anything if there are already target defaults for eslint
|
|
10
|
+
if (nxJson.targetDefaults?.['@nx/eslint:lint']) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
nxJson.targetDefaults ??= {};
|
|
14
|
+
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
|
15
|
+
const lintTargets = new Set();
|
|
16
|
+
(0, executor_options_utils_1.forEachExecutorOptionsInGraph)(graph, '@nx/eslint:lint', (value, proj, targetName) => {
|
|
17
|
+
lintTargets.add(targetName);
|
|
18
|
+
});
|
|
19
|
+
// Workspace does not use eslint?
|
|
20
|
+
if (lintTargets.size === 0) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const lintDefaults = (nxJson.targetDefaults['@nx/eslint:lint'] = {});
|
|
24
|
+
// All eslint targets have the same name
|
|
25
|
+
if (lintTargets.size === 1) {
|
|
26
|
+
const targetName = Array.from(lintTargets)[0];
|
|
27
|
+
if (nxJson.targetDefaults[targetName]) {
|
|
28
|
+
Object.assign(lintDefaults, nxJson.targetDefaults[targetName]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
lintDefaults.cache ??= true;
|
|
32
|
+
if (!lintDefaults.inputs) {
|
|
33
|
+
const eslintConfig = (0, eslint_file_1.findEslintFile)(tree);
|
|
34
|
+
lintDefaults.inputs = [
|
|
35
|
+
'default',
|
|
36
|
+
...(eslintConfig ? [`{workspaceRoot}/${eslintConfig}`] : []),
|
|
37
|
+
'{workspaceRoot}/tools/eslint-rules/**/*',
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
// Cleanup old target defaults
|
|
41
|
+
const projects = graph.nodes;
|
|
42
|
+
const projectMap = (0, devkit_1.getProjects)(tree);
|
|
43
|
+
for (const [targetDefaultKey, targetDefault] of Object.entries(nxJson.targetDefaults)) {
|
|
44
|
+
if (!isTargetDefaultUsed(targetDefault, nxJson.targetDefaults, projects, projectMap)) {
|
|
45
|
+
delete nxJson.targetDefaults[targetDefaultKey];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
let addOutputs = false;
|
|
49
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/eslint:lint', (options, proj, targetName, configuration) => {
|
|
50
|
+
const projConfig = projectMap.get(proj);
|
|
51
|
+
// modify lint file patterns
|
|
52
|
+
if (options.lintFilePatterns) {
|
|
53
|
+
const projectRootRegex = new RegExp(`^${projConfig.root}/`);
|
|
54
|
+
projConfig.targets[targetName].options.lintFilePatterns =
|
|
55
|
+
options.lintFilePatterns
|
|
56
|
+
.filter((filePattern) => filePattern !== '{projectRoot}' &&
|
|
57
|
+
filePattern !== projConfig.root)
|
|
58
|
+
.map((filePattern) => filePattern.replace(projectRootRegex, '{projectRoot}/'));
|
|
59
|
+
// remove lintFilePatterns if empty
|
|
60
|
+
if (projConfig.targets[targetName].options.lintFilePatterns.length === 0) {
|
|
61
|
+
delete projConfig.targets[targetName].options.lintFilePatterns;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// remove inputs if they are not bringing any new inputs
|
|
65
|
+
if (projConfig.targets[targetName].inputs &&
|
|
66
|
+
projConfig.targets[targetName].inputs.every((i) => lintDefaults.inputs.includes(i))) {
|
|
67
|
+
delete projConfig.targets[targetName].inputs;
|
|
68
|
+
}
|
|
69
|
+
// remove obsolete eslint config definition, unless it's a custom one
|
|
70
|
+
const projectEslintConfig = (0, eslint_file_1.findEslintFile)(tree, projConfig.root);
|
|
71
|
+
if (options.eslintConfig === `${projConfig.root}/${projectEslintConfig}` ||
|
|
72
|
+
options.eslintConfig === `{projectRoot}/${projectEslintConfig}`) {
|
|
73
|
+
delete projConfig.targets[targetName].options.eslintConfig;
|
|
74
|
+
}
|
|
75
|
+
// remove options if empty
|
|
76
|
+
if (Object.keys(projConfig.targets[targetName]?.options ?? {}).length === 0) {
|
|
77
|
+
delete projConfig.targets[targetName].options;
|
|
78
|
+
}
|
|
79
|
+
// track output
|
|
80
|
+
if (options.outputFile) {
|
|
81
|
+
addOutputs = true;
|
|
82
|
+
}
|
|
83
|
+
if (projConfig.targets[targetName].outputs?.length === 1 &&
|
|
84
|
+
projConfig.targets[targetName].outputs[0] === '{options.outputFile}') {
|
|
85
|
+
delete projConfig.targets[targetName].outputs;
|
|
86
|
+
}
|
|
87
|
+
(0, devkit_1.updateProjectConfiguration)(tree, proj, projConfig);
|
|
88
|
+
});
|
|
89
|
+
if (addOutputs) {
|
|
90
|
+
lintDefaults.outputs = ['{options.outputFile}'];
|
|
91
|
+
}
|
|
92
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
93
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
94
|
+
}
|
|
95
|
+
exports.default = update;
|
|
96
|
+
function isTargetDefaultUsed(targetDefault, targetDefaults, projects, projectMap) {
|
|
97
|
+
for (const p of Object.values(projects)) {
|
|
98
|
+
for (const targetName in p.data?.targets ?? {}) {
|
|
99
|
+
if ((0, project_configuration_utils_1.readTargetDefaultsForTarget)(targetName, targetDefaults,
|
|
100
|
+
// It might seem like we should use the graph here too but we don't want to pass an executor which was processed in the graph
|
|
101
|
+
projectMap.get(p.name)?.targets?.[targetName]?.executor) === targetDefault) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodes = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const globs_1 = require("nx/src/utils/globs");
|
|
7
|
+
const config_file_1 = require("../utils/config-file");
|
|
8
|
+
exports.createNodes = [
|
|
9
|
+
(0, globs_1.combineGlobPatterns)(['**/project.json', '**/package.json']),
|
|
10
|
+
(configFilePath, options, context) => {
|
|
11
|
+
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
12
|
+
options = normalizeOptions(options);
|
|
13
|
+
const eslintConfigs = getEslintConfigsForProject(projectRoot, context.workspaceRoot);
|
|
14
|
+
if (!eslintConfigs.length) {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
projects: {
|
|
19
|
+
[projectRoot]: {
|
|
20
|
+
targets: buildEslintTargets(eslintConfigs, projectRoot, options),
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
function getEslintConfigsForProject(projectRoot, workspaceRoot) {
|
|
27
|
+
const detectedConfigs = new Set();
|
|
28
|
+
const baseConfig = (0, config_file_1.findBaseEslintFile)(workspaceRoot);
|
|
29
|
+
if (baseConfig) {
|
|
30
|
+
detectedConfigs.add(baseConfig);
|
|
31
|
+
}
|
|
32
|
+
let siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(workspaceRoot, projectRoot));
|
|
33
|
+
if (projectRoot === '.') {
|
|
34
|
+
// If there's no src folder, it's not a standalone project
|
|
35
|
+
if (!siblingFiles.includes('src')) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
// If it's standalone but doesn't have eslint config, it's not a lintable
|
|
39
|
+
const config = siblingFiles.find((f) => config_file_1.ESLINT_CONFIG_FILENAMES.includes(f));
|
|
40
|
+
if (!config) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
detectedConfigs.add(config);
|
|
44
|
+
return Array.from(detectedConfigs);
|
|
45
|
+
}
|
|
46
|
+
while (projectRoot !== '.') {
|
|
47
|
+
// if it has an eslint config it's lintable
|
|
48
|
+
const config = siblingFiles.find((f) => config_file_1.ESLINT_CONFIG_FILENAMES.includes(f));
|
|
49
|
+
if (config) {
|
|
50
|
+
detectedConfigs.add(`${projectRoot}/${config}`);
|
|
51
|
+
return Array.from(detectedConfigs);
|
|
52
|
+
}
|
|
53
|
+
projectRoot = (0, path_1.dirname)(projectRoot);
|
|
54
|
+
siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(workspaceRoot, projectRoot));
|
|
55
|
+
}
|
|
56
|
+
// check whether the root has an eslint config
|
|
57
|
+
const config = (0, fs_1.readdirSync)(workspaceRoot).find((f) => config_file_1.ESLINT_CONFIG_FILENAMES.includes(f));
|
|
58
|
+
if (config) {
|
|
59
|
+
detectedConfigs.add(config);
|
|
60
|
+
return Array.from(detectedConfigs);
|
|
61
|
+
}
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
function buildEslintTargets(eslintConfigs, projectRoot, options) {
|
|
65
|
+
const isRootProject = projectRoot === '.';
|
|
66
|
+
const targets = {};
|
|
67
|
+
const targetConfig = {
|
|
68
|
+
command: `eslint ${isRootProject ? './src' : '.'}`,
|
|
69
|
+
cache: true,
|
|
70
|
+
options: {
|
|
71
|
+
cwd: projectRoot,
|
|
72
|
+
},
|
|
73
|
+
inputs: [
|
|
74
|
+
'default',
|
|
75
|
+
...eslintConfigs.map((config) => `{workspaceRoot}/${config}`),
|
|
76
|
+
'{workspaceRoot}/tools/eslint-rules/**/*',
|
|
77
|
+
{ externalDependencies: ['eslint'] },
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
if (eslintConfigs.some((config) => (0, config_file_1.isFlatConfig)(config))) {
|
|
81
|
+
targetConfig.options.env = {
|
|
82
|
+
ESLINT_USE_FLAT_CONFIG: 'true',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
targets[options.targetName] = targetConfig;
|
|
86
|
+
return targets;
|
|
87
|
+
}
|
|
88
|
+
function normalizeOptions(options) {
|
|
89
|
+
options ??= {};
|
|
90
|
+
options.targetName ??= 'lint';
|
|
91
|
+
return options;
|
|
92
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const ESLINT_CONFIG_FILENAMES: string[];
|
|
2
|
+
export declare const baseEsLintConfigFile = ".eslintrc.base.json";
|
|
3
|
+
export declare const baseEsLintFlatConfigFile = "eslint.base.config.js";
|
|
4
|
+
export declare function findBaseEslintFile(workspaceRoot?: string): string | null;
|
|
5
|
+
export declare function isFlatConfig(configFilePath: string): boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFlatConfig = exports.findBaseEslintFile = exports.baseEsLintFlatConfigFile = exports.baseEsLintConfigFile = exports.ESLINT_CONFIG_FILENAMES = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
exports.ESLINT_CONFIG_FILENAMES = [
|
|
7
|
+
'.eslintrc',
|
|
8
|
+
'.eslintrc.js',
|
|
9
|
+
'.eslintrc.cjs',
|
|
10
|
+
'.eslintrc.yaml',
|
|
11
|
+
'.eslintrc.yml',
|
|
12
|
+
'.eslintrc.json',
|
|
13
|
+
'eslint.config.js',
|
|
14
|
+
];
|
|
15
|
+
exports.baseEsLintConfigFile = '.eslintrc.base.json';
|
|
16
|
+
exports.baseEsLintFlatConfigFile = 'eslint.base.config.js';
|
|
17
|
+
function findBaseEslintFile(workspaceRoot = '') {
|
|
18
|
+
if ((0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(workspaceRoot, exports.baseEsLintConfigFile))) {
|
|
19
|
+
return exports.baseEsLintConfigFile;
|
|
20
|
+
}
|
|
21
|
+
if ((0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(workspaceRoot, exports.baseEsLintFlatConfigFile))) {
|
|
22
|
+
return exports.baseEsLintFlatConfigFile;
|
|
23
|
+
}
|
|
24
|
+
for (const file of exports.ESLINT_CONFIG_FILENAMES) {
|
|
25
|
+
if ((0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(workspaceRoot, file))) {
|
|
26
|
+
return file;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
exports.findBaseEslintFile = findBaseEslintFile;
|
|
32
|
+
function isFlatConfig(configFilePath) {
|
|
33
|
+
return configFilePath.endsWith('.config.js');
|
|
34
|
+
}
|
|
35
|
+
exports.isFlatConfig = isFlatConfig;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeParserOptionsProjectIfNotRequired = exports.hasRulesRequiringTypeChecking = void 0;
|
|
4
|
+
// Cache the resolved rules from node_modules
|
|
5
|
+
let knownRulesRequiringTypeChecking = null;
|
|
6
|
+
function resolveKnownRulesRequiringTypeChecking() {
|
|
7
|
+
if (knownRulesRequiringTypeChecking) {
|
|
8
|
+
return knownRulesRequiringTypeChecking;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const { rules } = require('@typescript-eslint/eslint-plugin');
|
|
12
|
+
const rulesRequiringTypeInfo = Object.entries(rules)
|
|
13
|
+
.map(([ruleName, config]) => {
|
|
14
|
+
if (config.meta?.docs?.requiresTypeChecking) {
|
|
15
|
+
return `@typescript-eslint/${ruleName}`;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
})
|
|
19
|
+
.filter(Boolean);
|
|
20
|
+
return rulesRequiringTypeInfo;
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
console.log(err);
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function hasRulesRequiringTypeChecking(eslintConfig) {
|
|
28
|
+
knownRulesRequiringTypeChecking = resolveKnownRulesRequiringTypeChecking();
|
|
29
|
+
if (!knownRulesRequiringTypeChecking) {
|
|
30
|
+
/**
|
|
31
|
+
* If (unexpectedly) known rules requiring type checking could not be resolved,
|
|
32
|
+
* default to assuming that the rules are in use to align most closely with Nx
|
|
33
|
+
* ESLint configs to date.
|
|
34
|
+
*/
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const allRulesInConfig = getAllRulesInConfig(eslintConfig);
|
|
38
|
+
return allRulesInConfig.some((rule) => knownRulesRequiringTypeChecking.includes(rule));
|
|
39
|
+
}
|
|
40
|
+
exports.hasRulesRequiringTypeChecking = hasRulesRequiringTypeChecking;
|
|
41
|
+
function removeParserOptionsProjectIfNotRequired(json) {
|
|
42
|
+
// At least one rule requiring type-checking is in use, do not migrate the config
|
|
43
|
+
if (hasRulesRequiringTypeChecking(json)) {
|
|
44
|
+
return json;
|
|
45
|
+
}
|
|
46
|
+
removeProjectParserOptionFromConfig(json);
|
|
47
|
+
return json;
|
|
48
|
+
}
|
|
49
|
+
exports.removeParserOptionsProjectIfNotRequired = removeParserOptionsProjectIfNotRequired;
|
|
50
|
+
function determineEnabledRules(rules) {
|
|
51
|
+
return Object.entries(rules)
|
|
52
|
+
.filter(([key, value]) => {
|
|
53
|
+
return !(typeof value === 'string' && value === 'off');
|
|
54
|
+
})
|
|
55
|
+
.map(([ruleName]) => ruleName);
|
|
56
|
+
}
|
|
57
|
+
function getAllRulesInConfig(json) {
|
|
58
|
+
let allRules = json.rules ? determineEnabledRules(json.rules) : [];
|
|
59
|
+
if (json.overrides?.length > 0) {
|
|
60
|
+
for (const o of json.overrides) {
|
|
61
|
+
if (o.rules) {
|
|
62
|
+
allRules = allRules = [...allRules, ...determineEnabledRules(o.rules)];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return allRules;
|
|
67
|
+
}
|
|
68
|
+
function removeProjectParserOptionFromConfig(json) {
|
|
69
|
+
delete json.parserOptions?.project;
|
|
70
|
+
// If parserOptions is left empty by this removal, also clean up the whole object
|
|
71
|
+
if (json.parserOptions && Object.keys(json.parserOptions).length === 0) {
|
|
72
|
+
delete json.parserOptions;
|
|
73
|
+
}
|
|
74
|
+
if (json.overrides) {
|
|
75
|
+
for (const override of json.overrides) {
|
|
76
|
+
delete override.parserOptions?.project;
|
|
77
|
+
// If parserOptions is left empty by this removal, also clean up the whole object
|
|
78
|
+
if (override.parserOptions &&
|
|
79
|
+
Object.keys(override.parserOptions).length === 0) {
|
|
80
|
+
delete override.parserOptions;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typescriptESLintVersion = exports.eslintConfigPrettierVersion = exports.eslintrcVersion = exports.eslintVersion = exports.nxVersion = void 0;
|
|
4
|
+
exports.nxVersion = require('../../package.json').version;
|
|
5
|
+
exports.eslintVersion = '~8.48.0';
|
|
6
|
+
exports.eslintrcVersion = '^2.1.1';
|
|
7
|
+
exports.eslintConfigPrettierVersion = '^9.0.0';
|
|
8
|
+
exports.typescriptESLintVersion = '^6.13.2';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const workspaceLintPluginDir: string;
|