@o3r/eslint-plugin 11.6.0-prerelease.6 → 11.6.0-prerelease.8
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +22 -21
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/src/index.js +4 -5
- package/src/public_api.d.ts +3 -0
- package/src/public_api.js +1 -0
- package/src/rules/json/json-dependency-versions-harmonize/json-dependency-versions-harmonize.d.ts +3 -2
- package/src/rules/json/json-dependency-versions-harmonize/json-dependency-versions-harmonize.js +60 -60
- package/src/rules/json/json-dependency-versions-harmonize/version-harmonize.js +1 -1
- package/src/rules/json/utils.js +2 -2
- package/src/rules/template/no-inner-html/no-inner-html.d.ts +1 -1
- package/src/rules/template/no-inner-html/no-inner-html.js +30 -31
- package/src/rules/template/template-async-number-limitation/template-async-number-limitation.d.ts +2 -2
- package/src/rules/template/template-async-number-limitation/template-async-number-limitation.js +24 -24
- package/src/rules/template/utils.js +3 -3
- package/src/rules/typescript/matching-configuration-name/matching-configuration-name.d.ts +1 -1
- package/src/rules/typescript/matching-configuration-name/matching-configuration-name.js +40 -40
- package/src/rules/typescript/no-folder-import-for-module/no-folder-import-for-module.d.ts +1 -1
- package/src/rules/typescript/no-folder-import-for-module/no-folder-import-for-module.js +28 -24
- package/src/rules/typescript/no-multiple-type-configuration-property/no-multiple-type-configuration-property.d.ts +1 -1
- package/src/rules/typescript/no-multiple-type-configuration-property/no-multiple-type-configuration-property.js +3 -5
- package/src/rules/typescript/o3r-categories-tags/o3r-categories-tags.d.ts +1 -1
- package/src/rules/typescript/o3r-categories-tags/o3r-categories-tags.js +82 -82
- package/src/rules/typescript/o3r-widget-tags/o3r-widget-tags.d.ts +1 -1
- package/src/rules/typescript/o3r-widget-tags/o3r-widget-tags.js +142 -142
- package/src/rules/utils.d.ts +1 -1
- package/src/rules/utils.js +4 -7
- package/src/rules/yaml/utils.js +2 -2
- package/src/rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize.d.ts +2 -2
- package/src/rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize.js +45 -45
@@ -72,184 +72,184 @@ exports.default = (0, utils_1.createRule)({
|
|
72
72
|
defaultOptions,
|
73
73
|
create: (context, [options]) => {
|
74
74
|
const supportedO3rWidgets = new Set(Object.keys(options.widgets));
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
const
|
85
|
-
|
75
|
+
const rule = (node) => {
|
76
|
+
const { sourceCode } = context;
|
77
|
+
const comment = (0, utils_1.getNodeComment)(node, sourceCode);
|
78
|
+
if (!comment || comment.value.length === 0) {
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
const { loc, value: docText } = comment;
|
82
|
+
const widgetTypes = Array.from(docText.matchAll(/@o3rWidget (.*)/g));
|
83
|
+
if (widgetTypes.length > 1) {
|
84
|
+
const fix = (fixer) => {
|
85
|
+
return fixer.replaceTextRange(comment.range, (0, utils_1.createCommentString)(comment.value.replace(/(.*(@o3rWidget ).*(\n.*)*)(\n.*)\2.*/, '$1')));
|
86
|
+
};
|
87
|
+
return context.report({
|
88
|
+
messageId: 'onlyOneWidgetAllowed',
|
89
|
+
node,
|
90
|
+
loc,
|
91
|
+
fix,
|
92
|
+
suggest: [{
|
93
|
+
messageId: 'suggestRemoveDuplicatedO3rWidget',
|
94
|
+
fix
|
95
|
+
}]
|
96
|
+
});
|
97
|
+
}
|
98
|
+
const widgetType = widgetTypes[0]?.[1].trim();
|
99
|
+
const widgetParameterTexts = Array.from(docText.matchAll(/@o3rWidgetParam (.*)/g))
|
100
|
+
.map((match) => match[1].trim());
|
101
|
+
if (!widgetType) {
|
102
|
+
if (widgetParameterTexts.length > 0) {
|
86
103
|
const fix = (fixer) => {
|
87
|
-
return fixer.replaceTextRange(comment.range, (0, utils_1.createCommentString)(comment.value.replace(/(.*
|
104
|
+
return fixer.replaceTextRange(comment.range, (0, utils_1.createCommentString)(comment.value.replace(/((.*)@o3rWidgetParam .*)/, '$2@o3rWidget widgetType\n$1')));
|
88
105
|
};
|
89
106
|
return context.report({
|
90
|
-
messageId: '
|
107
|
+
messageId: 'noParamWithoutWidget',
|
91
108
|
node,
|
92
109
|
loc,
|
93
110
|
fix,
|
94
111
|
suggest: [{
|
95
|
-
messageId: '
|
112
|
+
messageId: 'suggestAddO3rWidgetTag',
|
96
113
|
fix
|
97
114
|
}]
|
98
115
|
});
|
99
116
|
}
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
}
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
const interfaceDeclNode = node.parent?.parent;
|
120
|
+
if (!(0, utils_1.isExtendingConfiguration)(interfaceDeclNode, options.supportedInterfaceNames)) {
|
121
|
+
return context.report({
|
122
|
+
messageId: 'notInConfigurationInterface',
|
123
|
+
node,
|
124
|
+
loc
|
125
|
+
});
|
126
|
+
}
|
127
|
+
if (!supportedO3rWidgets.has(widgetType)) {
|
128
|
+
return context.report({
|
129
|
+
messageId: 'notSupportedType',
|
130
|
+
node,
|
131
|
+
loc,
|
132
|
+
data: {
|
133
|
+
o3rWidgetType: widgetType,
|
134
|
+
supportedO3rWidgets: Array.from(supportedO3rWidgets).join(', ')
|
135
|
+
},
|
136
|
+
suggest: Array.from(supportedO3rWidgets).map((suggestedWidget) => ({
|
137
|
+
messageId: 'suggestReplaceO3rWidgetType',
|
138
|
+
data: {
|
139
|
+
currentType: widgetType,
|
140
|
+
suggestedType: suggestedWidget
|
141
|
+
},
|
142
|
+
fix: (fixer) => {
|
143
|
+
return fixer.replaceTextRange(comment.range, (0, utils_1.createCommentString)(comment.value.replace(`@o3rWidget ${widgetType}`, `@o3rWidget ${suggestedWidget}`)));
|
144
|
+
}
|
145
|
+
}))
|
146
|
+
});
|
147
|
+
}
|
148
|
+
const widgetParameters = widgetParameterTexts.map((text) => {
|
149
|
+
const [name, ...values] = text.split(' ');
|
150
|
+
return {
|
151
|
+
name,
|
152
|
+
textValue: values.join(' ')
|
153
|
+
};
|
154
|
+
});
|
155
|
+
const widgetParameterNames = widgetParameters.map(({ name }) => name);
|
156
|
+
const supportedO3rWidgetParam = new Set(Object.keys(options.widgets[widgetType]));
|
157
|
+
const checkedParam = new Set();
|
158
|
+
for (const widgetParameterName of widgetParameterNames) {
|
159
|
+
if (checkedParam.has(widgetParameterName)) {
|
160
|
+
const fix = (fixer) => {
|
161
|
+
return fixer.replaceTextRange(comment.range, (0, utils_1.createCommentString)(comment.value.replace(/(.*(@o3rWidgetParam ).*(\n.*)*)(\n.*)\2.*/m, '$1')));
|
162
|
+
};
|
123
163
|
return context.report({
|
124
|
-
messageId: '
|
164
|
+
messageId: 'duplicatedParam',
|
125
165
|
node,
|
126
|
-
loc
|
166
|
+
loc,
|
167
|
+
data: {
|
168
|
+
o3rWidgetParam: widgetParameterName
|
169
|
+
},
|
170
|
+
fix,
|
171
|
+
suggest: [{
|
172
|
+
messageId: 'suggestRemoveDuplicatedO3rWidgetParam',
|
173
|
+
fix
|
174
|
+
}]
|
127
175
|
});
|
128
176
|
}
|
129
|
-
if (!
|
177
|
+
if (!supportedO3rWidgetParam.has(widgetParameterName)) {
|
130
178
|
return context.report({
|
131
|
-
messageId: '
|
179
|
+
messageId: 'notSupportedParamForType',
|
132
180
|
node,
|
133
181
|
loc,
|
134
182
|
data: {
|
183
|
+
o3rWidgetParam: widgetParameterName,
|
135
184
|
o3rWidgetType: widgetType,
|
136
|
-
|
185
|
+
supportedO3rWidgetParam: Array.from(supportedO3rWidgetParam).join(', ')
|
137
186
|
},
|
138
|
-
suggest: Array.from(
|
187
|
+
suggest: Array.from(supportedO3rWidgetParam).map((suggestedParam) => ({
|
139
188
|
messageId: 'suggestReplaceO3rWidgetType',
|
140
189
|
data: {
|
141
|
-
currentType:
|
142
|
-
suggestedType:
|
190
|
+
currentType: widgetParameterName,
|
191
|
+
suggestedType: suggestedParam
|
143
192
|
},
|
144
193
|
fix: (fixer) => {
|
145
|
-
return fixer.replaceTextRange(comment.range, (0, utils_1.createCommentString)(comment.value.replace(`@
|
194
|
+
return fixer.replaceTextRange(comment.range, (0, utils_1.createCommentString)(comment.value.replace(`@o3rWidgetParam ${widgetParameterName}`, `@o3rWidgetParam ${suggestedParam}`)));
|
146
195
|
}
|
147
196
|
}))
|
148
197
|
});
|
149
198
|
}
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
data: {
|
170
|
-
o3rWidgetParam: widgetParameterName
|
171
|
-
},
|
172
|
-
fix,
|
173
|
-
suggest: [{
|
174
|
-
messageId: 'suggestRemoveDuplicatedO3rWidget',
|
175
|
-
fix
|
176
|
-
}]
|
177
|
-
});
|
178
|
-
}
|
179
|
-
if (!supportedO3rWidgetParam.has(widgetParameterName)) {
|
180
|
-
return context.report({
|
181
|
-
messageId: 'notSupportedParamForType',
|
182
|
-
node,
|
183
|
-
loc,
|
199
|
+
checkedParam.add(widgetParameterName);
|
200
|
+
}
|
201
|
+
const firstRequiredParam = Object.entries(options.widgets[widgetType]).find(([param, { required }]) => required && !checkedParam.has(param));
|
202
|
+
if (firstRequiredParam) {
|
203
|
+
const [firstRequiredParamName] = firstRequiredParam;
|
204
|
+
const fix = (fixer) => {
|
205
|
+
return fixer.replaceTextRange(comment.range, (0, utils_1.createCommentString)(comment.value.replace(/((.*)@o3rWidget (.*))/, `$1\n$2@o3rWidgetParam ${firstRequiredParamName} value`)));
|
206
|
+
};
|
207
|
+
return context.report({
|
208
|
+
messageId: 'requiredParamMissing',
|
209
|
+
node,
|
210
|
+
loc,
|
211
|
+
data: {
|
212
|
+
o3rWidgetParam: firstRequiredParamName,
|
213
|
+
o3rWidgetType: widgetType
|
214
|
+
},
|
215
|
+
fix,
|
216
|
+
suggest: [{
|
217
|
+
messageId: 'suggestParamMissing',
|
184
218
|
data: {
|
185
|
-
o3rWidgetParam:
|
186
|
-
o3rWidgetType: widgetType,
|
187
|
-
supportedO3rWidgetParam: Array.from(supportedO3rWidgetParam).join(', ')
|
219
|
+
o3rWidgetParam: firstRequiredParamName
|
188
220
|
},
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
}
|
201
|
-
checkedParam.add(widgetParameterName);
|
202
|
-
}
|
203
|
-
const firstRequiredParam = Object.entries(options.widgets[widgetType]).find(([param, { required }]) => required && !checkedParam.has(param));
|
204
|
-
if (firstRequiredParam) {
|
205
|
-
const [firstRequiredParamName] = firstRequiredParam;
|
206
|
-
const fix = (fixer) => {
|
207
|
-
return fixer.replaceTextRange(comment.range, (0, utils_1.createCommentString)(comment.value.replace(/((.*)@o3rWidget (.*))/, `$1\n$2@o3rWidgetParam ${firstRequiredParamName} value`)));
|
208
|
-
};
|
209
|
-
return context.report({
|
210
|
-
messageId: 'requiredParamMissing',
|
211
|
-
node,
|
212
|
-
loc,
|
213
|
-
data: {
|
214
|
-
o3rWidgetParam: firstRequiredParamName,
|
215
|
-
o3rWidgetType: widgetType
|
216
|
-
},
|
217
|
-
fix,
|
218
|
-
suggest: [{
|
219
|
-
messageId: 'suggestParamMissing',
|
220
|
-
data: {
|
221
|
-
o3rWidgetParam: firstRequiredParamName
|
222
|
-
},
|
223
|
-
fix
|
224
|
-
}]
|
225
|
-
});
|
226
|
-
}
|
227
|
-
for (const widgetParameter of widgetParameters) {
|
228
|
-
const { name, textValue } = widgetParameter;
|
229
|
-
const supportedTypeForParam = options.widgets[widgetType][name];
|
230
|
-
try {
|
231
|
-
const value = JSON.parse(textValue);
|
232
|
-
if (supportedTypeForParam.type.endsWith('[]')) {
|
233
|
-
if (Array.isArray(value) && value.every((element) => typeof element === supportedTypeForParam.type.substring(0, -2))) {
|
234
|
-
continue;
|
235
|
-
}
|
236
|
-
}
|
237
|
-
else if (typeof value === supportedTypeForParam.type) {
|
221
|
+
fix
|
222
|
+
}]
|
223
|
+
});
|
224
|
+
}
|
225
|
+
for (const widgetParameter of widgetParameters) {
|
226
|
+
const { name, textValue } = widgetParameter;
|
227
|
+
const supportedTypeForParam = options.widgets[widgetType][name];
|
228
|
+
try {
|
229
|
+
const value = JSON.parse(textValue);
|
230
|
+
if (supportedTypeForParam.type.endsWith('[]')) {
|
231
|
+
if (Array.isArray(value) && value.every((element) => typeof element === supportedTypeForParam.type.substring(0, -2))) {
|
238
232
|
continue;
|
239
233
|
}
|
240
234
|
}
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
node,
|
245
|
-
loc,
|
246
|
-
data: {
|
247
|
-
o3rWidgetParam: name,
|
248
|
-
o3rWidgetParamType: supportedTypeForParam.type
|
249
|
-
}
|
250
|
-
});
|
235
|
+
else if (typeof value === supportedTypeForParam.type) {
|
236
|
+
continue;
|
237
|
+
}
|
251
238
|
}
|
239
|
+
catch { }
|
240
|
+
return context.report({
|
241
|
+
messageId: 'invalidParamValueType',
|
242
|
+
node,
|
243
|
+
loc,
|
244
|
+
data: {
|
245
|
+
o3rWidgetParam: name,
|
246
|
+
o3rWidgetParamType: supportedTypeForParam.type
|
247
|
+
}
|
248
|
+
});
|
252
249
|
}
|
253
250
|
};
|
251
|
+
return {
|
252
|
+
TSPropertySignature: rule
|
253
|
+
};
|
254
254
|
}
|
255
255
|
});
|
package/src/rules/utils.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ESLintUtils, TSESLint, TSESTree } from '@typescript-eslint/utils';
|
2
2
|
/** ESLint rule generator */
|
3
|
-
export declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({
|
3
|
+
export declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
|
4
4
|
/** Default supported interface names */
|
5
5
|
export declare const defaultSupportedInterfaceNames: string[];
|
6
6
|
/**
|
package/src/rules/utils.js
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.createCommentString = exports.getNodeComment = exports.isExtendingConfiguration = exports.defaultSupportedInterfaceNames = exports.createRule = void 0;
|
4
|
-
const utils_1 = require("@typescript-eslint/utils");
|
5
4
|
const node_fs_1 = require("node:fs");
|
6
5
|
const path = require("node:path");
|
6
|
+
const utils_1 = require("@typescript-eslint/utils");
|
7
7
|
/** Current package version (format: <major>.<minor>)*/
|
8
|
-
const version = JSON.parse((0, node_fs_1.readFileSync)(path.resolve(__dirname, '..', '..', 'package.json'), { encoding: '
|
8
|
+
const version = JSON.parse((0, node_fs_1.readFileSync)(path.resolve(__dirname, '..', '..', 'package.json'), { encoding: 'utf8' })).version?.split('.').slice(0, 2).join('.') || '0.0';
|
9
9
|
/** ESLint rule generator */
|
10
|
-
// eslint-disable-next-line new-cap
|
10
|
+
// eslint-disable-next-line new-cap -- naming convention imposed by typescript-eslint
|
11
11
|
exports.createRule = utils_1.ESLintUtils.RuleCreator((name) => {
|
12
|
-
|
13
|
-
return 'file:' + path.resolve(__dirname, '..', '..', '..', '..', '..', 'docs', 'linter', 'eslint-plugin', 'rules', `${name}.md`);
|
14
|
-
}
|
15
|
-
return `https://github.com/AmadeusITGroup/otter/tree/release/${version}/docs/linter/eslint-plugin/rules/${name}.md`;
|
12
|
+
return `https://github.com/AmadeusITGroup/otter/tree/release/${version === '0.0' ? 'main' : version}/docs/linter/eslint-plugin/rules/${name}.md`;
|
16
13
|
});
|
17
14
|
/** Default supported interface names */
|
18
15
|
exports.defaultSupportedInterfaceNames = ['Configuration', 'NestedConfiguration'];
|
package/src/rules/yaml/utils.js
CHANGED
@@ -15,7 +15,7 @@ function isYamlParserServices(parserServices) {
|
|
15
15
|
* @param context Rule context
|
16
16
|
*/
|
17
17
|
function getYamlParserServices(context) {
|
18
|
-
const parserService = context.parserServices;
|
18
|
+
const parserService = context.sourceCode.parserServices;
|
19
19
|
if (!isYamlParserServices(parserService)) {
|
20
20
|
/*
|
21
21
|
* The user needs to have configured "parser" in their eslint config and set it
|
@@ -31,7 +31,7 @@ function getYamlParserServices(context) {
|
|
31
31
|
* @param context
|
32
32
|
*/
|
33
33
|
function ensureJsoncParser(context) {
|
34
|
-
if (!(context.parserServices)) {
|
34
|
+
if (!(context.sourceCode.parserServices)) {
|
35
35
|
/*
|
36
36
|
* The user needs to have configured "parser" in their eslint config and set it
|
37
37
|
* to yaml-eslint-parser
|
package/src/rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
interface
|
1
|
+
export interface YarnrcPackageExtensionsHarmonizeOptions {
|
2
2
|
/** List of package.json to ignore when determining the dependencies versions */
|
3
3
|
excludePackages: string[];
|
4
4
|
/** List of dependency types in package.json to parse */
|
@@ -8,5 +8,5 @@ interface Options {
|
|
8
8
|
/** List of dependency types to validate in .yarnrc.yml */
|
9
9
|
yarnrcDependencyTypes: string[];
|
10
10
|
}
|
11
|
-
declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"error" | "versionUpdate", [
|
11
|
+
declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"error" | "versionUpdate", [YarnrcPackageExtensionsHarmonizeOptions, ...any[]], unknown, import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
|
12
12
|
export default _default;
|
package/src/rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize.js
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const path = require("node:path");
|
4
4
|
const semver = require("semver");
|
5
|
-
const utils_1 = require("../../utils");
|
6
|
-
const utils_2 = require("../utils");
|
7
5
|
const yaml_eslint_parser_1 = require("yaml-eslint-parser");
|
8
6
|
const version_harmonize_1 = require("../../json/json-dependency-versions-harmonize/version-harmonize");
|
7
|
+
const utils_1 = require("../../utils");
|
8
|
+
const utils_2 = require("../utils");
|
9
9
|
const defaultOptions = [{
|
10
10
|
ignoredDependencies: [],
|
11
11
|
excludePackages: [],
|
@@ -67,55 +67,55 @@ exports.default = (0, utils_1.createRule)({
|
|
67
67
|
defaultOptions,
|
68
68
|
create: (context, [options]) => {
|
69
69
|
const parserServices = (0, utils_2.getYamlParserServices)(context);
|
70
|
-
const dirname = path.dirname(context.
|
70
|
+
const dirname = path.dirname(context.filename);
|
71
71
|
const workspace = (0, version_harmonize_1.findWorkspacePackageJsons)(dirname);
|
72
|
-
const bestRanges = workspace
|
73
|
-
(0, version_harmonize_1.getBestRanges)(options.dependencyTypesInPackages, workspace.packages.filter(({ content }) => !content.name || !options.excludePackages.includes(content.name)))
|
74
|
-
{};
|
75
|
-
const ignoredDependencies = options.ignoredDependencies.map((dep) => new RegExp(dep.replace(/[
|
72
|
+
const bestRanges = workspace
|
73
|
+
? (0, version_harmonize_1.getBestRanges)(options.dependencyTypesInPackages, workspace.packages.filter(({ content }) => !content.name || !options.excludePackages.includes(content.name)))
|
74
|
+
: {};
|
75
|
+
const ignoredDependencies = options.ignoredDependencies.map((dep) => new RegExp(dep.replace(/[$()+.?[\\\]^{|}]/g, '\\$&').replace(/\*/g, '.*')));
|
76
76
|
if (parserServices.isYAML) {
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
const
|
85
|
-
if (
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
const
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
{
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
]
|
113
|
-
});
|
114
|
-
}
|
77
|
+
const rule = (node) => {
|
78
|
+
if (node.value) {
|
79
|
+
const range = (0, yaml_eslint_parser_1.getStaticYAMLValue)(node.value)?.toString();
|
80
|
+
const parent = node.parent.parent && node.parent.parent.type === 'YAMLPair' && (0, yaml_eslint_parser_1.getStaticYAMLValue)(node.parent.parent.key)?.toString();
|
81
|
+
const baseNode = node.parent.parent.parent.parent?.parent?.parent;
|
82
|
+
const isCorrectNode = baseNode && baseNode.type === 'YAMLPair' && (0, yaml_eslint_parser_1.getStaticYAMLValue)(baseNode.key)?.toString() === 'packageExtensions';
|
83
|
+
if (isCorrectNode && semver.validRange(range) && parent && options.yarnrcDependencyTypes.includes(parent)) {
|
84
|
+
const depName = node.key && (0, yaml_eslint_parser_1.getStaticYAMLValue)(node.key)?.toString();
|
85
|
+
if (!depName || !bestRanges[depName] || ignoredDependencies.some((ignore) => ignore.test(depName))) {
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
const minYarnrcVersion = semver.minVersion(range);
|
89
|
+
const minBestRangeVersion = semver.minVersion(bestRanges[depName].range);
|
90
|
+
if (minYarnrcVersion && minBestRangeVersion && semver.lt(minYarnrcVersion, minBestRangeVersion)) {
|
91
|
+
const version = bestRanges[depName].range;
|
92
|
+
const packageJsonFile = bestRanges[depName].path;
|
93
|
+
context.report({
|
94
|
+
loc: node.value.loc,
|
95
|
+
messageId: 'error',
|
96
|
+
data: {
|
97
|
+
depName,
|
98
|
+
version,
|
99
|
+
packageJsonFile
|
100
|
+
},
|
101
|
+
fix: (fixer) => fixer.replaceTextRange(node.value.range, `${version}`),
|
102
|
+
suggest: [
|
103
|
+
{
|
104
|
+
messageId: 'versionUpdate',
|
105
|
+
data: {
|
106
|
+
version
|
107
|
+
},
|
108
|
+
fix: (fixer) => fixer.replaceTextRange(node.value.range, `${version}`)
|
109
|
+
}
|
110
|
+
]
|
111
|
+
});
|
115
112
|
}
|
116
113
|
}
|
117
114
|
}
|
118
115
|
};
|
116
|
+
return {
|
117
|
+
YAMLPair: rule
|
118
|
+
};
|
119
119
|
}
|
120
120
|
return {};
|
121
121
|
}
|