eslint-plugin-mgw-eslint-rules 2.3.29 → 2.3.31
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 +10 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -44260,7 +44260,8 @@ var rule7 = createRule7({
|
|
|
44260
44260
|
recommended: true
|
|
44261
44261
|
},
|
|
44262
44262
|
messages: {
|
|
44263
|
-
|
|
44263
|
+
reactiveVariableNamingConvention: "Variable `{{ name }}` must end with `{{ suffix }}`.",
|
|
44264
|
+
reactivePropertyNamingConvention: "Property `{{ name }}` must end with `{{ suffix }}`."
|
|
44264
44265
|
},
|
|
44265
44266
|
schema: []
|
|
44266
44267
|
// No options
|
|
@@ -44271,10 +44272,10 @@ var rule7 = createRule7({
|
|
|
44271
44272
|
if (!parserServices?.program || !parserServices.esTreeNodeToTSNodeMap) {
|
|
44272
44273
|
return {};
|
|
44273
44274
|
}
|
|
44274
|
-
const listeReactiveWritableTypes = ["Subject", "
|
|
44275
|
+
const listeReactiveWritableTypes = ["Subject", "WritableSignal", "InputSignal"];
|
|
44275
44276
|
const listeReactiveReadonlyTypes = ["Signal", "Observable", "Promise"];
|
|
44276
44277
|
const checker = parserServices.program.getTypeChecker();
|
|
44277
|
-
function checkNode(node) {
|
|
44278
|
+
function checkNode(node, messageId) {
|
|
44278
44279
|
const name = node.name;
|
|
44279
44280
|
if (!name || name === "_" || !parserServices?.esTreeNodeToTSNodeMap) {
|
|
44280
44281
|
return;
|
|
@@ -44282,21 +44283,12 @@ var rule7 = createRule7({
|
|
|
44282
44283
|
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
|
44283
44284
|
const type = checker.getTypeAtLocation(tsNode);
|
|
44284
44285
|
const typeName = checker.typeToString(type);
|
|
44285
|
-
const
|
|
44286
|
-
const suffix =
|
|
44287
|
-
|
|
44288
|
-
node,
|
|
44289
|
-
messageId: "reactiveNamingConvention",
|
|
44290
|
-
data: {
|
|
44291
|
-
typeName,
|
|
44292
|
-
name,
|
|
44293
|
-
suffix
|
|
44294
|
-
}
|
|
44295
|
-
});
|
|
44296
|
-
if ((isReactiveReadonlyTypes || listeReactiveWritableTypes.includes(typeName)) && (!name.endsWith(suffix) || suffix === "$" && name.endsWith("$$"))) {
|
|
44286
|
+
const isReactiveWritableTypes = listeReactiveWritableTypes.some((t) => new RegExp(`${t}<.+>`).test(typeName));
|
|
44287
|
+
const suffix = isReactiveWritableTypes ? "$$" : "$";
|
|
44288
|
+
if ((isReactiveWritableTypes || listeReactiveReadonlyTypes.some((t) => new RegExp(`${t}<.+>`).test(typeName))) && (!name.endsWith(suffix) || suffix === "$" && name.endsWith("$$"))) {
|
|
44297
44289
|
context.report({
|
|
44298
44290
|
node,
|
|
44299
|
-
messageId
|
|
44291
|
+
messageId,
|
|
44300
44292
|
data: {
|
|
44301
44293
|
typeName,
|
|
44302
44294
|
name,
|
|
@@ -44336,13 +44328,13 @@ var rule7 = createRule7({
|
|
|
44336
44328
|
// Déclarations de variables : const x = signal(0)
|
|
44337
44329
|
VariableDeclarator(node) {
|
|
44338
44330
|
if (node.id?.type === "Identifier") {
|
|
44339
|
-
checkNode(node.id);
|
|
44331
|
+
checkNode(node.id, "reactiveVariableNamingConvention");
|
|
44340
44332
|
}
|
|
44341
44333
|
},
|
|
44342
44334
|
// Propriétés de classe : count = signal(0)
|
|
44343
44335
|
PropertyDefinition(node) {
|
|
44344
44336
|
if (node.key?.type === "Identifier") {
|
|
44345
|
-
checkNode(node.key);
|
|
44337
|
+
checkNode(node.key, "reactivePropertyNamingConvention");
|
|
44346
44338
|
}
|
|
44347
44339
|
}
|
|
44348
44340
|
};
|