eslint-plugin-mgw-eslint-rules 2.3.26 → 2.3.28
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/dist/index.js +149 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +149 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3261,8 +3261,8 @@ var require_RuleCreator = __commonJS({
|
|
|
3261
3261
|
exports2.RuleCreator = RuleCreator;
|
|
3262
3262
|
var applyDefault_1 = require_applyDefault();
|
|
3263
3263
|
function RuleCreator(urlCreator) {
|
|
3264
|
-
return function createNamedRule({ meta, name, ...
|
|
3265
|
-
const ruleWithDocs =
|
|
3264
|
+
return function createNamedRule({ meta, name, ...rule11 }) {
|
|
3265
|
+
const ruleWithDocs = createRule11({
|
|
3266
3266
|
meta: {
|
|
3267
3267
|
...meta,
|
|
3268
3268
|
docs: {
|
|
@@ -3271,12 +3271,12 @@ var require_RuleCreator = __commonJS({
|
|
|
3271
3271
|
}
|
|
3272
3272
|
},
|
|
3273
3273
|
name,
|
|
3274
|
-
...
|
|
3274
|
+
...rule11
|
|
3275
3275
|
});
|
|
3276
3276
|
return ruleWithDocs;
|
|
3277
3277
|
};
|
|
3278
3278
|
}
|
|
3279
|
-
function
|
|
3279
|
+
function createRule11({
|
|
3280
3280
|
create,
|
|
3281
3281
|
// Keep accepting deprecated defaultOptions for backward compatibility.
|
|
3282
3282
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
@@ -3296,7 +3296,7 @@ var require_RuleCreator = __commonJS({
|
|
|
3296
3296
|
};
|
|
3297
3297
|
}
|
|
3298
3298
|
RuleCreator.withoutDocs = function withoutDocs(args) {
|
|
3299
|
-
return
|
|
3299
|
+
return createRule11(args);
|
|
3300
3300
|
};
|
|
3301
3301
|
}
|
|
3302
3302
|
});
|
|
@@ -20621,13 +20621,13 @@ ${ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment()}`;
|
|
|
20621
20621
|
}
|
|
20622
20622
|
_scopeKeyframesRelatedCss(cssText, scopeSelector) {
|
|
20623
20623
|
const unscopedKeyframesSet = /* @__PURE__ */ new Set();
|
|
20624
|
-
const scopedKeyframesCssText = processRules(cssText, (
|
|
20625
|
-
return processRules(scopedKeyframesCssText, (
|
|
20624
|
+
const scopedKeyframesCssText = processRules(cssText, (rule11) => this._scopeLocalKeyframeDeclarations(rule11, scopeSelector, unscopedKeyframesSet));
|
|
20625
|
+
return processRules(scopedKeyframesCssText, (rule11) => this._scopeAnimationRule(rule11, scopeSelector, unscopedKeyframesSet));
|
|
20626
20626
|
}
|
|
20627
|
-
_scopeLocalKeyframeDeclarations(
|
|
20627
|
+
_scopeLocalKeyframeDeclarations(rule11, scopeSelector, unscopedKeyframesSet) {
|
|
20628
20628
|
return {
|
|
20629
|
-
...
|
|
20630
|
-
selector:
|
|
20629
|
+
...rule11,
|
|
20630
|
+
selector: rule11.selector.replace(/(^@(?:-webkit-)?keyframes(?:\s+))(['"]?)(.+)\2(\s*)$/, (_, start, quote, keyframeName, endSpaces) => {
|
|
20631
20631
|
unscopedKeyframesSet.add(unescapeQuotes(keyframeName, quote));
|
|
20632
20632
|
return `${start}${quote}${scopeSelector}_${keyframeName}${quote}${endSpaces}`;
|
|
20633
20633
|
})
|
|
@@ -20640,8 +20640,8 @@ ${ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment()}`;
|
|
|
20640
20640
|
});
|
|
20641
20641
|
}
|
|
20642
20642
|
_animationDeclarationKeyframesRe = /(^|\s+|,)(?:(?:(['"])((?:\\\\|\\\2|(?!\2).)+)\2)|(-?[A-Za-z][\w\-]*))(?=[,\s]|$)/g;
|
|
20643
|
-
_scopeAnimationRule(
|
|
20644
|
-
let content =
|
|
20643
|
+
_scopeAnimationRule(rule11, scopeSelector, unscopedKeyframesSet) {
|
|
20644
|
+
let content = rule11.content.replace(/((?:^|\s+|;)(?:-webkit-)?animation\s*:\s*),*([^;]+)/g, (_, start, animationDeclarations) => start + animationDeclarations.replace(this._animationDeclarationKeyframesRe, (original, leadingSpaces, quote = "", quotedName, nonQuotedName) => {
|
|
20645
20645
|
if (quotedName) {
|
|
20646
20646
|
return `${leadingSpaces}${this._scopeAnimationKeyframe(`${quote}${quotedName}${quote}`, scopeSelector, unscopedKeyframesSet)}`;
|
|
20647
20647
|
} else {
|
|
@@ -20650,7 +20650,7 @@ ${ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment()}`;
|
|
|
20650
20650
|
}));
|
|
20651
20651
|
content = content.replace(/((?:^|\s+|;)(?:-webkit-)?animation-name(?:\s*):(?:\s*))([^;]+)/g, (_match, start, commaSeparatedKeyframes) => `${start}${commaSeparatedKeyframes.split(",").map((keyframe) => this._scopeAnimationKeyframe(keyframe, scopeSelector, unscopedKeyframesSet)).join(",")}`);
|
|
20652
20652
|
return {
|
|
20653
|
-
...
|
|
20653
|
+
...rule11,
|
|
20654
20654
|
content
|
|
20655
20655
|
};
|
|
20656
20656
|
}
|
|
@@ -20661,8 +20661,8 @@ ${ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment()}`;
|
|
|
20661
20661
|
}
|
|
20662
20662
|
_insertPolyfillRulesInCssText(cssText) {
|
|
20663
20663
|
return cssText.replace(_cssContentRuleRe, (...m) => {
|
|
20664
|
-
const
|
|
20665
|
-
return m[4] +
|
|
20664
|
+
const rule11 = m[0].replace(m[1], "").replace(m[2], "");
|
|
20665
|
+
return m[4] + rule11;
|
|
20666
20666
|
});
|
|
20667
20667
|
}
|
|
20668
20668
|
_scopeCssText(cssText, scopeSelector, hostSelector) {
|
|
@@ -20683,8 +20683,8 @@ ${ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment()}`;
|
|
|
20683
20683
|
let m;
|
|
20684
20684
|
_cssContentUnscopedRuleRe.lastIndex = 0;
|
|
20685
20685
|
while ((m = _cssContentUnscopedRuleRe.exec(cssText)) !== null) {
|
|
20686
|
-
const
|
|
20687
|
-
r +=
|
|
20686
|
+
const rule11 = m[0].replace(m[2], "").replace(m[1], m[4]);
|
|
20687
|
+
r += rule11 + "\n\n";
|
|
20688
20688
|
}
|
|
20689
20689
|
return r;
|
|
20690
20690
|
}
|
|
@@ -20769,28 +20769,28 @@ ${ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment()}`;
|
|
|
20769
20769
|
return _shadowDOMSelectorsRe.reduce((result, pattern) => result.replace(pattern, " "), cssText);
|
|
20770
20770
|
}
|
|
20771
20771
|
_scopeSelectors(cssText, scopeSelector, hostSelector) {
|
|
20772
|
-
return processRules(cssText, (
|
|
20773
|
-
let selector =
|
|
20774
|
-
let content =
|
|
20775
|
-
if (
|
|
20772
|
+
return processRules(cssText, (rule11) => {
|
|
20773
|
+
let selector = rule11.selector;
|
|
20774
|
+
let content = rule11.content;
|
|
20775
|
+
if (rule11.selector[0] !== "@") {
|
|
20776
20776
|
selector = this._scopeSelector({
|
|
20777
20777
|
selector,
|
|
20778
20778
|
scopeSelector,
|
|
20779
20779
|
hostSelector,
|
|
20780
20780
|
isParentSelector: true
|
|
20781
20781
|
});
|
|
20782
|
-
} else if (scopedAtRuleIdentifiers.some((atRule) =>
|
|
20783
|
-
content = this._scopeSelectors(
|
|
20784
|
-
} else if (
|
|
20785
|
-
content = this._stripScopingSelectors(
|
|
20782
|
+
} else if (scopedAtRuleIdentifiers.some((atRule) => rule11.selector.startsWith(atRule))) {
|
|
20783
|
+
content = this._scopeSelectors(rule11.content, scopeSelector, hostSelector);
|
|
20784
|
+
} else if (rule11.selector.startsWith("@font-face") || rule11.selector.startsWith("@page")) {
|
|
20785
|
+
content = this._stripScopingSelectors(rule11.content);
|
|
20786
20786
|
}
|
|
20787
20787
|
return new CssRule(selector, content);
|
|
20788
20788
|
});
|
|
20789
20789
|
}
|
|
20790
20790
|
_stripScopingSelectors(cssText) {
|
|
20791
|
-
return processRules(cssText, (
|
|
20792
|
-
const selector =
|
|
20793
|
-
return new CssRule(selector,
|
|
20791
|
+
return processRules(cssText, (rule11) => {
|
|
20792
|
+
const selector = rule11.selector.replace(_shadowDeepSelectors, " ").replace(_polyfillHostNoCombinatorRe, " ");
|
|
20793
|
+
return new CssRule(selector, rule11.content);
|
|
20794
20794
|
});
|
|
20795
20795
|
}
|
|
20796
20796
|
_safeSelector;
|
|
@@ -21051,8 +21051,8 @@ ${ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment()}`;
|
|
|
21051
21051
|
suffix = suffix.substring(BLOCK_PLACEHOLDER.length + 1);
|
|
21052
21052
|
contentPrefix = "{";
|
|
21053
21053
|
}
|
|
21054
|
-
const
|
|
21055
|
-
return `${m[1]}${
|
|
21054
|
+
const rule11 = ruleCallback(new CssRule(selector, content));
|
|
21055
|
+
return `${m[1]}${rule11.selector}${m[3]}${contentPrefix}${rule11.content}${suffix}`;
|
|
21056
21056
|
});
|
|
21057
21057
|
return unescapeInStrings(escapedResult);
|
|
21058
21058
|
}
|
|
@@ -44056,11 +44056,9 @@ var rule3 = createRule3({
|
|
|
44056
44056
|
return {
|
|
44057
44057
|
Identifier(node) {
|
|
44058
44058
|
const variableNode = services.esTreeNodeToTSNodeMap?.get(node);
|
|
44059
|
-
console.log(node);
|
|
44060
44059
|
if (variableNode) {
|
|
44061
44060
|
const type = checker.getTypeAtLocation(variableNode);
|
|
44062
44061
|
const typeName = checker.typeToString(type);
|
|
44063
|
-
console.log(type, typeName, variableNode);
|
|
44064
44062
|
if (isSignal(typeName)) {
|
|
44065
44063
|
const parent = node.parent;
|
|
44066
44064
|
if (!parent || parent.type !== import_utils3.AST_NODE_TYPES.CallExpression) {
|
|
@@ -44248,15 +44246,109 @@ var rule6 = createRule6({
|
|
|
44248
44246
|
}
|
|
44249
44247
|
});
|
|
44250
44248
|
|
|
44249
|
+
// src/rules/reactive-naming-convention.ts
|
|
44250
|
+
var import_utils7 = __toESM(require_dist4());
|
|
44251
|
+
var RULE_NAME7 = "reactive-naming-convention";
|
|
44252
|
+
var createRule7 = import_utils7.ESLintUtils.RuleCreator((name) => `https://github.com/developpement-megao/mgw-eslint-rules/docs/rules/${name}.md`);
|
|
44253
|
+
var rule7 = createRule7({
|
|
44254
|
+
name: RULE_NAME7,
|
|
44255
|
+
meta: {
|
|
44256
|
+
type: "suggestion",
|
|
44257
|
+
fixable: "code",
|
|
44258
|
+
docs: {
|
|
44259
|
+
description: "Naming convention for reactive variables and properties (name must end with $ and $$ for WritableSignals and Subjects)",
|
|
44260
|
+
recommended: true
|
|
44261
|
+
},
|
|
44262
|
+
messages: {
|
|
44263
|
+
reactiveNamingConvention: "Element {{ typeName }} names {{ name }} must end with `{{ suffix }}`."
|
|
44264
|
+
},
|
|
44265
|
+
schema: []
|
|
44266
|
+
// No options
|
|
44267
|
+
},
|
|
44268
|
+
defaultOptions: [],
|
|
44269
|
+
create(context) {
|
|
44270
|
+
const parserServices = context.sourceCode.parserServices;
|
|
44271
|
+
if (!parserServices?.program || !parserServices.esTreeNodeToTSNodeMap) {
|
|
44272
|
+
return {};
|
|
44273
|
+
}
|
|
44274
|
+
const listeReactiveWritableTypes = ["Subject", "BehaviorSubject", "ReplaySubject", "AsyncSubject", "WritableSignal", "InputSignal"];
|
|
44275
|
+
const listeReactiveReadonlyTypes = ["Signal", "Observable", "Promise"];
|
|
44276
|
+
const checker = parserServices.program.getTypeChecker();
|
|
44277
|
+
function checkNode(node) {
|
|
44278
|
+
const name = node.name;
|
|
44279
|
+
if (!name || name === "_" || !parserServices?.esTreeNodeToTSNodeMap) {
|
|
44280
|
+
return;
|
|
44281
|
+
}
|
|
44282
|
+
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
|
44283
|
+
const type = checker.getTypeAtLocation(tsNode);
|
|
44284
|
+
const typeName = checker.typeToString(type);
|
|
44285
|
+
const isReactiveReadonlyTypes = listeReactiveReadonlyTypes.includes(typeName);
|
|
44286
|
+
const suffix = isReactiveReadonlyTypes ? "$" : "$$";
|
|
44287
|
+
if ((isReactiveReadonlyTypes || listeReactiveWritableTypes.includes(typeName)) && (!name.endsWith(suffix) || suffix === "$" && name.endsWith("$$"))) {
|
|
44288
|
+
context.report({
|
|
44289
|
+
node,
|
|
44290
|
+
messageId: "reactiveNamingConvention",
|
|
44291
|
+
data: {
|
|
44292
|
+
typeName,
|
|
44293
|
+
name,
|
|
44294
|
+
suffix
|
|
44295
|
+
},
|
|
44296
|
+
fix(fixer) {
|
|
44297
|
+
const baseName = name.replace(/\$+$/, "");
|
|
44298
|
+
const newName = `${baseName}${suffix}`;
|
|
44299
|
+
const sourceCode = context.sourceCode;
|
|
44300
|
+
const scope = sourceCode.getScope(node);
|
|
44301
|
+
const fixes = [];
|
|
44302
|
+
fixes.push(fixer.replaceText(node, newName));
|
|
44303
|
+
let variable;
|
|
44304
|
+
let current = scope;
|
|
44305
|
+
while (current) {
|
|
44306
|
+
variable = current.variables.find((v) => v.name === name);
|
|
44307
|
+
if (variable) {
|
|
44308
|
+
for (const ref of variable.references) {
|
|
44309
|
+
const refNode = ref.identifier;
|
|
44310
|
+
if (refNode !== node) {
|
|
44311
|
+
fixes.push(fixer.replaceText(refNode, newName));
|
|
44312
|
+
}
|
|
44313
|
+
}
|
|
44314
|
+
break;
|
|
44315
|
+
}
|
|
44316
|
+
if (!current.upper) {
|
|
44317
|
+
break;
|
|
44318
|
+
}
|
|
44319
|
+
current = current.upper;
|
|
44320
|
+
}
|
|
44321
|
+
return fixes;
|
|
44322
|
+
}
|
|
44323
|
+
});
|
|
44324
|
+
}
|
|
44325
|
+
}
|
|
44326
|
+
return {
|
|
44327
|
+
// Déclarations de variables : const x = signal(0)
|
|
44328
|
+
VariableDeclarator(node) {
|
|
44329
|
+
if (node.id?.type === "Identifier") {
|
|
44330
|
+
checkNode(node.id);
|
|
44331
|
+
}
|
|
44332
|
+
},
|
|
44333
|
+
// Propriétés de classe : count = signal(0)
|
|
44334
|
+
PropertyDefinition(node) {
|
|
44335
|
+
if (node.key?.type === "Identifier") {
|
|
44336
|
+
checkNode(node.key);
|
|
44337
|
+
}
|
|
44338
|
+
}
|
|
44339
|
+
};
|
|
44340
|
+
}
|
|
44341
|
+
});
|
|
44342
|
+
|
|
44251
44343
|
// src/rules/service-class-suffix.ts
|
|
44252
|
-
var
|
|
44253
|
-
var
|
|
44254
|
-
var
|
|
44344
|
+
var import_utils8 = __toESM(require_dist6());
|
|
44345
|
+
var import_utils9 = __toESM(require_dist4());
|
|
44346
|
+
var RULE_NAME8 = "service-class-suffix";
|
|
44255
44347
|
var SUFFIXES_DEFAULT = ["Service"];
|
|
44256
44348
|
var DOCS_RULES3 = "https://github.com/developpement-megao/mgw-eslint-rules/blob/main/docs/rules";
|
|
44257
|
-
var
|
|
44258
|
-
var
|
|
44259
|
-
name:
|
|
44349
|
+
var createRule8 = import_utils9.ESLintUtils.RuleCreator((name) => `${DOCS_RULES3}/${name}.md`);
|
|
44350
|
+
var rule8 = createRule8({
|
|
44351
|
+
name: RULE_NAME8,
|
|
44260
44352
|
meta: {
|
|
44261
44353
|
type: "suggestion",
|
|
44262
44354
|
docs: {
|
|
@@ -44288,7 +44380,7 @@ var rule7 = createRule7({
|
|
|
44288
44380
|
],
|
|
44289
44381
|
create(context, [{ suffixes }]) {
|
|
44290
44382
|
return {
|
|
44291
|
-
[
|
|
44383
|
+
[import_utils8.Selectors.INJECTABLE_CLASS_DECORATOR](node) {
|
|
44292
44384
|
const classDeclaration = node.parent;
|
|
44293
44385
|
if (!classDeclaration.id) {
|
|
44294
44386
|
return;
|
|
@@ -44311,11 +44403,11 @@ var rule7 = createRule7({
|
|
|
44311
44403
|
});
|
|
44312
44404
|
|
|
44313
44405
|
// src/rules/template/attributes-naming-convention.ts
|
|
44314
|
-
var
|
|
44315
|
-
var
|
|
44406
|
+
var import_utils10 = __toESM(require_dist6());
|
|
44407
|
+
var import_utils11 = __toESM(require_dist4());
|
|
44316
44408
|
var NAMING_CONVENTIONS = ["camelCase", "strictCamelCase", "PascalCase", "StrictPascalCase", "snake_case", "UPPER_CASE", "kebab-case"];
|
|
44317
44409
|
var ATTRIBUTE_CONVENTION_POSSIBLE_VALUES = [...NAMING_CONVENTIONS];
|
|
44318
|
-
var
|
|
44410
|
+
var RULE_NAME9 = "template/attributes-naming-convention";
|
|
44319
44411
|
var conventionPatterns = {
|
|
44320
44412
|
camelCase: /^[a-z][a-zA-Z0-9]*$/,
|
|
44321
44413
|
strictCamelCase: /^(?!.*[A-Z]{2})[a-z][a-zA-Z0-9]*$/,
|
|
@@ -44326,9 +44418,9 @@ var conventionPatterns = {
|
|
|
44326
44418
|
"kebab-case": /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/
|
|
44327
44419
|
};
|
|
44328
44420
|
var DOCS_RULES4 = "https://github.com/developpement-megao/mgw-eslint-rules/tree/main/docs/rules";
|
|
44329
|
-
var
|
|
44330
|
-
var
|
|
44331
|
-
name:
|
|
44421
|
+
var createRule9 = import_utils11.ESLintUtils.RuleCreator((name) => `${DOCS_RULES4}/${name}.md`);
|
|
44422
|
+
var rule9 = createRule9({
|
|
44423
|
+
name: RULE_NAME9,
|
|
44332
44424
|
meta: {
|
|
44333
44425
|
type: "suggestion",
|
|
44334
44426
|
docs: {
|
|
@@ -44387,7 +44479,7 @@ var rule8 = createRule8({
|
|
|
44387
44479
|
}
|
|
44388
44480
|
],
|
|
44389
44481
|
create(context, [options]) {
|
|
44390
|
-
const parserServices = (0,
|
|
44482
|
+
const parserServices = (0, import_utils10.getTemplateParserServices)(context);
|
|
44391
44483
|
const listeAttributes = new Map(
|
|
44392
44484
|
Object.entries(options).map(([a, n]) => {
|
|
44393
44485
|
const listeNommage = typeof n === "string" ? [n] : n;
|
|
@@ -44436,13 +44528,13 @@ var rule8 = createRule8({
|
|
|
44436
44528
|
});
|
|
44437
44529
|
|
|
44438
44530
|
// src/rules/template/prefer-class-style-binding.ts
|
|
44439
|
-
var
|
|
44440
|
-
var
|
|
44441
|
-
var
|
|
44531
|
+
var import_utils12 = __toESM(require_dist6());
|
|
44532
|
+
var import_utils13 = __toESM(require_dist4());
|
|
44533
|
+
var RULE_NAME10 = "template/prefer-class-style-binding";
|
|
44442
44534
|
var DOCS_RULES5 = "https://github.com/developpement-megao/mgw-eslint-rules/tree/main/docs/rules";
|
|
44443
|
-
var
|
|
44444
|
-
var
|
|
44445
|
-
name:
|
|
44535
|
+
var createRule10 = import_utils13.ESLintUtils.RuleCreator((name) => `${DOCS_RULES5}/${name}.md`);
|
|
44536
|
+
var rule10 = createRule10({
|
|
44537
|
+
name: RULE_NAME10,
|
|
44446
44538
|
meta: {
|
|
44447
44539
|
type: "suggestion",
|
|
44448
44540
|
docs: {
|
|
@@ -44457,7 +44549,7 @@ var rule9 = createRule9({
|
|
|
44457
44549
|
},
|
|
44458
44550
|
defaultOptions: [],
|
|
44459
44551
|
create(context) {
|
|
44460
|
-
const parserServices = (0,
|
|
44552
|
+
const parserServices = (0, import_utils12.getTemplateParserServices)(context);
|
|
44461
44553
|
return {
|
|
44462
44554
|
// Détecte les attributs ngClass et ngStyle et inputs [ngClass] et [ngStyle] dans les templates
|
|
44463
44555
|
Element(node) {
|
|
@@ -44483,10 +44575,11 @@ var rules = {
|
|
|
44483
44575
|
[RULE_NAME3]: rule3,
|
|
44484
44576
|
[RULE_NAME4]: rule4,
|
|
44485
44577
|
[RULE_NAME]: rule,
|
|
44486
|
-
[
|
|
44487
|
-
[
|
|
44578
|
+
[RULE_NAME10]: rule10,
|
|
44579
|
+
[RULE_NAME8]: rule8,
|
|
44488
44580
|
[RULE_NAME2]: rule2,
|
|
44489
|
-
[
|
|
44581
|
+
[RULE_NAME9]: rule9,
|
|
44582
|
+
[RULE_NAME7]: rule7
|
|
44490
44583
|
};
|
|
44491
44584
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44492
44585
|
0 && (module.exports = {
|