eslint-plugin-mgw-eslint-rules 2.3.20 → 2.3.22
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 +42 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -31
- 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]*$/,
|
|
@@ -44344,53 +44340,68 @@ var rule8 = createRule8({
|
|
|
44344
44340
|
schema: [
|
|
44345
44341
|
{
|
|
44346
44342
|
type: "object",
|
|
44347
|
-
|
|
44348
|
-
|
|
44343
|
+
description: "Map of attribute names to their allowed naming conventions (single or array).",
|
|
44344
|
+
anyOf: [
|
|
44345
|
+
{
|
|
44346
|
+
type: "string",
|
|
44347
|
+
enum: ATTRIBUTE_CONVENTION_POSSIBLE_VALUES
|
|
44348
|
+
},
|
|
44349
|
+
{
|
|
44350
|
+
type: "array",
|
|
44351
|
+
items: {
|
|
44352
|
+
type: "string",
|
|
44353
|
+
enum: ATTRIBUTE_CONVENTION_POSSIBLE_VALUES
|
|
44354
|
+
},
|
|
44355
|
+
minItems: 1
|
|
44356
|
+
},
|
|
44357
|
+
{
|
|
44349
44358
|
type: "object",
|
|
44350
|
-
|
|
44351
|
-
|
|
44352
|
-
|
|
44353
|
-
{
|
|
44354
|
-
type: "string"
|
|
44355
|
-
enum: ATTRIBUTE_CONVENTION_POSSIBLE_VALUES
|
|
44359
|
+
properties: {
|
|
44360
|
+
pattern: {
|
|
44361
|
+
type: "array",
|
|
44362
|
+
items: {
|
|
44363
|
+
type: "string"
|
|
44356
44364
|
},
|
|
44357
|
-
|
|
44358
|
-
|
|
44359
|
-
|
|
44360
|
-
|
|
44361
|
-
|
|
44362
|
-
|
|
44363
|
-
|
|
44364
|
-
}
|
|
44365
|
-
]
|
|
44366
|
-
}
|
|
44365
|
+
minItems: 1,
|
|
44366
|
+
//default: [],
|
|
44367
|
+
description: "Patterns regex to test"
|
|
44368
|
+
}
|
|
44369
|
+
},
|
|
44370
|
+
required: ["pattern"],
|
|
44371
|
+
additionalProperties: false
|
|
44367
44372
|
}
|
|
44368
|
-
|
|
44369
|
-
//required: ['conventions'],
|
|
44370
|
-
additionalProperties: false
|
|
44373
|
+
]
|
|
44371
44374
|
}
|
|
44372
44375
|
],
|
|
44373
44376
|
hasSuggestions: true
|
|
44374
44377
|
},
|
|
44375
44378
|
defaultOptions: [
|
|
44376
44379
|
{
|
|
44377
|
-
|
|
44380
|
+
id: "kebab-case",
|
|
44381
|
+
class: "kebab-case"
|
|
44378
44382
|
}
|
|
44379
44383
|
],
|
|
44380
44384
|
create(context, [options]) {
|
|
44381
44385
|
const parserServices = (0, import_utils9.getTemplateParserServices)(context);
|
|
44382
|
-
const attributesConfig = options.attributes || ATTRIBUTE_DEFAULT_VALUES;
|
|
44383
44386
|
const listeAttributes = new Map(
|
|
44384
|
-
Object.entries(
|
|
44387
|
+
Object.entries(options).map(([a, n]) => {
|
|
44385
44388
|
const listeNommage = typeof n === "string" ? [n] : n;
|
|
44386
|
-
|
|
44387
|
-
|
|
44389
|
+
if (Array.isArray(listeNommage)) {
|
|
44390
|
+
const nommageReg = listeNommage.map((c) => conventionPatterns[c]);
|
|
44391
|
+
return [a, { noms: listeNommage.join(", "), regs: nommageReg }];
|
|
44392
|
+
}
|
|
44393
|
+
return [
|
|
44394
|
+
a,
|
|
44395
|
+
{
|
|
44396
|
+
noms: listeNommage.pattern.join(", "),
|
|
44397
|
+
regs: listeNommage.pattern.map((p) => new RegExp(p))
|
|
44398
|
+
}
|
|
44399
|
+
];
|
|
44388
44400
|
})
|
|
44389
44401
|
);
|
|
44390
44402
|
return {
|
|
44391
44403
|
// Détecte les attributs dans les templates (parcours global élément (noeud) par élément)
|
|
44392
44404
|
"Element[attributes]"(node) {
|
|
44393
|
-
console.log(node);
|
|
44394
44405
|
const attributes = node.attributes;
|
|
44395
44406
|
for (const attr of attributes) {
|
|
44396
44407
|
if (attr.value) {
|