@agilebot/eslint-plugin 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +6 -3
- package/dist/index.js +104 -6
- package/package.json +3 -4
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
|
1
|
+
import * as eslint from 'eslint';
|
2
|
+
|
2
3
|
declare namespace plugin {
|
3
|
-
let rules:
|
4
|
+
let rules: eslint.Linter.RulesRecord;
|
4
5
|
namespace configs {
|
5
6
|
namespace recommended {
|
6
7
|
export let plugins: string[];
|
7
|
-
let rules_1:
|
8
|
+
let rules_1: eslint.Linter.RulesRecord;
|
8
9
|
export { rules_1 as rules };
|
9
10
|
export namespace settings {
|
10
11
|
namespace react {
|
@@ -14,3 +15,5 @@ declare namespace plugin {
|
|
14
15
|
}
|
15
16
|
}
|
16
17
|
}
|
18
|
+
|
19
|
+
export { plugin as default };
|
package/dist/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license @agilebot/eslint-plugin v0.3.
|
2
|
+
* @license @agilebot/eslint-plugin v0.3.7
|
3
3
|
*
|
4
4
|
* Copyright (c) Agilebot, Inc. and its affiliates.
|
5
5
|
*
|
@@ -76,7 +76,15 @@ function getSetting(context, name) {
|
|
76
76
|
return context.settings["agilebot/".concat(name)];
|
77
77
|
}
|
78
78
|
|
79
|
-
|
79
|
+
const warned = new Set();
|
80
|
+
function warnOnce(message) {
|
81
|
+
if (warned.has(message)) {
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
warned.add(message);
|
85
|
+
console.warn("Warning: ".concat(message));
|
86
|
+
}
|
87
|
+
|
80
88
|
var importMonorepo = {
|
81
89
|
meta: {
|
82
90
|
type: 'problem',
|
@@ -95,10 +103,7 @@ var importMonorepo = {
|
|
95
103
|
ImportDeclaration(node) {
|
96
104
|
let prefix = getSetting(context, 'monorepo-scope');
|
97
105
|
if (!prefix) {
|
98
|
-
|
99
|
-
console.error('Warning: agilebot/monorepo-scope is not set.');
|
100
|
-
warnedForMissingPrefix = true;
|
101
|
-
}
|
106
|
+
warnOnce('agilebot/monorepo-scope is not set.');
|
102
107
|
return;
|
103
108
|
}
|
104
109
|
prefix = "".concat(prefix, "/");
|
@@ -269,6 +274,98 @@ var intlIdMissing = {
|
|
269
274
|
}
|
270
275
|
};
|
271
276
|
|
277
|
+
var intlIdNaming = {
|
278
|
+
meta: {
|
279
|
+
docs: {
|
280
|
+
description: 'Validates intl message ids naming convention',
|
281
|
+
category: 'Intl'
|
282
|
+
},
|
283
|
+
fixable: undefined,
|
284
|
+
schema: [{
|
285
|
+
type: 'object',
|
286
|
+
properties: {
|
287
|
+
format: {
|
288
|
+
"enum": ['camelCase', 'PascalCase']
|
289
|
+
}
|
290
|
+
}
|
291
|
+
}],
|
292
|
+
messages: {
|
293
|
+
invalidIdNaming: "Invalid id naming, expected {{format}}"
|
294
|
+
}
|
295
|
+
},
|
296
|
+
create: function (context) {
|
297
|
+
if (!context.options[0]) {
|
298
|
+
throw new Error('Missing options');
|
299
|
+
}
|
300
|
+
const format = context.options[0].format;
|
301
|
+
function report(node, value) {
|
302
|
+
const values = value.split('.');
|
303
|
+
let isPass;
|
304
|
+
for (const v of values) {
|
305
|
+
switch (format) {
|
306
|
+
case 'camelCase':
|
307
|
+
if (!eslintUtils.isCamelCase(v)) {
|
308
|
+
isPass = false;
|
309
|
+
}
|
310
|
+
break;
|
311
|
+
case 'PascalCase':
|
312
|
+
if (!eslintUtils.isPascalCase(v)) {
|
313
|
+
isPass = false;
|
314
|
+
}
|
315
|
+
break;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
if (isPass === false) {
|
319
|
+
context.report({
|
320
|
+
node: node,
|
321
|
+
messageId: 'invalidIdNaming',
|
322
|
+
data: {
|
323
|
+
format
|
324
|
+
}
|
325
|
+
});
|
326
|
+
}
|
327
|
+
}
|
328
|
+
function processLiteral(node) {
|
329
|
+
report(node, node.value);
|
330
|
+
}
|
331
|
+
function processTemplateLiteral(node) {
|
332
|
+
const displayStr = templateLiteralDisplayStr(node);
|
333
|
+
report(node, displayStr);
|
334
|
+
}
|
335
|
+
function processAttrNode(node) {
|
336
|
+
if (node.value.type === 'Literal') {
|
337
|
+
return processLiteral(node.value);
|
338
|
+
}
|
339
|
+
if (node.value.type === 'JSXExpressionContainer' && node.value.expression.type === 'TemplateLiteral') {
|
340
|
+
return processTemplateLiteral(node.value.expression);
|
341
|
+
}
|
342
|
+
if (node.value.type === 'TemplateLiteral') {
|
343
|
+
return processTemplateLiteral(node.value);
|
344
|
+
}
|
345
|
+
}
|
346
|
+
return {
|
347
|
+
JSXIdentifier: function (node) {
|
348
|
+
const attrNode = findFormattedMessageAttrNode(node, 'id');
|
349
|
+
if (attrNode) {
|
350
|
+
return processAttrNode(attrNode);
|
351
|
+
}
|
352
|
+
},
|
353
|
+
CallExpression: function (node) {
|
354
|
+
const attrNode = findFormatMessageAttrNode(node, 'id');
|
355
|
+
if (attrNode) {
|
356
|
+
return processAttrNode(attrNode);
|
357
|
+
}
|
358
|
+
},
|
359
|
+
Property: function (node) {
|
360
|
+
const attrNode = findAttrNodeInDefineMessages(node, 'id') || findAttrNodeInDefineMessage(node, 'id');
|
361
|
+
if (attrNode) {
|
362
|
+
return processAttrNode(attrNode);
|
363
|
+
}
|
364
|
+
}
|
365
|
+
};
|
366
|
+
}
|
367
|
+
};
|
368
|
+
|
272
369
|
var intlIdPrefix = {
|
273
370
|
meta: {
|
274
371
|
docs: {
|
@@ -2416,6 +2513,7 @@ var ruleFiles = /*#__PURE__*/Object.freeze({
|
|
2416
2513
|
rules_enforce_mui_icon_alias: enforceMuiIconAlias,
|
2417
2514
|
rules_import_monorepo: importMonorepo,
|
2418
2515
|
rules_intl_id_missing: intlIdMissing,
|
2516
|
+
rules_intl_id_naming: intlIdNaming,
|
2419
2517
|
rules_intl_id_prefix: intlIdPrefix,
|
2420
2518
|
rules_intl_id_unused: intlIdUnused,
|
2421
2519
|
rules_intl_no_default: intlNoDefault,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@agilebot/eslint-plugin",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.7",
|
4
4
|
"description": "Agilebot's ESLint plugin",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"dependencies": {
|
21
21
|
"@typescript-eslint/utils": "~7.9.0",
|
22
22
|
"eslint-plugin-react": "^7.34.1",
|
23
|
-
"@agilebot/eslint-utils": "0.3.
|
23
|
+
"@agilebot/eslint-utils": "0.3.7"
|
24
24
|
},
|
25
25
|
"peerDependencies": {
|
26
26
|
"eslint": "^7.0.0 || ^8.0.0"
|
@@ -35,8 +35,7 @@
|
|
35
35
|
"eslint-vitest-rule-tester": "^0.3.2"
|
36
36
|
},
|
37
37
|
"scripts": {
|
38
|
-
"build": "rollup -c rollup.config.mjs
|
39
|
-
"dts": "tsc -p tsconfig.dts.json",
|
38
|
+
"build": "rollup -c rollup.config.mjs",
|
40
39
|
"lint": "eslint src --fix"
|
41
40
|
}
|
42
41
|
}
|