eslint-plugin-mgw-eslint-rules 2.3.19 → 2.3.21
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 +49 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -44314,10 +44314,6 @@ var import_utils10 = __toESM(require_dist4());
|
|
|
44314
44314
|
var NAMING_CONVENTIONS = ["camelCase", "strictCamelCase", "PascalCase", "StrictPascalCase", "snake_case", "UPPER_CASE", "kebab-case"];
|
|
44315
44315
|
var ATTRIBUTE_CONVENTION_POSSIBLE_VALUES = [...NAMING_CONVENTIONS];
|
|
44316
44316
|
var RULE_NAME8 = "template/attributes-naming-convention";
|
|
44317
|
-
var ATTRIBUTE_DEFAULT_VALUES = {
|
|
44318
|
-
id: "kebab-case",
|
|
44319
|
-
class: "kebab-case"
|
|
44320
|
-
};
|
|
44321
44317
|
var conventionPatterns = {
|
|
44322
44318
|
camelCase: /^[a-z][a-zA-Z0-9]*$/,
|
|
44323
44319
|
strictCamelCase: /^(?!.*[A-Z]{2})[a-z][a-zA-Z0-9]*$/,
|
|
@@ -44361,12 +44357,26 @@ var rule8 = createRule8({
|
|
|
44361
44357
|
enum: ATTRIBUTE_CONVENTION_POSSIBLE_VALUES
|
|
44362
44358
|
},
|
|
44363
44359
|
minItems: 1
|
|
44360
|
+
},
|
|
44361
|
+
{
|
|
44362
|
+
type: "object",
|
|
44363
|
+
properties: {
|
|
44364
|
+
pattern: {
|
|
44365
|
+
type: "array",
|
|
44366
|
+
items: {
|
|
44367
|
+
type: "string"
|
|
44368
|
+
},
|
|
44369
|
+
minItems: 1,
|
|
44370
|
+
//default: [],
|
|
44371
|
+
description: "Patterns regex to test"
|
|
44372
|
+
}
|
|
44373
|
+
},
|
|
44374
|
+
required: ["pattern"]
|
|
44364
44375
|
}
|
|
44365
44376
|
]
|
|
44366
44377
|
}
|
|
44367
44378
|
}
|
|
44368
44379
|
},
|
|
44369
|
-
//required: ['conventions'],
|
|
44370
44380
|
additionalProperties: false
|
|
44371
44381
|
}
|
|
44372
44382
|
],
|
|
@@ -44374,44 +44384,50 @@ var rule8 = createRule8({
|
|
|
44374
44384
|
},
|
|
44375
44385
|
defaultOptions: [
|
|
44376
44386
|
{
|
|
44377
|
-
|
|
44387
|
+
id: "kebab-case",
|
|
44388
|
+
class: "kebab-case"
|
|
44378
44389
|
}
|
|
44379
44390
|
],
|
|
44380
44391
|
create(context, [options]) {
|
|
44381
44392
|
const parserServices = (0, import_utils9.getTemplateParserServices)(context);
|
|
44382
|
-
const attributesConfig = options.attributes || ATTRIBUTE_DEFAULT_VALUES;
|
|
44383
44393
|
const listeAttributes = new Map(
|
|
44384
|
-
Object.entries(
|
|
44394
|
+
Object.entries(options).map(([a, n]) => {
|
|
44385
44395
|
const listeNommage = typeof n === "string" ? [n] : n;
|
|
44386
|
-
|
|
44387
|
-
|
|
44396
|
+
if (Array.isArray(listeNommage)) {
|
|
44397
|
+
const nommageReg = listeNommage.map((c) => conventionPatterns[c]);
|
|
44398
|
+
return [a, { noms: listeNommage.join(", "), regs: nommageReg }];
|
|
44399
|
+
}
|
|
44400
|
+
return [
|
|
44401
|
+
a,
|
|
44402
|
+
{
|
|
44403
|
+
noms: listeNommage.pattern.join(", "),
|
|
44404
|
+
regs: listeNommage.pattern.map((p) => new RegExp(p))
|
|
44405
|
+
}
|
|
44406
|
+
];
|
|
44388
44407
|
})
|
|
44389
44408
|
);
|
|
44390
44409
|
return {
|
|
44391
44410
|
// Détecte les attributs dans les templates (parcours global élément (noeud) par élément)
|
|
44392
|
-
|
|
44393
|
-
|
|
44394
|
-
|
|
44395
|
-
|
|
44396
|
-
|
|
44397
|
-
|
|
44398
|
-
|
|
44399
|
-
|
|
44400
|
-
|
|
44401
|
-
|
|
44402
|
-
|
|
44403
|
-
|
|
44404
|
-
|
|
44405
|
-
|
|
44406
|
-
|
|
44407
|
-
|
|
44408
|
-
|
|
44409
|
-
|
|
44410
|
-
|
|
44411
|
-
|
|
44412
|
-
conventions: attrNomme.noms
|
|
44413
|
-
}
|
|
44414
|
-
});
|
|
44411
|
+
"Element[attributes]"(node) {
|
|
44412
|
+
const attributes = node.attributes;
|
|
44413
|
+
for (const attr of attributes) {
|
|
44414
|
+
if (attr.value) {
|
|
44415
|
+
const attrNomme = listeAttributes.get(attr.name);
|
|
44416
|
+
if (attrNomme) {
|
|
44417
|
+
const attributeValues = attr.value.split(/\s+/);
|
|
44418
|
+
for (const attrValue of attributeValues) {
|
|
44419
|
+
if (!attrNomme.regs.some((pattern) => pattern.test(attrValue))) {
|
|
44420
|
+
const loc = parserServices.convertNodeSourceSpanToLoc(node.sourceSpan);
|
|
44421
|
+
context.report({
|
|
44422
|
+
loc,
|
|
44423
|
+
messageId: "invalidNaming",
|
|
44424
|
+
data: {
|
|
44425
|
+
attribute: attr.name,
|
|
44426
|
+
value: attrValue,
|
|
44427
|
+
conventions: attrNomme.noms
|
|
44428
|
+
}
|
|
44429
|
+
});
|
|
44430
|
+
}
|
|
44415
44431
|
}
|
|
44416
44432
|
}
|
|
44417
44433
|
}
|